68#define NANOPB_VERSION "nanopb-0.4.9-dev"
81#ifdef PB_SYSTEM_HEADER
82#include PB_SYSTEM_HEADER
90#ifdef PB_ENABLE_MALLOC
102#if defined(PB_NO_PACKED_STRUCTS)
104# define PB_PACKED_STRUCT_START
105# define PB_PACKED_STRUCT_END
107#elif defined(__GNUC__) || defined(__clang__)
109# define PB_PACKED_STRUCT_START
110# define PB_PACKED_STRUCT_END
111# define pb_packed __attribute__((packed))
112#elif defined(__ICCARM__) || defined(__CC_ARM)
114# define PB_PACKED_STRUCT_START _Pragma("pack(push, 1)")
115# define PB_PACKED_STRUCT_END _Pragma("pack(pop)")
117#elif defined(_MSC_VER) && (_MSC_VER >= 1500)
119# define PB_PACKED_STRUCT_START __pragma(pack(push, 1))
120# define PB_PACKED_STRUCT_END __pragma(pack(pop))
124# define PB_PACKED_STRUCT_START
125# define PB_PACKED_STRUCT_END
130#ifndef PB_LITTLE_ENDIAN_8BIT
131#if ((defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \
132 (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
133 defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || \
134 defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || \
135 defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM)) \
137#define PB_LITTLE_ENDIAN_8BIT 1
143#define PB_UNUSED(x) (void)(x)
150#include <avr/pgmspace.h>
151#define PB_PROGMEM PROGMEM
152#define PB_PROGMEM_READU32(x) pgm_read_dword(&x)
155#define PB_PROGMEM_READU32(x) (x)
168#ifndef PB_NO_STATIC_ASSERT
169# ifndef PB_STATIC_ASSERT
170# if defined(__ICCARM__)
172# define PB_STATIC_ASSERT(COND,MSG) static_assert(COND,#MSG);
173# elif defined(_MSC_VER) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112)
175# define PB_STATIC_ASSERT(COND,MSG) static_assert(COND,#MSG);
176# elif defined(PB_C99_STATIC_ASSERT)
178# define PB_STATIC_ASSERT(COND,MSG) typedef char PB_STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1];
179# define PB_STATIC_ASSERT_MSG(MSG, LINE, COUNTER) PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER)
180# define PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) pb_static_assertion_##MSG##_##LINE##_##COUNTER
181# elif defined(__cplusplus)
183# define PB_STATIC_ASSERT(COND,MSG) static_assert(COND,#MSG);
186# define PB_STATIC_ASSERT(COND,MSG) _Static_assert(COND,#MSG);
191# define PB_STATIC_ASSERT(COND,MSG)
203#ifndef PB_MAX_REQUIRED_FIELDS
204#define PB_MAX_REQUIRED_FIELDS 64
207#if PB_MAX_REQUIRED_FIELDS < 64
208#error You should not lower PB_MAX_REQUIRED_FIELDS from the default value (64).
211#ifdef PB_WITHOUT_64BIT
212#ifdef PB_CONVERT_DOUBLE_FLOAT
214#undef PB_CONVERT_DOUBLE_FLOAT
222#if defined(PB_BYTE_T_OVERRIDE)
224#elif defined(UINT8_MAX)
239#define PB_LTYPE_BOOL 0x00U
240#define PB_LTYPE_VARINT 0x01U
241#define PB_LTYPE_UVARINT 0x02U
242#define PB_LTYPE_SVARINT 0x03U
243#define PB_LTYPE_FIXED32 0x04U
244#define PB_LTYPE_FIXED64 0x05U
247#define PB_LTYPE_LAST_PACKABLE 0x05U
251#define PB_LTYPE_BYTES 0x06U
255#define PB_LTYPE_STRING 0x07U
259#define PB_LTYPE_SUBMESSAGE 0x08U
264#define PB_LTYPE_SUBMSG_W_CB 0x09U
268#define PB_LTYPE_EXTENSION 0x0AU
274#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
277#define PB_LTYPES_COUNT 0x0CU
278#define PB_LTYPE_MASK 0x0FU
282#define PB_HTYPE_REQUIRED 0x00U
283#define PB_HTYPE_OPTIONAL 0x10U
284#define PB_HTYPE_SINGULAR 0x10U
285#define PB_HTYPE_REPEATED 0x20U
286#define PB_HTYPE_FIXARRAY 0x20U
287#define PB_HTYPE_ONEOF 0x30U
288#define PB_HTYPE_MASK 0x30U
292#define PB_ATYPE_STATIC 0x00U
293#define PB_ATYPE_POINTER 0x80U
294#define PB_ATYPE_CALLBACK 0x40U
295#define PB_ATYPE_MASK 0xC0U
297#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
298#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
299#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
300#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
301 PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
306#if defined(PB_FIELD_32BIT)
313#define PB_SIZE_MAX ((pb_size_t)-1)
367#ifndef PB_WITHOUT_64BIT
376#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; pb_byte_t bytes[n]; }
377#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
443 bool (*
decode)(pb_istream_t *stream, pb_extension_t *extension,
452 bool (*
encode)(pb_ostream_t *stream,
const pb_extension_t *extension);
461 const pb_extension_type_t *
type;
477#define pb_extension_init_zero {NULL,NULL,NULL,false}
481#ifdef PB_ENABLE_MALLOC
483# define pb_realloc(ptr, size) realloc(ptr, size)
486# define pb_free(ptr) free(ptr)
491#define PB_PROTO_HEADER_VERSION 40
495#define pb_membersize(st, m) (sizeof ((st*)0)->m)
497#define pb_arraysize(st, m) (pb_membersize(st, m) / pb_membersize(st, m[0]))
499#define pb_delta(st, m1, m2) ((int)offsetof(st, m1) - (int)offsetof(st, m2))
502#define PB_EXPAND(x) x
505#define PB_BIND(msgname, structname, width) \
506 const uint32_t structname ## _field_info[] PB_PROGMEM = \
508 msgname ## _FIELDLIST(PB_GEN_FIELD_INFO_ ## width, structname) \
511 const pb_msgdesc_t* const structname ## _submsg_info[] = \
513 msgname ## _FIELDLIST(PB_GEN_SUBMSG_INFO, structname) \
516 const pb_msgdesc_t structname ## _msg = \
518 structname ## _field_info, \
519 structname ## _submsg_info, \
520 msgname ## _DEFAULT, \
521 msgname ## _CALLBACK, \
522 0 msgname ## _FIELDLIST(PB_GEN_FIELD_COUNT, structname), \
523 0 msgname ## _FIELDLIST(PB_GEN_REQ_FIELD_COUNT, structname), \
524 0 msgname ## _FIELDLIST(PB_GEN_LARGEST_TAG, structname), \
526 msgname ## _FIELDLIST(PB_GEN_FIELD_INFO_ASSERT_ ## width, structname)
528#define PB_GEN_FIELD_COUNT(structname, atype, htype, ltype, fieldname, tag) +1
529#define PB_GEN_REQ_FIELD_COUNT(structname, atype, htype, ltype, fieldname, tag) \
530 + (PB_HTYPE_ ## htype == PB_HTYPE_REQUIRED)
531#define PB_GEN_LARGEST_TAG(structname, atype, htype, ltype, fieldname, tag) \
535#define PB_GEN_FIELD_INFO_1(structname, atype, htype, ltype, fieldname, tag) \
536 PB_FIELDINFO_1(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
537 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
538 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
539 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
540 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
542#define PB_GEN_FIELD_INFO_2(structname, atype, htype, ltype, fieldname, tag) \
543 PB_FIELDINFO_2(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
544 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
545 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
546 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
547 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
549#define PB_GEN_FIELD_INFO_4(structname, atype, htype, ltype, fieldname, tag) \
550 PB_FIELDINFO_4(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
551 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
552 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
553 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
554 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
556#define PB_GEN_FIELD_INFO_8(structname, atype, htype, ltype, fieldname, tag) \
557 PB_FIELDINFO_8(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
558 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
559 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
560 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
561 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
563#define PB_GEN_FIELD_INFO_AUTO(structname, atype, htype, ltype, fieldname, tag) \
564 PB_FIELDINFO_AUTO2(PB_FIELDINFO_WIDTH_AUTO(_PB_ATYPE_ ## atype, _PB_HTYPE_ ## htype, _PB_LTYPE_ ## ltype), \
565 tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
566 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
567 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
568 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
569 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
571#define PB_FIELDINFO_AUTO2(width, tag, type, data_offset, data_size, size_offset, array_size) \
572 PB_FIELDINFO_AUTO3(width, tag, type, data_offset, data_size, size_offset, array_size)
574#define PB_FIELDINFO_AUTO3(width, tag, type, data_offset, data_size, size_offset, array_size) \
575 PB_FIELDINFO_ ## width(tag, type, data_offset, data_size, size_offset, array_size)
580#define PB_GEN_FIELD_INFO_ASSERT_1(structname, atype, htype, ltype, fieldname, tag) \
581 PB_FIELDINFO_ASSERT_1(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
582 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
583 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
584 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
585 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
587#define PB_GEN_FIELD_INFO_ASSERT_2(structname, atype, htype, ltype, fieldname, tag) \
588 PB_FIELDINFO_ASSERT_2(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
589 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
590 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
591 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
592 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
594#define PB_GEN_FIELD_INFO_ASSERT_4(structname, atype, htype, ltype, fieldname, tag) \
595 PB_FIELDINFO_ASSERT_4(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
596 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
597 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
598 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
599 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
601#define PB_GEN_FIELD_INFO_ASSERT_8(structname, atype, htype, ltype, fieldname, tag) \
602 PB_FIELDINFO_ASSERT_8(tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
603 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
604 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
605 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
606 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
608#define PB_GEN_FIELD_INFO_ASSERT_AUTO(structname, atype, htype, ltype, fieldname, tag) \
609 PB_FIELDINFO_ASSERT_AUTO2(PB_FIELDINFO_WIDTH_AUTO(_PB_ATYPE_ ## atype, _PB_HTYPE_ ## htype, _PB_LTYPE_ ## ltype), \
610 tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
611 PB_DATA_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
612 PB_DATA_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
613 PB_SIZE_OFFSET_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname), \
614 PB_ARRAY_SIZE_ ## atype(_PB_HTYPE_ ## htype, structname, fieldname))
616#define PB_FIELDINFO_ASSERT_AUTO2(width, tag, type, data_offset, data_size, size_offset, array_size) \
617 PB_FIELDINFO_ASSERT_AUTO3(width, tag, type, data_offset, data_size, size_offset, array_size)
619#define PB_FIELDINFO_ASSERT_AUTO3(width, tag, type, data_offset, data_size, size_offset, array_size) \
620 PB_FIELDINFO_ASSERT_ ## width(tag, type, data_offset, data_size, size_offset, array_size)
622#define PB_DATA_OFFSET_STATIC(htype, structname, fieldname) PB_DO ## htype(structname, fieldname)
623#define PB_DATA_OFFSET_POINTER(htype, structname, fieldname) PB_DO ## htype(structname, fieldname)
624#define PB_DATA_OFFSET_CALLBACK(htype, structname, fieldname) PB_DO ## htype(structname, fieldname)
625#define PB_DO_PB_HTYPE_REQUIRED(structname, fieldname) offsetof(structname, fieldname)
626#define PB_DO_PB_HTYPE_SINGULAR(structname, fieldname) offsetof(structname, fieldname)
627#define PB_DO_PB_HTYPE_ONEOF(structname, fieldname) offsetof(structname, PB_ONEOF_NAME(FULL, fieldname))
628#define PB_DO_PB_HTYPE_OPTIONAL(structname, fieldname) offsetof(structname, fieldname)
629#define PB_DO_PB_HTYPE_REPEATED(structname, fieldname) offsetof(structname, fieldname)
630#define PB_DO_PB_HTYPE_FIXARRAY(structname, fieldname) offsetof(structname, fieldname)
632#define PB_SIZE_OFFSET_STATIC(htype, structname, fieldname) PB_SO ## htype(structname, fieldname)
633#define PB_SIZE_OFFSET_POINTER(htype, structname, fieldname) PB_SO_PTR ## htype(structname, fieldname)
634#define PB_SIZE_OFFSET_CALLBACK(htype, structname, fieldname) PB_SO_CB ## htype(structname, fieldname)
635#define PB_SO_PB_HTYPE_REQUIRED(structname, fieldname) 0
636#define PB_SO_PB_HTYPE_SINGULAR(structname, fieldname) 0
637#define PB_SO_PB_HTYPE_ONEOF(structname, fieldname) PB_SO_PB_HTYPE_ONEOF2(structname, PB_ONEOF_NAME(FULL, fieldname), PB_ONEOF_NAME(UNION, fieldname))
638#define PB_SO_PB_HTYPE_ONEOF2(structname, fullname, unionname) PB_SO_PB_HTYPE_ONEOF3(structname, fullname, unionname)
639#define PB_SO_PB_HTYPE_ONEOF3(structname, fullname, unionname) pb_delta(structname, fullname, which_ ## unionname)
640#define PB_SO_PB_HTYPE_OPTIONAL(structname, fieldname) pb_delta(structname, fieldname, has_ ## fieldname)
641#define PB_SO_PB_HTYPE_REPEATED(structname, fieldname) pb_delta(structname, fieldname, fieldname ## _count)
642#define PB_SO_PB_HTYPE_FIXARRAY(structname, fieldname) 0
643#define PB_SO_PTR_PB_HTYPE_REQUIRED(structname, fieldname) 0
644#define PB_SO_PTR_PB_HTYPE_SINGULAR(structname, fieldname) 0
645#define PB_SO_PTR_PB_HTYPE_ONEOF(structname, fieldname) PB_SO_PB_HTYPE_ONEOF(structname, fieldname)
646#define PB_SO_PTR_PB_HTYPE_OPTIONAL(structname, fieldname) 0
647#define PB_SO_PTR_PB_HTYPE_REPEATED(structname, fieldname) PB_SO_PB_HTYPE_REPEATED(structname, fieldname)
648#define PB_SO_PTR_PB_HTYPE_FIXARRAY(structname, fieldname) 0
649#define PB_SO_CB_PB_HTYPE_REQUIRED(structname, fieldname) 0
650#define PB_SO_CB_PB_HTYPE_SINGULAR(structname, fieldname) 0
651#define PB_SO_CB_PB_HTYPE_ONEOF(structname, fieldname) PB_SO_PB_HTYPE_ONEOF(structname, fieldname)
652#define PB_SO_CB_PB_HTYPE_OPTIONAL(structname, fieldname) 0
653#define PB_SO_CB_PB_HTYPE_REPEATED(structname, fieldname) 0
654#define PB_SO_CB_PB_HTYPE_FIXARRAY(structname, fieldname) 0
656#define PB_ARRAY_SIZE_STATIC(htype, structname, fieldname) PB_AS ## htype(structname, fieldname)
657#define PB_ARRAY_SIZE_POINTER(htype, structname, fieldname) PB_AS_PTR ## htype(structname, fieldname)
658#define PB_ARRAY_SIZE_CALLBACK(htype, structname, fieldname) 1
659#define PB_AS_PB_HTYPE_REQUIRED(structname, fieldname) 1
660#define PB_AS_PB_HTYPE_SINGULAR(structname, fieldname) 1
661#define PB_AS_PB_HTYPE_OPTIONAL(structname, fieldname) 1
662#define PB_AS_PB_HTYPE_ONEOF(structname, fieldname) 1
663#define PB_AS_PB_HTYPE_REPEATED(structname, fieldname) pb_arraysize(structname, fieldname)
664#define PB_AS_PB_HTYPE_FIXARRAY(structname, fieldname) pb_arraysize(structname, fieldname)
665#define PB_AS_PTR_PB_HTYPE_REQUIRED(structname, fieldname) 1
666#define PB_AS_PTR_PB_HTYPE_SINGULAR(structname, fieldname) 1
667#define PB_AS_PTR_PB_HTYPE_OPTIONAL(structname, fieldname) 1
668#define PB_AS_PTR_PB_HTYPE_ONEOF(structname, fieldname) 1
669#define PB_AS_PTR_PB_HTYPE_REPEATED(structname, fieldname) 1
670#define PB_AS_PTR_PB_HTYPE_FIXARRAY(structname, fieldname) pb_arraysize(structname, fieldname[0])
672#define PB_DATA_SIZE_STATIC(htype, structname, fieldname) PB_DS ## htype(structname, fieldname)
673#define PB_DATA_SIZE_POINTER(htype, structname, fieldname) PB_DS_PTR ## htype(structname, fieldname)
674#define PB_DATA_SIZE_CALLBACK(htype, structname, fieldname) PB_DS_CB ## htype(structname, fieldname)
675#define PB_DS_PB_HTYPE_REQUIRED(structname, fieldname) pb_membersize(structname, fieldname)
676#define PB_DS_PB_HTYPE_SINGULAR(structname, fieldname) pb_membersize(structname, fieldname)
677#define PB_DS_PB_HTYPE_OPTIONAL(structname, fieldname) pb_membersize(structname, fieldname)
678#define PB_DS_PB_HTYPE_ONEOF(structname, fieldname) pb_membersize(structname, PB_ONEOF_NAME(FULL, fieldname))
679#define PB_DS_PB_HTYPE_REPEATED(structname, fieldname) pb_membersize(structname, fieldname[0])
680#define PB_DS_PB_HTYPE_FIXARRAY(structname, fieldname) pb_membersize(structname, fieldname[0])
681#define PB_DS_PTR_PB_HTYPE_REQUIRED(structname, fieldname) pb_membersize(structname, fieldname[0])
682#define PB_DS_PTR_PB_HTYPE_SINGULAR(structname, fieldname) pb_membersize(structname, fieldname[0])
683#define PB_DS_PTR_PB_HTYPE_OPTIONAL(structname, fieldname) pb_membersize(structname, fieldname[0])
684#define PB_DS_PTR_PB_HTYPE_ONEOF(structname, fieldname) pb_membersize(structname, PB_ONEOF_NAME(FULL, fieldname)[0])
685#define PB_DS_PTR_PB_HTYPE_REPEATED(structname, fieldname) pb_membersize(structname, fieldname[0])
686#define PB_DS_PTR_PB_HTYPE_FIXARRAY(structname, fieldname) pb_membersize(structname, fieldname[0][0])
687#define PB_DS_CB_PB_HTYPE_REQUIRED(structname, fieldname) pb_membersize(structname, fieldname)
688#define PB_DS_CB_PB_HTYPE_SINGULAR(structname, fieldname) pb_membersize(structname, fieldname)
689#define PB_DS_CB_PB_HTYPE_OPTIONAL(structname, fieldname) pb_membersize(structname, fieldname)
690#define PB_DS_CB_PB_HTYPE_ONEOF(structname, fieldname) pb_membersize(structname, PB_ONEOF_NAME(FULL, fieldname))
691#define PB_DS_CB_PB_HTYPE_REPEATED(structname, fieldname) pb_membersize(structname, fieldname)
692#define PB_DS_CB_PB_HTYPE_FIXARRAY(structname, fieldname) pb_membersize(structname, fieldname)
694#define PB_ONEOF_NAME(type, tuple) PB_EXPAND(PB_ONEOF_NAME_ ## type tuple)
695#define PB_ONEOF_NAME_UNION(unionname,membername,fullname) unionname
696#define PB_ONEOF_NAME_MEMBER(unionname,membername,fullname) membername
697#define PB_ONEOF_NAME_FULL(unionname,membername,fullname) fullname
699#define PB_GEN_SUBMSG_INFO(structname, atype, htype, ltype, fieldname, tag) \
700 PB_SUBMSG_INFO_ ## htype(_PB_LTYPE_ ## ltype, structname, fieldname)
702#define PB_SUBMSG_INFO_REQUIRED(ltype, structname, fieldname) PB_SI ## ltype(structname ## _ ## fieldname ## _MSGTYPE)
703#define PB_SUBMSG_INFO_SINGULAR(ltype, structname, fieldname) PB_SI ## ltype(structname ## _ ## fieldname ## _MSGTYPE)
704#define PB_SUBMSG_INFO_OPTIONAL(ltype, structname, fieldname) PB_SI ## ltype(structname ## _ ## fieldname ## _MSGTYPE)
705#define PB_SUBMSG_INFO_ONEOF(ltype, structname, fieldname) PB_SUBMSG_INFO_ONEOF2(ltype, structname, PB_ONEOF_NAME(UNION, fieldname), PB_ONEOF_NAME(MEMBER, fieldname))
706#define PB_SUBMSG_INFO_ONEOF2(ltype, structname, unionname, membername) PB_SUBMSG_INFO_ONEOF3(ltype, structname, unionname, membername)
707#define PB_SUBMSG_INFO_ONEOF3(ltype, structname, unionname, membername) PB_SI ## ltype(structname ## _ ## unionname ## _ ## membername ## _MSGTYPE)
708#define PB_SUBMSG_INFO_REPEATED(ltype, structname, fieldname) PB_SI ## ltype(structname ## _ ## fieldname ## _MSGTYPE)
709#define PB_SUBMSG_INFO_FIXARRAY(ltype, structname, fieldname) PB_SI ## ltype(structname ## _ ## fieldname ## _MSGTYPE)
710#define PB_SI_PB_LTYPE_BOOL(t)
711#define PB_SI_PB_LTYPE_BYTES(t)
712#define PB_SI_PB_LTYPE_DOUBLE(t)
713#define PB_SI_PB_LTYPE_ENUM(t)
714#define PB_SI_PB_LTYPE_UENUM(t)
715#define PB_SI_PB_LTYPE_FIXED32(t)
716#define PB_SI_PB_LTYPE_FIXED64(t)
717#define PB_SI_PB_LTYPE_FLOAT(t)
718#define PB_SI_PB_LTYPE_INT32(t)
719#define PB_SI_PB_LTYPE_INT64(t)
720#define PB_SI_PB_LTYPE_MESSAGE(t) PB_SUBMSG_DESCRIPTOR(t)
721#define PB_SI_PB_LTYPE_MSG_W_CB(t) PB_SUBMSG_DESCRIPTOR(t)
722#define PB_SI_PB_LTYPE_SFIXED32(t)
723#define PB_SI_PB_LTYPE_SFIXED64(t)
724#define PB_SI_PB_LTYPE_SINT32(t)
725#define PB_SI_PB_LTYPE_SINT64(t)
726#define PB_SI_PB_LTYPE_STRING(t)
727#define PB_SI_PB_LTYPE_UINT32(t)
728#define PB_SI_PB_LTYPE_UINT64(t)
729#define PB_SI_PB_LTYPE_EXTENSION(t)
730#define PB_SI_PB_LTYPE_FIXED_LENGTH_BYTES(t)
731#define PB_SUBMSG_DESCRIPTOR(t) &(t ## _msg),
761#define PB_FIELDINFO_1(tag, type, data_offset, data_size, size_offset, array_size) \
762 (0 | (((tag) << 2) & 0xFF) | ((type) << 8) | (((uint32_t)(data_offset) & 0xFF) << 16) | \
763 (((uint32_t)(size_offset) & 0x0F) << 24) | (((uint32_t)(data_size) & 0x0F) << 28)),
765#define PB_FIELDINFO_2(tag, type, data_offset, data_size, size_offset, array_size) \
766 (1 | (((tag) << 2) & 0xFF) | ((type) << 8) | (((uint32_t)(array_size) & 0xFFF) << 16) | (((uint32_t)(size_offset) & 0x0F) << 28)), \
767 (((uint32_t)(data_offset) & 0xFFFF) | (((uint32_t)(data_size) & 0xFFF) << 16) | (((uint32_t)(tag) & 0x3c0) << 22)),
769#define PB_FIELDINFO_4(tag, type, data_offset, data_size, size_offset, array_size) \
770 (2 | (((tag) << 2) & 0xFF) | ((type) << 8) | (((uint32_t)(array_size) & 0xFFFF) << 16)), \
771 ((uint32_t)(int_least8_t)(size_offset) | (((uint32_t)(tag) << 2) & 0xFFFFFF00)), \
772 (data_offset), (data_size),
774#define PB_FIELDINFO_8(tag, type, data_offset, data_size, size_offset, array_size) \
775 (3 | (((tag) << 2) & 0xFF) | ((type) << 8)), \
776 ((uint32_t)(int_least8_t)(size_offset) | (((uint32_t)(tag) << 2) & 0xFFFFFF00)), \
777 (data_offset), (data_size), (array_size), 0, 0, 0,
786#define PB_FITS(value,bits) ((uint32_t)(value) < ((uint32_t)1<<bits))
787#define PB_FIELDINFO_ASSERT_1(tag, type, data_offset, data_size, size_offset, array_size) \
788 PB_STATIC_ASSERT(PB_FITS(tag,6) && PB_FITS(data_offset,8) && PB_FITS(size_offset,4) && PB_FITS(data_size,4) && PB_FITS(array_size,1), FIELDINFO_DOES_NOT_FIT_width1_field ## tag)
790#define PB_FIELDINFO_ASSERT_2(tag, type, data_offset, data_size, size_offset, array_size) \
791 PB_STATIC_ASSERT(PB_FITS(tag,10) && PB_FITS(data_offset,16) && PB_FITS(size_offset,4) && PB_FITS(data_size,12) && PB_FITS(array_size,12), FIELDINFO_DOES_NOT_FIT_width2_field ## tag)
793#ifndef PB_FIELD_32BIT
795#define PB_FIELDINFO_ASSERT_4(tag, type, data_offset, data_size, size_offset, array_size) \
796 PB_STATIC_ASSERT(PB_FITS(tag,16) && PB_FITS(data_offset,16) && PB_FITS((int_least8_t)size_offset,8) && PB_FITS(data_size,16) && PB_FITS(array_size,16), FIELDINFO_DOES_NOT_FIT_width4_field ## tag)
798#define PB_FIELDINFO_ASSERT_8(tag, type, data_offset, data_size, size_offset, array_size) \
799 PB_STATIC_ASSERT(PB_FITS(tag,16) && PB_FITS(data_offset,16) && PB_FITS((int_least8_t)size_offset,8) && PB_FITS(data_size,16) && PB_FITS(array_size,16), FIELDINFO_DOES_NOT_FIT_width8_field ## tag)
805#define PB_FIELDINFO_ASSERT_4(tag, type, data_offset, data_size, size_offset, array_size) \
806 PB_STATIC_ASSERT(PB_FITS(tag,30) && PB_FITS(data_offset,31) && PB_FITS(size_offset,8) && PB_FITS(data_size,31) && PB_FITS(array_size,16), FIELDINFO_DOES_NOT_FIT_width4_field ## tag)
808#define PB_FIELDINFO_ASSERT_8(tag, type, data_offset, data_size, size_offset, array_size) \
809 PB_STATIC_ASSERT(PB_FITS(tag,30) && PB_FITS(data_offset,31) && PB_FITS(size_offset,8) && PB_FITS(data_size,31) && PB_FITS(array_size,31), FIELDINFO_DOES_NOT_FIT_width8_field ## tag)
819#define PB_FIELDINFO_WIDTH_AUTO(atype, htype, ltype) PB_FI_WIDTH ## atype(htype, ltype)
820#define PB_FI_WIDTH_PB_ATYPE_STATIC(htype, ltype) PB_FI_WIDTH ## htype(ltype)
821#define PB_FI_WIDTH_PB_ATYPE_POINTER(htype, ltype) PB_FI_WIDTH ## htype(ltype)
822#define PB_FI_WIDTH_PB_ATYPE_CALLBACK(htype, ltype) 2
823#define PB_FI_WIDTH_PB_HTYPE_REQUIRED(ltype) PB_FI_WIDTH ## ltype
824#define PB_FI_WIDTH_PB_HTYPE_SINGULAR(ltype) PB_FI_WIDTH ## ltype
825#define PB_FI_WIDTH_PB_HTYPE_OPTIONAL(ltype) PB_FI_WIDTH ## ltype
826#define PB_FI_WIDTH_PB_HTYPE_ONEOF(ltype) PB_FI_WIDTH ## ltype
827#define PB_FI_WIDTH_PB_HTYPE_REPEATED(ltype) 2
828#define PB_FI_WIDTH_PB_HTYPE_FIXARRAY(ltype) 2
829#define PB_FI_WIDTH_PB_LTYPE_BOOL 1
830#define PB_FI_WIDTH_PB_LTYPE_BYTES 2
831#define PB_FI_WIDTH_PB_LTYPE_DOUBLE 1
832#define PB_FI_WIDTH_PB_LTYPE_ENUM 1
833#define PB_FI_WIDTH_PB_LTYPE_UENUM 1
834#define PB_FI_WIDTH_PB_LTYPE_FIXED32 1
835#define PB_FI_WIDTH_PB_LTYPE_FIXED64 1
836#define PB_FI_WIDTH_PB_LTYPE_FLOAT 1
837#define PB_FI_WIDTH_PB_LTYPE_INT32 1
838#define PB_FI_WIDTH_PB_LTYPE_INT64 1
839#define PB_FI_WIDTH_PB_LTYPE_MESSAGE 2
840#define PB_FI_WIDTH_PB_LTYPE_MSG_W_CB 2
841#define PB_FI_WIDTH_PB_LTYPE_SFIXED32 1
842#define PB_FI_WIDTH_PB_LTYPE_SFIXED64 1
843#define PB_FI_WIDTH_PB_LTYPE_SINT32 1
844#define PB_FI_WIDTH_PB_LTYPE_SINT64 1
845#define PB_FI_WIDTH_PB_LTYPE_STRING 2
846#define PB_FI_WIDTH_PB_LTYPE_UINT32 1
847#define PB_FI_WIDTH_PB_LTYPE_UINT64 1
848#define PB_FI_WIDTH_PB_LTYPE_EXTENSION 1
849#define PB_FI_WIDTH_PB_LTYPE_FIXED_LENGTH_BYTES 2
852#define PB_LTYPE_MAP_BOOL PB_LTYPE_BOOL
853#define PB_LTYPE_MAP_BYTES PB_LTYPE_BYTES
854#define PB_LTYPE_MAP_DOUBLE PB_LTYPE_FIXED64
855#define PB_LTYPE_MAP_ENUM PB_LTYPE_VARINT
856#define PB_LTYPE_MAP_UENUM PB_LTYPE_UVARINT
857#define PB_LTYPE_MAP_FIXED32 PB_LTYPE_FIXED32
858#define PB_LTYPE_MAP_FIXED64 PB_LTYPE_FIXED64
859#define PB_LTYPE_MAP_FLOAT PB_LTYPE_FIXED32
860#define PB_LTYPE_MAP_INT32 PB_LTYPE_VARINT
861#define PB_LTYPE_MAP_INT64 PB_LTYPE_VARINT
862#define PB_LTYPE_MAP_MESSAGE PB_LTYPE_SUBMESSAGE
863#define PB_LTYPE_MAP_MSG_W_CB PB_LTYPE_SUBMSG_W_CB
864#define PB_LTYPE_MAP_SFIXED32 PB_LTYPE_FIXED32
865#define PB_LTYPE_MAP_SFIXED64 PB_LTYPE_FIXED64
866#define PB_LTYPE_MAP_SINT32 PB_LTYPE_SVARINT
867#define PB_LTYPE_MAP_SINT64 PB_LTYPE_SVARINT
868#define PB_LTYPE_MAP_STRING PB_LTYPE_STRING
869#define PB_LTYPE_MAP_UINT32 PB_LTYPE_UVARINT
870#define PB_LTYPE_MAP_UINT64 PB_LTYPE_UVARINT
871#define PB_LTYPE_MAP_EXTENSION PB_LTYPE_EXTENSION
872#define PB_LTYPE_MAP_FIXED_LENGTH_BYTES PB_LTYPE_FIXED_LENGTH_BYTES
887#define PB_SET_ERROR(stream, msg) PB_UNUSED(stream)
888#define PB_GET_ERROR(stream) "(errmsg disabled)"
890#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
891#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
894#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
901#if __cplusplus >= 201103L
902#define PB_CONSTEXPR constexpr
907#if __cplusplus >= 201703L
908#define PB_INLINE_CONSTEXPR inline constexpr
910#define PB_INLINE_CONSTEXPR PB_CONSTEXPR
917template <
typename GenMessageT>
struct MessageDescriptor;
#define PB_STATIC_ASSERT(COND, MSG)
bool pb_default_field_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_t *field)
pb_field_iter_t pb_field_t
unsigned long long uint64_t
bool(* encode)(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
union pb_callback_s::@29 funcs
bool(* decode)(pb_istream_t *stream, const pb_field_t *field, void **arg)
const pb_extension_type_t * type
bool(* encode)(pb_ostream_t *stream, const pb_extension_t *extension)
bool(* decode)(pb_istream_t *stream, pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type)
const pb_msgdesc_t * descriptor
pb_size_t submessage_index
const pb_msgdesc_t * submsg_desc
pb_size_t required_field_index
pb_size_t field_info_index
const uint32_t * field_info
const pb_msgdesc_t *const * submsg_info
const pb_byte_t * default_value
bool(* field_callback)(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_iter_t *field)
pb_size_t required_field_count