暫無描述

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c.
  2. * These functions are rarely needed by applications directly.
  3. */
  4. #ifndef PB_COMMON_H_INCLUDED
  5. #define PB_COMMON_H_INCLUDED
  6. #include "pb.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /* Iterator for pb_field_t list */
  11. struct pb_field_iter_s {
  12. const pb_field_t *start; /* Start of the pb_field_t array */
  13. const pb_field_t *pos; /* Current position of the iterator */
  14. unsigned required_field_index; /* Zero-based index that counts only the required fields */
  15. void *dest_struct; /* Pointer to start of the structure */
  16. void *pData; /* Pointer to current field value */
  17. void *pSize; /* Pointer to count/has field */
  18. };
  19. typedef struct pb_field_iter_s pb_field_iter_t;
  20. /* Initialize the field iterator structure to beginning.
  21. * Returns false if the message type is empty. */
  22. bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct);
  23. /* Advance the iterator to the next field.
  24. * Returns false when the iterator wraps back to the first field. */
  25. bool pb_field_iter_next(pb_field_iter_t *iter);
  26. /* Advance the iterator until it points at a field with the given tag.
  27. * Returns false if no such field exists. */
  28. bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag);
  29. #ifdef __cplusplus
  30. } /* extern "C" */
  31. #endif
  32. #endif