diff options
author | m-holger <m-holger@kubitscheck.org> | 2023-02-11 18:46:30 +0100 |
---|---|---|
committer | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2023-02-11 21:44:03 +0100 |
commit | d80b63c3c0c43fd6bd9e275c7979ecde57d30264 (patch) | |
tree | 1b88b3399a26b2a5d4e2eed707f22719b9c67ba6 /include | |
parent | 72bf719772117eead2e9a354f6c92cd926d58c72 (diff) | |
download | qpdf-d80b63c3c0c43fd6bd9e275c7979ecde57d30264.tar.zst |
Refactor JSON type checks
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/JSON.hh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh index 64f3792c..28da3f24 100644 --- a/include/qpdf/JSON.hh +++ b/include/qpdf/JSON.hh @@ -339,13 +339,33 @@ class JSON static void writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter); + enum value_type_e { + vt_none, + vt_dictionary, + vt_array, + vt_string, + vt_number, + vt_bool, + vt_null, + vt_blob, + }; + struct JSON_value { + JSON_value(value_type_e type_code) : + type_code(type_code) + { + } virtual ~JSON_value() = default; virtual void write(Pipeline*, size_t depth) const = 0; + const value_type_e type_code{vt_none}; }; struct JSON_dictionary: public JSON_value { + JSON_dictionary() : + JSON_value(vt_dictionary) + { + } virtual ~JSON_dictionary() = default; virtual void write(Pipeline*, size_t depth) const; std::map<std::string, std::shared_ptr<JSON_value>> members; @@ -353,6 +373,10 @@ class JSON }; struct JSON_array: public JSON_value { + JSON_array() : + JSON_value(vt_array) + { + } virtual ~JSON_array() = default; virtual void write(Pipeline*, size_t depth) const; std::vector<std::shared_ptr<JSON_value>> elements; @@ -383,6 +407,10 @@ class JSON }; struct JSON_null: public JSON_value { + JSON_null() : + JSON_value(vt_null) + { + } virtual ~JSON_null() = default; virtual void write(Pipeline*, size_t depth) const; }; |