diff options
author | m-holger <m-holger@kubitscheck.org> | 2024-02-09 14:09:08 +0100 |
---|---|---|
committer | m-holger <m-holger@kubitscheck.org> | 2024-02-16 11:51:25 +0100 |
commit | e2737ab646bff6aa07ba72e0cc15cc955d9afcc0 (patch) | |
tree | 0ff6b1adb00694477e23e278055d61474d6b844a /libqpdf/qpdf | |
parent | 9e90007a4a490dd1335b63079fc3e2a74420911f (diff) | |
download | qpdf-e2737ab646bff6aa07ba72e0cc15cc955d9afcc0.tar.zst |
Add new writeJSON methods
Create an alternative to getJSON to allow an object handle to be written as JSON without the overhead of creating a JSON object.
Diffstat (limited to 'libqpdf/qpdf')
-rw-r--r-- | libqpdf/qpdf/QPDFObject_private.hh | 5 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDFValue.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Array.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Bool.hh | 2 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Destroyed.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Dictionary.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_InlineImage.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Integer.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Name.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Null.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Operator.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Real.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Reserved.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Stream.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_String.hh | 1 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Unresolved.hh | 1 |
16 files changed, 21 insertions, 0 deletions
diff --git a/libqpdf/qpdf/QPDFObject_private.hh b/libqpdf/qpdf/QPDFObject_private.hh index 5e87c215..b873bcd0 100644 --- a/libqpdf/qpdf/QPDFObject_private.hh +++ b/libqpdf/qpdf/QPDFObject_private.hh @@ -38,6 +38,11 @@ class QPDFObject { return value->getJSON(json_version); } + void + writeJSON(int json_version, JSON::Writer& p) + { + return value->writeJSON(json_version, p); + } std::string getStringValue() const { diff --git a/libqpdf/qpdf/QPDFValue.hh b/libqpdf/qpdf/QPDFValue.hh index db8fb923..f7783466 100644 --- a/libqpdf/qpdf/QPDFValue.hh +++ b/libqpdf/qpdf/QPDFValue.hh @@ -25,6 +25,7 @@ class QPDFValue: public std::enable_shared_from_this<QPDFValue> virtual std::shared_ptr<QPDFObject> copy(bool shallow = false) = 0; virtual std::string unparse() = 0; virtual JSON getJSON(int json_version) = 0; + virtual void writeJSON(int json_version, JSON::Writer& p) = 0; struct JSON_Descr { diff --git a/libqpdf/qpdf/QPDF_Array.hh b/libqpdf/qpdf/QPDF_Array.hh index 281e1d48..7ee69b8e 100644 --- a/libqpdf/qpdf/QPDF_Array.hh +++ b/libqpdf/qpdf/QPDF_Array.hh @@ -23,6 +23,7 @@ class QPDF_Array: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; void disconnect() override; int diff --git a/libqpdf/qpdf/QPDF_Bool.hh b/libqpdf/qpdf/QPDF_Bool.hh index 0b4a71fd..f4ce0b1c 100644 --- a/libqpdf/qpdf/QPDF_Bool.hh +++ b/libqpdf/qpdf/QPDF_Bool.hh @@ -11,6 +11,8 @@ class QPDF_Bool: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; + bool getVal() const; private: diff --git a/libqpdf/qpdf/QPDF_Destroyed.hh b/libqpdf/qpdf/QPDF_Destroyed.hh index 72e9130a..400921e3 100644 --- a/libqpdf/qpdf/QPDF_Destroyed.hh +++ b/libqpdf/qpdf/QPDF_Destroyed.hh @@ -10,6 +10,7 @@ class QPDF_Destroyed: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; static std::shared_ptr<QPDFValue> getInstance(); private: diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh index 0fb6636e..32c926a3 100644 --- a/libqpdf/qpdf/QPDF_Dictionary.hh +++ b/libqpdf/qpdf/QPDF_Dictionary.hh @@ -17,6 +17,7 @@ class QPDF_Dictionary: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; void disconnect() override; // hasKey() and getKeys() treat keys with null values as if they aren't there. getKey() returns diff --git a/libqpdf/qpdf/QPDF_InlineImage.hh b/libqpdf/qpdf/QPDF_InlineImage.hh index bee12354..cc4dc31a 100644 --- a/libqpdf/qpdf/QPDF_InlineImage.hh +++ b/libqpdf/qpdf/QPDF_InlineImage.hh @@ -11,6 +11,7 @@ class QPDF_InlineImage: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; std::string getStringValue() const override { diff --git a/libqpdf/qpdf/QPDF_Integer.hh b/libqpdf/qpdf/QPDF_Integer.hh index 2c2cf2f9..dd2f9e0d 100644 --- a/libqpdf/qpdf/QPDF_Integer.hh +++ b/libqpdf/qpdf/QPDF_Integer.hh @@ -11,6 +11,7 @@ class QPDF_Integer: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; long long getVal() const; private: diff --git a/libqpdf/qpdf/QPDF_Name.hh b/libqpdf/qpdf/QPDF_Name.hh index c14d8659..167ddef5 100644 --- a/libqpdf/qpdf/QPDF_Name.hh +++ b/libqpdf/qpdf/QPDF_Name.hh @@ -11,6 +11,7 @@ class QPDF_Name: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; // Put # into strings with characters unsuitable for name token static std::string normalizeName(std::string const& name); diff --git a/libqpdf/qpdf/QPDF_Null.hh b/libqpdf/qpdf/QPDF_Null.hh index a59b7509..2a099bf9 100644 --- a/libqpdf/qpdf/QPDF_Null.hh +++ b/libqpdf/qpdf/QPDF_Null.hh @@ -19,6 +19,7 @@ class QPDF_Null: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; private: QPDF_Null(); diff --git a/libqpdf/qpdf/QPDF_Operator.hh b/libqpdf/qpdf/QPDF_Operator.hh index 77aa5a17..d8b99e17 100644 --- a/libqpdf/qpdf/QPDF_Operator.hh +++ b/libqpdf/qpdf/QPDF_Operator.hh @@ -11,6 +11,7 @@ class QPDF_Operator: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; std::string getStringValue() const override { diff --git a/libqpdf/qpdf/QPDF_Real.hh b/libqpdf/qpdf/QPDF_Real.hh index db5e0940..5fec919d 100644 --- a/libqpdf/qpdf/QPDF_Real.hh +++ b/libqpdf/qpdf/QPDF_Real.hh @@ -13,6 +13,7 @@ class QPDF_Real: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; std::string getStringValue() const override { diff --git a/libqpdf/qpdf/QPDF_Reserved.hh b/libqpdf/qpdf/QPDF_Reserved.hh index 9ba855b7..4503fb9e 100644 --- a/libqpdf/qpdf/QPDF_Reserved.hh +++ b/libqpdf/qpdf/QPDF_Reserved.hh @@ -11,6 +11,7 @@ class QPDF_Reserved: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; private: QPDF_Reserved(); diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh index 8488e157..597a48a8 100644 --- a/libqpdf/qpdf/QPDF_Stream.hh +++ b/libqpdf/qpdf/QPDF_Stream.hh @@ -26,6 +26,7 @@ class QPDF_Stream: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; void setDescription( QPDF*, std::shared_ptr<QPDFValue::Description>& description, qpdf_offset_t offset) override; void disconnect() override; diff --git a/libqpdf/qpdf/QPDF_String.hh b/libqpdf/qpdf/QPDF_String.hh index c34cafef..e7a87a53 100644 --- a/libqpdf/qpdf/QPDF_String.hh +++ b/libqpdf/qpdf/QPDF_String.hh @@ -17,6 +17,7 @@ class QPDF_String: public QPDFValue std::string unparse() override; std::string unparse(bool force_binary); JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; std::string getUTF8Val() const; std::string getStringValue() const override diff --git a/libqpdf/qpdf/QPDF_Unresolved.hh b/libqpdf/qpdf/QPDF_Unresolved.hh index 0a1fa9a5..669e314e 100644 --- a/libqpdf/qpdf/QPDF_Unresolved.hh +++ b/libqpdf/qpdf/QPDF_Unresolved.hh @@ -11,6 +11,7 @@ class QPDF_Unresolved: public QPDFValue std::shared_ptr<QPDFObject> copy(bool shallow = false) override; std::string unparse() override; JSON getJSON(int json_version) override; + void writeJSON(int json_version, JSON::Writer& p) override; private: QPDF_Unresolved(QPDF* qpdf, QPDFObjGen const& og); |