summaryrefslogtreecommitdiffstats
path: root/pb.h
diff options
context:
space:
mode:
authorBernhard Krämer <bdkrae@gmail.com>2016-10-09 20:26:28 +0200
committerBernhard Krämer <bdkrae@gmail.com>2016-10-09 20:26:28 +0200
commitba97926cfd1e82bd294cf5e484633850d8e0b368 (patch)
tree41aa38edf6cf9b87e318287b6497a01940700551 /pb.h
parent91bb64a47b36b112c9b22391ef76fab29cf2cffc (diff)
Add proto3 option to handle singular fields
Diffstat (limited to 'pb.h')
-rw-r--r--pb.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/pb.h b/pb.h
index 4576f79a..0e1e92d5 100644
--- a/pb.h
+++ b/pb.h
@@ -413,6 +413,10 @@ struct pb_extension_s {
pb_delta(st, has_ ## m, m), \
pb_membersize(st, m), 0, ptr}
+#define PB_SINGULAR_STATIC(tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \
+ fd, 0, pb_membersize(st, m), 0, ptr}
+
/* Repeated fields have a _count field and also the maximum number of entries. */
#define PB_REPEATED_STATIC(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_REPEATED | ltype, \
@@ -444,6 +448,11 @@ struct pb_extension_s {
{tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m[0]), 0, ptr}
+/* Same as optional fields*/
+#define PB_SINGULAR_POINTER(tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \
+ fd, 0, pb_membersize(st, m[0]), 0, ptr}
+
/* Repeated fields have a _count field and a pointer to array of pointers */
#define PB_REPEATED_POINTER(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_REPEATED | ltype, \
@@ -458,6 +467,10 @@ struct pb_extension_s {
#define PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
+
+#define PB_SINGULAR_CALLBACK(tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
+ fd, 0, pb_membersize(st, m), 0, ptr}
#define PB_REPEATED_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_REPEATED | ltype, \