diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-02-16 02:45:19 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-02-19 03:05:47 +0100 |
commit | e410b0fe0d8c1da3e0b0e075b54f247b952389ef (patch) | |
tree | 49020a0201961e9e6e0da9b4ab7fa2a498529759 /libqpdf/QPDFObjectHandle.cc | |
parent | 1fdd86a04924e4ab9543133b74df3322cffbd358 (diff) | |
download | qpdf-e410b0fe0d8c1da3e0b0e075b54f247b952389ef.tar.zst |
Simplify TokenFilter interface
Expose Pl_QPDFTokenizer, and have it do more of the work of managing
the token filter's pipeline.
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 5d7b0bb9..195442ca 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -16,7 +16,6 @@ #include <qpdf/Pl_Buffer.hh> #include <qpdf/Pl_Concatenate.hh> #include <qpdf/Pl_QPDFTokenizer.hh> -#include <qpdf/Pl_Discard.hh> #include <qpdf/BufferInputSource.hh> #include <qpdf/QPDFExc.hh> @@ -65,6 +64,11 @@ CoalesceProvider::provideStreamData(int, int, Pipeline* p) } void +QPDFObjectHandle::TokenFilter::handleEOF() +{ +} + +void QPDFObjectHandle::TokenFilter::setPipeline(Pipeline* p) { this->pipeline = p; @@ -75,8 +79,7 @@ QPDFObjectHandle::TokenFilter::write(char const* data, size_t len) { if (! this->pipeline) { - throw std::logic_error( - "TokenFilter::write called before setPipeline"); + return; } if (len) { @@ -98,17 +101,6 @@ QPDFObjectHandle::TokenFilter::writeToken(QPDFTokenizer::Token const& token) } void -QPDFObjectHandle::TokenFilter::finish() -{ - if (! this->pipeline) - { - throw std::logic_error( - "TokenFilter::finish called before setPipeline"); - } - this->pipeline->finish(); -} - -void QPDFObjectHandle::ParserCallbacks::terminateParsing() { throw TerminateParsing(); @@ -1007,14 +999,7 @@ QPDFObjectHandle::filterPageContents(TokenFilter* filter, Pipeline* next) std::string description = "token filter for page object " + QUtil::int_to_string(this->objid) + " " + QUtil::int_to_string(this->generation); - Pl_QPDFTokenizer token_pipeline(description.c_str(), filter); - PointerHolder<Pipeline> next_p; - if (next == 0) - { - next_p = new Pl_Discard(); - next = next_p.getPointer(); - } - filter->setPipeline(next); + Pl_QPDFTokenizer token_pipeline(description.c_str(), filter, next); this->pipePageContents(&token_pipeline); } |