diff options
author | Yuchen Zeng <zyc@google.com> | 2016-10-03 13:24:13 -0700 |
---|---|---|
committer | Yuchen Zeng <zyc@google.com> | 2016-10-03 13:24:13 -0700 |
commit | 6988838a67479d2873fb724625cec28f1b0b5639 (patch) | |
tree | dceb3aba7883ca7269ebbf8521ead56f49a5cf0f /third_party/nanopb/pb_common.h | |
parent | c87b77fb3d3c333f4bfc7e732410a4dae6beb4f3 (diff) | |
parent | 9070ab6610bd8cd0dbe6922a049a3b094c908bd1 (diff) |
Merge remote-tracking branch 'upstream/master' into cares_buildin
Diffstat (limited to 'third_party/nanopb/pb_common.h')
-rw-r--r-- | third_party/nanopb/pb_common.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/third_party/nanopb/pb_common.h b/third_party/nanopb/pb_common.h new file mode 100644 index 0000000000..60b3d37491 --- /dev/null +++ b/third_party/nanopb/pb_common.h @@ -0,0 +1,42 @@ +/* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. + * These functions are rarely needed by applications directly. + */ + +#ifndef PB_COMMON_H_INCLUDED +#define PB_COMMON_H_INCLUDED + +#include "pb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Iterator for pb_field_t list */ +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 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. */ +bool pb_field_iter_next(pb_field_iter_t *iter); + +/* Advance the iterator until it points at a field with the given tag. + * Returns false if no such field exists. */ +bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif + |