diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2015-02-02 13:54:24 -0800 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2015-02-02 13:54:24 -0800 |
commit | 17be1ef0f246aa7add98c04efce3e0b992abccc4 (patch) | |
tree | 5ea54a02a338f2123503f840280a6e037cd65954 /upb/json/parser.h | |
parent | 51513c6e7f9df3f04fde0ff94bfe654f8dccaaa0 (diff) | |
parent | fb585045692c482b6946fff63f0cd8425c8c70b5 (diff) |
Merge pull request #12 from cfallin/json-maps
Support maps in JSON parsing and serialization.
Diffstat (limited to 'upb/json/parser.h')
-rw-r--r-- | upb/json/parser.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/upb/json/parser.h b/upb/json/parser.h index 51578f2..c693edf 100644 --- a/upb/json/parser.h +++ b/upb/json/parser.h @@ -23,12 +23,30 @@ class Parser; UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser); -// Internal-only struct used by the parser. +// Internal-only struct used by the parser. A parser frame corresponds +// one-to-one with a handler (sink) frame. typedef struct { UPB_PRIVATE_FOR_CPP upb_sink sink; + // The current message in which we're parsing, and the field whose value we're + // expecting next. const upb_msgdef *m; const upb_fielddef *f; + + // We are in a repeated-field context, ready to emit mapentries as + // submessages. This flag alters the start-of-object (open-brace) behavior to + // begin a sequence of mapentry messages rather than a single submessage. + bool is_map; + // We are in a map-entry message context. This flag is set when parsing the + // value field of a single map entry and indicates to all value-field parsers + // (subobjects, strings, numbers, and bools) that the map-entry submessage + // should end as soon as the value is parsed. + bool is_mapentry; + // If |is_map| or |is_mapentry| is true, |mapfield| refers to the parent + // message's map field that we're currently parsing. This differs from |f| + // because |f| is the field in the *current* message (i.e., the map-entry + // message itself), not the parent's field that leads to this map. + const upb_fielddef *mapfield; } upb_jsonparser_frame; |