X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=pb_common.h;h=60b3d37491446fa18b4f8d2003cd6b287d41d6bd;hb=516a5eab2c5904b2cd39d4958b0c101bafd8e060;hp=e85f000c6ac9389ddb93af21e242b2789b55e858;hpb=a641e21b34aed824b6b919f7ab9937eaadf09473;p=apps%2Fagl-service-can-low-level.git diff --git a/pb_common.h b/pb_common.h index e85f000c..60b3d374 100644 --- a/pb_common.h +++ b/pb_common.h @@ -2,8 +2,8 @@ * These functions are rarely needed by applications directly. */ -#ifndef _PB_COMMON_H_ -#define _PB_COMMON_H_ +#ifndef PB_COMMON_H_INCLUDED +#define PB_COMMON_H_INCLUDED #include "pb.h" @@ -12,17 +12,19 @@ extern "C" { #endif /* Iterator for pb_field_t list */ -typedef struct { +struct pb_field_iter_s { const pb_field_t *start; /* Start of the pb_field_t array */ const pb_field_t *pos; /* Current position of the iterator */ unsigned required_field_index; /* Zero-based index that counts only the required fields */ - void *dest_struct; /* Pointer to the destination structure to decode to */ - void *pData; /* Pointer where to store current field value */ - void *pSize; /* Pointer where to store the size of current array field */ -} pb_field_iter_t; - -/* Initialize the field iterator structure to beginning. */ -void pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); + void *dest_struct; /* Pointer to start of the structure */ + void *pData; /* Pointer to current field value */ + void *pSize; /* Pointer to count/has field */ +}; +typedef struct pb_field_iter_s pb_field_iter_t; + +/* Initialize the field iterator structure to beginning. + * Returns false if the message type is empty. */ +bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); /* Advance the iterator to the next field. * Returns false when the iterator wraps back to the first field. */