diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDF.hh | 29 | ||||
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 1 |
2 files changed, 25 insertions, 5 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index b547fcbd..f3ce4684 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -998,7 +998,7 @@ class QPDF class JSONReactor: public JSON::Reactor { public: - JSONReactor(QPDF&, bool must_be_complete); + JSONReactor(QPDF&, std::string const& filename, bool must_be_complete); virtual ~JSONReactor() = default; virtual void dictionaryStart() override; virtual void arrayStart() override; @@ -1008,31 +1008,51 @@ class QPDF dictionaryItem(std::string const& key, JSON const& value) override; virtual bool arrayItem(JSON const& value) override; + bool anyErrors() const; + private: enum state_e { st_initial, st_top, - st_ignore, st_qpdf, - st_objects_top, - st_trailer_top, + st_objects, + st_trailer, st_object_top, st_stream, st_object, + st_ignore, }; void containerStart(); void nestedState(std::string const& key, JSON const& value, state_e); + QPDFObjectHandle makeObject(JSON const& value); + void error(size_t offset, std::string const& message); + QPDFObjectHandle + reserveObject(std::string const& obj, std::string const& gen); + void replaceObject( + QPDFObjectHandle to_replace, QPDFObjectHandle replacement); QPDF& pdf; + std::string filename; bool must_be_complete; + bool errors; + bool parse_error; bool saw_qpdf; + bool saw_objects; bool saw_json_version; bool saw_pdf_version; bool saw_trailer; state_e state; state_e next_state; + std::string cur_object; + bool saw_value; + bool saw_stream; + bool saw_dict; + bool saw_data; + bool saw_datafile; std::vector<state_e> state_stack; + std::vector<QPDFObjectHandle> object_stack; + std::set<QPDFObjGen> reserved; }; friend class JSONReactor; @@ -1080,6 +1100,7 @@ class QPDF void resolveObjectsInStream(int obj_stream_number); void stopOnError(std::string const& message); QPDFObjectHandle reserveObjectIfNotExists(int objid, int gen); + QPDFObjectHandle reserveStream(int objid, int gen); // Calls finish() on the pipeline when done but does not delete it bool pipeStreamData( diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index ec4a9699..5bdafb31 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -1431,7 +1431,6 @@ class QPDFObjectHandle { return QPDFObjectHandle::newIndirect(qpdf, objid, generation); } - // object must be dictionary object static QPDFObjectHandle newStream( QPDF* qpdf, |