2022-02-04 21:36:22 +00:00
|
|
|
// Copyright (c) 2005-2022 Jay Berkenbilt
|
2018-02-16 01:25:49 +00:00
|
|
|
//
|
|
|
|
// This file is part of qpdf.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
// Versions of qpdf prior to version 7 were released under the terms
|
|
|
|
// of version 2.0 of the Artistic License. At your option, you may
|
|
|
|
// continue to consider qpdf to be licensed under those terms. Please
|
|
|
|
// see the manual for additional information.
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#ifndef PL_QPDFTOKENIZER_HH
|
|
|
|
#define PL_QPDFTOKENIZER_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
#include <qpdf/Pipeline.hh>
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
#include <qpdf/Pl_Buffer.hh>
|
2022-09-23 19:15:39 +00:00
|
|
|
#include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785)
|
2018-02-02 23:21:34 +00:00
|
|
|
#include <qpdf/QPDFObjectHandle.hh>
|
2022-04-02 21:14:10 +00:00
|
|
|
#include <qpdf/QPDFTokenizer.hh>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2022-02-06 16:40:24 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-02-11 20:39:13 +00:00
|
|
|
// Tokenize the incoming text using QPDFTokenizer and pass the tokens
|
|
|
|
// in turn to a QPDFObjectHandle::TokenFilter object. All bytes of
|
|
|
|
// incoming content will be included in exactly one token and passed
|
|
|
|
// downstream.
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2018-02-16 01:25:49 +00:00
|
|
|
// This is a very low-level interface for working with token filters.
|
|
|
|
// Most code will want to use QPDFObjectHandle::filterPageContents or
|
|
|
|
// QPDFObjectHandle::addTokenFilter. See QPDFObjectHandle.hh for
|
|
|
|
// details.
|
|
|
|
|
2022-04-10 13:29:11 +00:00
|
|
|
class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-02-16 01:45:19 +00:00
|
|
|
// Whatever pipeline is provided as "next" will be set as the
|
|
|
|
// pipeline that the token filter writes to. If next is not
|
|
|
|
// provided, any output written by the filter will be discarded.
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2022-04-02 21:14:10 +00:00
|
|
|
Pl_QPDFTokenizer(
|
|
|
|
char const* identifier,
|
|
|
|
QPDFObjectHandle::TokenFilter* filter,
|
|
|
|
Pipeline* next = 0);
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual ~Pl_QPDFTokenizer();
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2022-05-03 21:43:07 +00:00
|
|
|
virtual void write(unsigned char const* buf, size_t len);
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual void finish();
|
|
|
|
|
|
|
|
private:
|
2022-04-10 13:29:11 +00:00
|
|
|
class QPDF_DLL_PRIVATE Members
|
2018-02-02 23:21:34 +00:00
|
|
|
{
|
|
|
|
friend class Pl_QPDFTokenizer;
|
|
|
|
|
|
|
|
public:
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2022-04-15 23:44:07 +00:00
|
|
|
~Members() = default;
|
2018-02-02 23:21:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Members();
|
2022-04-15 23:44:07 +00:00
|
|
|
Members(Members const&) = delete;
|
2018-02-02 23:21:34 +00:00
|
|
|
|
|
|
|
QPDFObjectHandle::TokenFilter* filter;
|
|
|
|
QPDFTokenizer tokenizer;
|
2019-01-30 19:20:56 +00:00
|
|
|
Pl_Buffer buf;
|
2018-02-02 23:21:34 +00:00
|
|
|
};
|
2022-04-09 18:35:56 +00:00
|
|
|
std::shared_ptr<Members> m;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // PL_QPDFTOKENIZER_HH
|