From 0500d4347a6d31ef05fd860559e380c2e488c194 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 4 May 2022 16:28:12 -0400 Subject: JSON: add blob type that generates base64-encoded binary data --- include/qpdf/JSON.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh index 435c2362..4f4162fc 100644 --- a/include/qpdf/JSON.hh +++ b/include/qpdf/JSON.hh @@ -122,6 +122,13 @@ class JSON QPDF_DLL static JSON makeNull(); + // A blob serializes as a string. The function will be called by + // JSON with a pipeline and should write binary data to the + // pipeline but not call finish(). JSON will call finish() at the + // right time. + QPDF_DLL + static JSON makeBlob(std::function); + QPDF_DLL bool isArray() const; @@ -323,6 +330,13 @@ class JSON virtual ~JSON_null() = default; virtual void write(Pipeline*, size_t depth) const; }; + struct JSON_blob: public JSON_value + { + JSON_blob(std::function fn); + virtual ~JSON_blob() = default; + virtual void write(Pipeline*, size_t depth) const; + std::function fn; + }; JSON(std::shared_ptr); -- cgit v1.2.3-54-g00ecf