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