aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-15 23:38:06 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-20 15:16:25 +0200
commit7e7a9c437982b7ede2af9cd0b12b3e47b4bc3a3d (patch)
tree4ca147f0e85e0e9f7acb833a08d1fe237890327c /include
parentbe0ed6ab5ed92d2018ac4b3274f21e24f30c0626 (diff)
downloadqpdf-7e7a9c437982b7ede2af9cd0b12b3e47b4bc3a3d.tar.zst
Parse objects; stream data is not yet handled
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDF.hh29
-rw-r--r--include/qpdf/QPDFObjectHandle.hh1
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,