diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-05-15 18:34:27 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-05-16 19:41:40 +0200 |
commit | 7fa5d1773b599df51df21658dff53f5b66fdbba8 (patch) | |
tree | 1cd7a6fc7b9efa3b1b0fb436f0e5b05c23a1f03c /include | |
parent | 8d42eb2632ca5c2ae1200160e78116505b57f6b0 (diff) | |
download | qpdf-7fa5d1773b599df51df21658dff53f5b66fdbba8.tar.zst |
Implement top-level qpdf json parsing
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDF.hh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 61efa4ed..2e24b261 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -998,6 +998,7 @@ class QPDF class JSONReactor: public JSON::Reactor { public: + JSONReactor(QPDF&, bool must_be_complete); virtual ~JSONReactor() = default; virtual void dictionaryStart() override; virtual void arrayStart() override; @@ -1006,6 +1007,32 @@ class QPDF virtual bool dictionaryItem(std::string const& key, JSON const& value) override; virtual bool arrayItem(JSON const& value) override; + + private: + enum state_e { + st_initial, + st_top, + st_ignore, + st_qpdf, + st_objects_top, + st_trailer_top, + st_object_top, + st_stream, + st_object, + }; + + void containerStart(); + void nestedState(std::string const& key, JSON const& value, state_e); + + QPDF& pdf; + bool must_be_complete; + bool saw_qpdf; + bool saw_json_version; + bool saw_pdf_version; + bool saw_trailer; + state_e state; + state_e next_state; + std::vector<state_e> state_stack; }; friend class JSONReactor; |