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/QPDFObjectHandle.cc | |
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/QPDFObjectHandle.cc')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index d543f98e..7af83a68 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -3,6 +3,7 @@ #include <qpdf/BufferInputSource.hh> #include <qpdf/Pl_Buffer.hh> #include <qpdf/Pl_QPDFTokenizer.hh> +#include <qpdf/JSON_writer.hh> #include <qpdf/QPDF.hh> #include <qpdf/QPDFExc.hh> #include <qpdf/QPDFLogger.hh> @@ -1621,6 +1622,18 @@ QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect) } } +void +QPDFObjectHandle::writeJSON(int json_version, JSON::Writer& p, bool dereference_indirect) +{ + if (!dereference_indirect && isIndirect()) { + p << "\"" << getObjGen().unparse(' ') << " R\""; + } else if (!dereference()) { + throw std::logic_error("attempted to dereference an uninitialized QPDFObjectHandle"); + } else { + obj->writeJSON(json_version, p); + } +} + JSON QPDFObjectHandle::getStreamJSON( int json_version, |