2
0

pb_common.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /* Initialize the field iterator structure to beginning.
  11. * Returns false if the message type is empty. */
  12. bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_msgdesc_t *desc, void *message);
  13. /* Get a field iterator for extension field. */
  14. bool pb_field_iter_begin_extension(pb_field_iter_t *iter, pb_extension_t *extension);
  15. /* Same as pb_field_iter_begin(), but for const message pointer.
  16. * Note that the pointers in pb_field_iter_t will be non-const but shouldn't
  17. * be written to when using these functions. */
  18. bool pb_field_iter_begin_const(pb_field_iter_t *iter, const pb_msgdesc_t *desc, const void *message);
  19. bool pb_field_iter_begin_extension_const(pb_field_iter_t *iter, const pb_extension_t *extension);
  20. /* Advance the iterator to the next field.
  21. * Returns false when the iterator wraps back to the first field. */
  22. bool pb_field_iter_next(pb_field_iter_t *iter);
  23. /* Advance the iterator until it points at a field with the given tag.
  24. * Returns false if no such field exists. */
  25. bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag);
  26. /* Find a field with type PB_LTYPE_EXTENSION, or return false if not found.
  27. * There can be only one extension range field per message. */
  28. bool pb_field_iter_find_extension(pb_field_iter_t *iter);
  29. #ifdef PB_VALIDATE_UTF8
  30. /* Validate UTF-8 text string */
  31. bool pb_validate_utf8(const char *s);
  32. #endif
  33. #ifdef __cplusplus
  34. } /* extern "C" */
  35. #endif
  36. #endif