Nanopb files
Dependents: nanopb_V2 Message_generator LEX_Threaded_Programming_V3
pb_common.h@3:67ee10c4ae98, 2019-08-19 (annotated)
- Committer:
- omatthews
- Date:
- Mon Aug 19 15:23:39 2019 +0000
- Revision:
- 3:67ee10c4ae98
- Parent:
- 2:d2c61a9be078
It works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
omatthews | 2:d2c61a9be078 | 1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. |
omatthews | 2:d2c61a9be078 | 2 | * These functions are rarely needed by applications directly. |
omatthews | 2:d2c61a9be078 | 3 | */ |
omatthews | 2:d2c61a9be078 | 4 | |
omatthews | 2:d2c61a9be078 | 5 | #ifndef PB_COMMON_H_INCLUDED |
omatthews | 2:d2c61a9be078 | 6 | #define PB_COMMON_H_INCLUDED |
omatthews | 2:d2c61a9be078 | 7 | |
omatthews | 2:d2c61a9be078 | 8 | #include "pb.h" |
omatthews | 2:d2c61a9be078 | 9 | |
omatthews | 2:d2c61a9be078 | 10 | #ifdef __cplusplus |
omatthews | 2:d2c61a9be078 | 11 | extern "C" { |
omatthews | 2:d2c61a9be078 | 12 | #endif |
omatthews | 2:d2c61a9be078 | 13 | |
omatthews | 2:d2c61a9be078 | 14 | /* Iterator for pb_field_t list */ |
omatthews | 2:d2c61a9be078 | 15 | struct pb_field_iter_s { |
omatthews | 2:d2c61a9be078 | 16 | const pb_field_t *start; /* Start of the pb_field_t array */ |
omatthews | 2:d2c61a9be078 | 17 | const pb_field_t *pos; /* Current position of the iterator */ |
omatthews | 2:d2c61a9be078 | 18 | unsigned required_field_index; /* Zero-based index that counts only the required fields */ |
omatthews | 2:d2c61a9be078 | 19 | void *dest_struct; /* Pointer to start of the structure */ |
omatthews | 2:d2c61a9be078 | 20 | void *pData; /* Pointer to current field value */ |
omatthews | 2:d2c61a9be078 | 21 | void *pSize; /* Pointer to count/has field */ |
omatthews | 2:d2c61a9be078 | 22 | }; |
omatthews | 2:d2c61a9be078 | 23 | typedef struct pb_field_iter_s pb_field_iter_t; |
omatthews | 2:d2c61a9be078 | 24 | |
omatthews | 2:d2c61a9be078 | 25 | /* Initialize the field iterator structure to beginning. |
omatthews | 2:d2c61a9be078 | 26 | * Returns false if the message type is empty. */ |
omatthews | 2:d2c61a9be078 | 27 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); |
omatthews | 2:d2c61a9be078 | 28 | |
omatthews | 2:d2c61a9be078 | 29 | /* Advance the iterator to the next field. |
omatthews | 2:d2c61a9be078 | 30 | * Returns false when the iterator wraps back to the first field. */ |
omatthews | 2:d2c61a9be078 | 31 | bool pb_field_iter_next(pb_field_iter_t *iter); |
omatthews | 2:d2c61a9be078 | 32 | |
omatthews | 2:d2c61a9be078 | 33 | /* Advance the iterator until it points at a field with the given tag. |
omatthews | 2:d2c61a9be078 | 34 | * Returns false if no such field exists. */ |
omatthews | 2:d2c61a9be078 | 35 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); |
omatthews | 2:d2c61a9be078 | 36 | |
omatthews | 2:d2c61a9be078 | 37 | #ifdef __cplusplus |
omatthews | 2:d2c61a9be078 | 38 | } /* extern "C" */ |
omatthews | 2:d2c61a9be078 | 39 | #endif |
omatthews | 2:d2c61a9be078 | 40 | |
omatthews | 2:d2c61a9be078 | 41 | #endif |