2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-05 08:02:11 +00:00
qpdf/libqpdf/qpdf/Pl_QPDFTokenizer.hh
Jay Berkenbilt 5d4cad9c02 ABI change: fix use of off_t, size_t, and integer types
Significantly improve the code's use of off_t for file offsets, size_t
for memory sizes, and integer types in cases where there has to be
compatibility with external interfaces.  Rework sections of the code
that would have prevented qpdf from working on files larger than 2 (or
maybe 4) GB in size.
2012-06-20 15:20:26 -04:00

42 lines
1.1 KiB
C++

#ifndef __PL_QPDFTOKENIZER_HH__
#define __PL_QPDFTOKENIZER_HH__
#include <qpdf/Pipeline.hh>
#include <qpdf/QPDFTokenizer.hh>
//
// Treat incoming text as a stream consisting of valid PDF tokens, but
// output bad tokens just the same. The idea here is to be able to
// use pipeline for content streams to normalize newlines without
// interfering with meaningful newlines such as those that occur
// inside of strings.
//
class Pl_QPDFTokenizer: public Pipeline
{
public:
Pl_QPDFTokenizer(char const* identifier, Pipeline* next);
virtual ~Pl_QPDFTokenizer();
virtual void write(unsigned char* buf, size_t len);
virtual void finish();
private:
void processChar(char ch);
void checkUnread();
void writeNext(char const*, size_t len);
void writeToken(QPDFTokenizer::Token&);
QPDFTokenizer tokenizer;
bool newline_after_next_token;
bool just_wrote_nl;
bool last_char_was_cr;
bool unread_char;
char char_to_unread;
bool in_inline_image;
static int const IMAGE_BUF_SIZE = 4; // must be >= 4
char image_buf[IMAGE_BUF_SIZE];
};
#endif // __PL_QPDFTOKENIZER_HH__