summaryrefslogtreecommitdiff
path: root/upb/def.h
diff options
context:
space:
mode:
authorChris Fallin <cfallin@c1f.net>2015-02-02 13:38:05 -0800
committerChris Fallin <cfallin@c1f.net>2015-02-02 13:38:05 -0800
commitfb585045692c482b6946fff63f0cd8425c8c70b5 (patch)
tree5ea54a02a338f2123503f840280a6e037cd65954 /upb/def.h
parent51513c6e7f9df3f04fde0ff94bfe654f8dccaaa0 (diff)
Support maps in JSON parsing and serialization.
This is a sync of our internal developing of JSON parsing and serialization. It implements native understanding of MapEntry submessages, so that map fields with (key, value) pairs are serialized as JSON maps (objects) natively rather than as arrays of objects with 'key' and 'value' fields. The parser also now understands how to emit handler calls corresponding to MapEntry objects when processing a map field. This sync also picks up a bugfix in `table.c` to handle an alloc-failed case.
Diffstat (limited to 'upb/def.h')
-rw-r--r--upb/def.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/upb/def.h b/upb/def.h
index fc342f3..3281076 100644
--- a/upb/def.h
+++ b/upb/def.h
@@ -368,6 +368,7 @@ UPB_DEFINE_DEF(upb::FieldDef, fielddef, FIELD,
bool IsString() const;
bool IsSequence() const;
bool IsPrimitive() const;
+ bool IsMap() const;
// How integers are encoded. Only meaningful for integer types.
// Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes.
@@ -592,6 +593,7 @@ bool upb_fielddef_issubmsg(const upb_fielddef *f);
bool upb_fielddef_isstring(const upb_fielddef *f);
bool upb_fielddef_isseq(const upb_fielddef *f);
bool upb_fielddef_isprimitive(const upb_fielddef *f);
+bool upb_fielddef_ismap(const upb_fielddef *f);
int64_t upb_fielddef_defaultint64(const upb_fielddef *f);
int32_t upb_fielddef_defaultint32(const upb_fielddef *f);
uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f);
@@ -980,6 +982,10 @@ UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m,
void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry);
bool upb_msgdef_mapentry(const upb_msgdef *m);
+// Well-known field tag numbers for map-entry messages.
+#define UPB_MAPENTRY_KEY 1
+#define UPB_MAPENTRY_VALUE 2
+
const upb_oneofdef *upb_msgdef_findoneof(const upb_msgdef *m,
const char *name);
int upb_msgdef_numoneofs(const upb_msgdef *m);
@@ -1479,6 +1485,7 @@ inline bool FieldDef::IsSubMessage() const {
}
inline bool FieldDef::IsString() const { return upb_fielddef_isstring(this); }
inline bool FieldDef::IsSequence() const { return upb_fielddef_isseq(this); }
+inline bool FieldDef::IsMap() const { return upb_fielddef_ismap(this); }
inline int64_t FieldDef::default_int64() const {
return upb_fielddef_defaultint64(this);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback