7 // Decode from stream to destination struct.
8 // The actual struct pointed to by dest must match the description in fields.
9 bool pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest);
11 /* --- Helper functions ---
12 * You may want to use these from your callbacks.
15 bool pb_decode_varint32(pb_istream_t *stream, uint32_t *dest);
16 bool pb_decode_varint64(pb_istream_t *stream, uint64_t *dest);
18 bool pb_skip_varint(pb_istream_t *stream);
19 bool pb_skip_string(pb_istream_t *stream);
21 /* --- Field decoders ---
22 * Each decoder takes stream and field description, and a pointer to the field
23 * in the destination struct (dest = struct_addr + field->offset).
27 bool pb_dec_uint32(pb_istream_t *stream, const pb_field_t *field, void *dest);
28 bool pb_dec_sint32(pb_istream_t *stream, const pb_field_t *field, void *dest);
29 bool pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest);
30 bool pb_dec_uint64(pb_istream_t *stream, const pb_field_t *field, void *dest);
31 bool pb_dec_sint64(pb_istream_t *stream, const pb_field_t *field, void *dest);
32 bool pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest);
33 bool pb_dec_bool(pb_istream_t *stream, const pb_field_t *field, void *dest);
35 // Floating point types. Info is ignored.
36 bool pb_dec_float(pb_istream_t *stream, const pb_field_t *field, void *dest);
37 bool pb_dec_double(pb_istream_t *stream, const pb_field_t *field, void *dest);
39 // Byte array. Dest is pointer to
40 bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest);
42 // Null-terminated string.
43 bool pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest);
45 // Use callback. Dest is pointer to pb_callback_t struct.
46 bool pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest);
48 typedef bool (*pb_decoder_t)(pb_istream_t *stream, const pb_field_t *field, void *dest);
50 /* --- Function pointers to field decoders ---
51 * Order in the array must match pb_action_t numbering.
53 const pb_decoder_t PB_DECODERS[PB_LAST_ACT];