2023-02-25 19:18:13 +00:00
|
|
|
// Copyright (c) 2005-2023 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>
|
|
|
|
|
|
|
|
#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>
|
2019-01-30 19:20:56 +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
|
2018-02-02 23:21:34 +00:00
|
|
|
Pl_QPDFTokenizer(
|
2018-02-16 01:45:19 +00:00
|
|
|
char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2023-06-01 14:21:32 +00:00
|
|
|
~Pl_QPDFTokenizer() override;
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2023-06-01 14:21:32 +00:00
|
|
|
void write(unsigned char const* buf, size_t len) override;
|
2018-08-05 00:08:06 +00:00
|
|
|
QPDF_DLL
|
2023-06-01 14:21:32 +00:00
|
|
|
void finish() override;
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
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
|