diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 25 | ||||
-rw-r--r-- | include/qpdf/QPDFTokenizer.hh | 10 |
2 files changed, 34 insertions, 1 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 932a6678..c4a922d1 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -71,6 +71,21 @@ class QPDFObjectHandle virtual void decryptString(std::string& val) = 0; }; + // This class is used by parseContentStream. Callers must + // instantiate a subclass of this with handlers defined to accept + // QPDFObjectHandles that are parsed from the stream. + class ParserCallbacks + { + public: + QPDF_DLL + virtual ~ParserCallbacks() + { + } + virtual void handleObject(QPDFObjectHandle) = 0; + virtual void handleEOF() = 0; + }; + + QPDF_DLL QPDFObjectHandle(); QPDF_DLL @@ -138,6 +153,11 @@ class QPDFObjectHandle StringDecrypter* decrypter, QPDF* context); + // Helpers for parsing content streams + QPDF_DLL + static void parseContentStream(QPDFObjectHandle stream_or_array, + ParserCallbacks* callbacks); + // Type-specific factories QPDF_DLL static QPDFObjectHandle newNull(); @@ -571,7 +591,10 @@ class QPDFObjectHandle std::string const& object_description, QPDFTokenizer& tokenizer, bool& empty, StringDecrypter* decrypter, QPDF* context, - bool in_array, bool in_dictionary); + bool in_array, bool in_dictionary, + bool content_stream); + static void parseContentStream_internal( + QPDFObjectHandle stream, ParserCallbacks* callbacks); bool initialized; diff --git a/include/qpdf/QPDFTokenizer.hh b/include/qpdf/QPDFTokenizer.hh index 1835fcb1..081e12d3 100644 --- a/include/qpdf/QPDFTokenizer.hh +++ b/include/qpdf/QPDFTokenizer.hh @@ -18,6 +18,8 @@ class QPDFTokenizer { public: + // Token type tt_eof is only returned of allowEOF() is called on + // the tokenizer. tt_eof was introduced in QPDF version 4.1. enum token_type_e { tt_bad, @@ -34,6 +36,7 @@ class QPDFTokenizer tt_null, tt_bool, tt_word, + tt_eof, }; class Token @@ -97,6 +100,12 @@ class QPDFTokenizer QPDF_DLL void allowPoundAnywhereInName(); + // If called, treat EOF as a separate token type instead of an + // error. This was introduced in QPDF 4.1 to facilitate + // tokenizing content streams. + QPDF_DLL + void allowEOF(); + // Mode of operation: // Keep presenting characters and calling getToken() until @@ -140,6 +149,7 @@ class QPDFTokenizer st_literal, st_in_hexstring, st_token_ready } state; bool pound_special_in_name; + bool allow_eof; // Current token accumulation token_type_e type; |