wxPdfDocument  1.4.0
Library for generating PDF documents from wxWidgets applications
Loading...
Searching...
No Matches
wxPdfTokenizer Class Reference

Class representing a tokenizer for parsing PDF documents. More...

#include <pdfparser.h>

Public Member Functions

 wxPdfTokenizer (wxInputStream *inputStream)
 Constructor.
virtual ~wxPdfTokenizer ()
 Destructor.
off_t Seek (off_t pos)
 Set current offset position in stream.
off_t Tell ()
 Get current offset position in stream.
void BackOnePosition (int ch)
 Go back one position in the stream.
off_t GetLength ()
 Get length of stream.
int ReadChar ()
 Read one byte from stream.
wxMemoryOutputStream * ReadBuffer (size_t size)
 Read size bytes from stream.
off_t GetStartXRef ()
 Find the offset of the startxref tag.
wxString ReadString (int size)
 Read a string.
wxString CheckPdfHeader ()
 Check the header of the document stream.
bool NextToken ()
 Get the next token.
void NextValidToken ()
 Get the next valid token.
int GetTokenType () const
 Get the type of the last token.
wxString GetStringValue () const
 Get the token value as a string.
int GetIntValue () const
 Get the token value as an integer.
bool IsHexString () const
 Check whether the token is a hexadecimal string.
int GetReference () const
 Get object reference.
int GetGeneration () const
 Get object generation.

Static Public Member Functions

static bool IsWhitespace (int ch)
 Check byte whether it represents a white space character.
static bool IsDelimiter (int ch)
 Check byte whether it is a delimiter.
static bool IsDelimiterOrWhitespace (int ch)
 Check byte whether it is a delimiter or a whitespace character.
static int GetHex (int v)
 Get hexadecimal character.

Detailed Description

Class representing a tokenizer for parsing PDF documents.

The tokenizer reads a PDF stream and breaks it into tokens like strings, names, numbers, etc. It also handles identifying the XRef (Cross-Reference) table, which contains the byte offsets of all indirect objects in the PDF file.

Constructor & Destructor Documentation

◆ wxPdfTokenizer()

wxPdfTokenizer::wxPdfTokenizer ( wxInputStream * inputStream)

Constructor.

Parameters
inputStreamThe stream to tokenize

◆ ~wxPdfTokenizer()

virtual wxPdfTokenizer::~wxPdfTokenizer ( )
virtual

Destructor.

Member Function Documentation

◆ BackOnePosition()

void wxPdfTokenizer::BackOnePosition ( int ch)

Go back one position in the stream.

Parameters
chThe character to put back

◆ CheckPdfHeader()

wxString wxPdfTokenizer::CheckPdfHeader ( )

Check the header of the document stream.

Returns
The PDF version string (e.g., "%PDF-1.4")

◆ GetGeneration()

int wxPdfTokenizer::GetGeneration ( ) const

Get object generation.

Returns
The object generation number

◆ GetHex()

int wxPdfTokenizer::GetHex ( int v)
static

Get hexadecimal character.

Parameters
vThe integer value
Returns
The hex character value

◆ GetIntValue()

int wxPdfTokenizer::GetIntValue ( ) const

Get the token value as an integer.

Returns
The integer value of the token

◆ GetLength()

off_t wxPdfTokenizer::GetLength ( )

Get length of stream.

Returns
The total length of the stream

◆ GetReference()

int wxPdfTokenizer::GetReference ( ) const

Get object reference.

Returns
The object reference number

◆ GetStartXRef()

off_t wxPdfTokenizer::GetStartXRef ( )

Find the offset of the startxref tag.

Returns
The byte offset of the cross-reference table

◆ GetStringValue()

wxString wxPdfTokenizer::GetStringValue ( ) const

Get the token value as a string.

Returns
The string value of the token

◆ GetTokenType()

int wxPdfTokenizer::GetTokenType ( ) const

Get the type of the last token.

Returns
The token type (e.g., TOKEN_STRING, TOKEN_NUMBER)

◆ IsDelimiter()

bool wxPdfTokenizer::IsDelimiter ( int ch)
static

Check byte whether it is a delimiter.

Parameters
chThe character to check
Returns
true if it is a delimiter, false otherwise

◆ IsDelimiterOrWhitespace()

bool wxPdfTokenizer::IsDelimiterOrWhitespace ( int ch)
static

Check byte whether it is a delimiter or a whitespace character.

Parameters
chThe character to check
Returns
true if it is a delimiter or whitespace, false otherwise

◆ IsHexString()

bool wxPdfTokenizer::IsHexString ( ) const
inline

Check whether the token is a hexadecimal string.

Returns
true if it is a hex string, false otherwise

◆ IsWhitespace()

bool wxPdfTokenizer::IsWhitespace ( int ch)
static

Check byte whether it represents a white space character.

Parameters
chThe character to check
Returns
true if it is whitespace, false otherwise

◆ NextToken()

bool wxPdfTokenizer::NextToken ( )

Get the next token.

Returns
true if a token was found, false otherwise

◆ NextValidToken()

void wxPdfTokenizer::NextValidToken ( )

Get the next valid token.

Skips comments and whitespace to find the next meaningful token.

◆ ReadBuffer()

wxMemoryOutputStream * wxPdfTokenizer::ReadBuffer ( size_t size)

Read size bytes from stream.

Parameters
sizeThe number of bytes to read
Returns
A memory stream containing the read bytes

◆ ReadChar()

int wxPdfTokenizer::ReadChar ( )

Read one byte from stream.

Returns
The character read, or EOF

◆ ReadString()

wxString wxPdfTokenizer::ReadString ( int size)

Read a string.

Parameters
sizeThe number of characters to read
Returns
The string read from the stream

◆ Seek()

off_t wxPdfTokenizer::Seek ( off_t pos)

Set current offset position in stream.

Parameters
posThe offset to seek to
Returns
The new offset position

◆ Tell()

off_t wxPdfTokenizer::Tell ( )

Get current offset position in stream.

Returns
The current offset position

The documentation for this class was generated from the following file: