The open source OpenXR runtime
at main 49 lines 1.7 kB view raw
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 5#ifndef PB_COMMON_H_INCLUDED 6#define PB_COMMON_H_INCLUDED 7 8#include "pb.h" 9 10#ifdef __cplusplus 11extern "C" { 12#endif 13 14/* Initialize the field iterator structure to beginning. 15 * Returns false if the message type is empty. */ 16bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_msgdesc_t *desc, void *message); 17 18/* Get a field iterator for extension field. */ 19bool pb_field_iter_begin_extension(pb_field_iter_t *iter, pb_extension_t *extension); 20 21/* Same as pb_field_iter_begin(), but for const message pointer. 22 * Note that the pointers in pb_field_iter_t will be non-const but shouldn't 23 * be written to when using these functions. */ 24bool pb_field_iter_begin_const(pb_field_iter_t *iter, const pb_msgdesc_t *desc, const void *message); 25bool pb_field_iter_begin_extension_const(pb_field_iter_t *iter, const pb_extension_t *extension); 26 27/* Advance the iterator to the next field. 28 * Returns false when the iterator wraps back to the first field. */ 29bool pb_field_iter_next(pb_field_iter_t *iter); 30 31/* Advance the iterator until it points at a field with the given tag. 32 * Returns false if no such field exists. */ 33bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); 34 35/* Find a field with type PB_LTYPE_EXTENSION, or return false if not found. 36 * There can be only one extension range field per message. */ 37bool pb_field_iter_find_extension(pb_field_iter_t *iter); 38 39#ifdef PB_VALIDATE_UTF8 40/* Validate UTF-8 text string */ 41bool pb_validate_utf8(const char *s); 42#endif 43 44#ifdef __cplusplus 45} /* extern "C" */ 46#endif 47 48#endif 49