PoDoFo 0.9.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions

PoDoFo::PdfTokenizer Class Reference

#include <PdfTokenizer.h>

Inheritance diagram for PoDoFo::PdfTokenizer:
PoDoFo::PdfContentsTokenizer PoDoFo::PdfParser PoDoFo::PdfParserObject PoDoFo::PdfXRefStreamParserObject

List of all members.

Public Member Functions

virtual bool GetNextToken (const char *&pszToken, EPdfTokenType *peType=NULL)
bool IsNextToken (const char *pszToken)
pdf_long GetNextNumber ()
void GetNextVariant (PdfVariant &rVariant, PdfEncrypt *pEncrypt)

Static Public Member Functions

static PODOFO_NOTHROW bool IsWhitespace (const unsigned char ch)
static PODOFO_NOTHROW bool IsDelimiter (const unsigned char ch)
static PODOFO_NOTHROW bool IsRegular (const unsigned char ch)
static PODOFO_NOTHROW bool IsPrintable (const unsigned char ch)
static PODOFO_NOTHROW int GetHexValue (const unsigned char ch)

Static Public Attributes

static const unsigned int HEX_NOT_FOUND = std::numeric_limits<unsigned int>::max()

Protected Member Functions

void GetNextVariant (const char *pszToken, EPdfTokenType eType, PdfVariant &rVariant, PdfEncrypt *pEncrypt)
EPdfDataType DetermineDataType (const char *pszToken, EPdfTokenType eType, PdfVariant &rVariant)
void ReadDictionary (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadArray (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadString (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadHexString (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadName (PdfVariant &rVariant)
void QuequeToken (const char *pszToken, EPdfTokenType eType)

Detailed Description

A simple tokenizer for PDF files and PDF content streams


Member Function Documentation

EPdfDataType PoDoFo::PdfTokenizer::DetermineDataType ( const char *  pszToken,
EPdfTokenType  eType,
PdfVariant rVariant 
) [protected]

Determine the possible datatype of a token. Numbers, reals, bools or NULL values are parsed directly by this function and saved to a variant.

Returns:
the expected datatype
int PoDoFo::PdfTokenizer::GetHexValue ( const unsigned char  ch) [inline, static]

Get the hex value from a static map of a given hex character (0-9, A-F, a-f).

Parameters:
chhex character
Returns:
hex value or HEX_NOT_FOUND if invalid
See also:
HEX_NOT_FOUND
pdf_long PoDoFo::PdfTokenizer::GetNextNumber ( )

Read the next number from the current file position ignoring all comments.

Raises NoNumber exception if the next token is no number, and UnexpectedEOF if no token could be read. No token is consumed if NoNumber is thrown.

Returns:
a number read from the input device.
bool PoDoFo::PdfTokenizer::GetNextToken ( const char *&  pszToken,
EPdfTokenType *  peType = NULL 
) [virtual]

Reads the next token from the current file position ignoring all comments.

Parameters:
[out]pszTokenOn true return, set to a pointer to the read token (a NULL-terminated C string). The pointer is to memory owned by PdfTokenizer and must NOT be freed. The contents are invalidated on the next call to GetNextToken(..) and by the destruction of the PdfTokenizer. Undefined on false return.
[out]peTypeOn true return, if not NULL the type of the read token will be stored into this parameter. Undefined on false return.
Returns:
True if a token was read, false if there are no more tokens to read.
See also:
GetBuffer

Reimplemented in PoDoFo::PdfContentsTokenizer.

void PoDoFo::PdfTokenizer::GetNextVariant ( PdfVariant rVariant,
PdfEncrypt pEncrypt 
)

Read the next variant from the current file position ignoring all comments.

Raises an UnexpectedEOF exception if there is no variant left in the file.

Parameters:
rVariantwrite the read variant to this value
pEncryptan encryption object which is used to decrypt strings during parsing
void PoDoFo::PdfTokenizer::GetNextVariant ( const char *  pszToken,
EPdfTokenType  eType,
PdfVariant rVariant,
PdfEncrypt pEncrypt 
) [protected]

Read the next variant from the current file position ignoring all comments.

Raises an exception if there is no variant left in the file.

Parameters:
pszTokena token that has already been read
eTypetype of the passed token
rVariantwrite the read variant to this value
pEncryptan encryption object which is used to decrypt strings during parsing
bool PoDoFo::PdfTokenizer::IsDelimiter ( const unsigned char  ch) [inline, static]

Returns true if the given character is a delimiter according to the pdf reference

Returns:
true if it is a delimiter character otherwise false
bool PoDoFo::PdfTokenizer::IsNextToken ( const char *  pszToken)

Reads the next token from the current file position ignoring all comments and compare the passed token to the read token.

If there is no next token available, throws UnexpectedEOF.

Parameters:
pszTokena token that is compared to the read token
Returns:
true if the read token equals the passed token.
bool PoDoFo::PdfTokenizer::IsPrintable ( const unsigned char  ch) [inline, static]

True if the passed character is within the generally accepted "printable" ASCII range.

bool PoDoFo::PdfTokenizer::IsRegular ( const unsigned char  ch) [inline, static]

True if the passed character is a regular character according to the PDF reference (Section 3.1.1, Character Set); ie it is neither a white-space nor a delimeter character.

bool PoDoFo::PdfTokenizer::IsWhitespace ( const unsigned char  ch) [inline, static]

Returns true if the given character is a whitespace according to the pdf reference

Returns:
true if it is a whitespace character otherwise false
void PoDoFo::PdfTokenizer::QuequeToken ( const char *  pszToken,
EPdfTokenType  eType 
) [protected]

Add a token to the queque of tokens. GetNextToken() will return all quequed tokens first before reading new tokens from the input device.

Parameters:
pszTokenstring of the token
eTypetype of the token
See also:
GetNextToken
void PoDoFo::PdfTokenizer::ReadArray ( PdfVariant rVariant,
PdfEncrypt pEncrypt 
) [protected]

Read an array from the input device and store it into a variant.

Parameters:
rVariantstore the array into this variable
pEncryptan encryption object which is used to decrypt strings during parsing
void PoDoFo::PdfTokenizer::ReadDictionary ( PdfVariant rVariant,
PdfEncrypt pEncrypt 
) [protected]

Read a dictionary from the input device and store it into a variant.

Parameters:
rVariantstore the dictionary into this variable
pEncryptan encryption object which is used to decrypt strings during parsing
void PoDoFo::PdfTokenizer::ReadHexString ( PdfVariant rVariant,
PdfEncrypt pEncrypt 
) [protected]

Read a hex string from the input device and store it into a variant.

Parameters:
rVariantstore the hex string into this variable
pEncryptan encryption object which is used to decrypt strings during parsing
void PoDoFo::PdfTokenizer::ReadName ( PdfVariant rVariant) [protected]

Read a name from the input device and store it into a variant.

Throws UnexpectedEOF if there is nothing to read.

Parameters:
rVariantstore the name into this variable
void PoDoFo::PdfTokenizer::ReadString ( PdfVariant rVariant,
PdfEncrypt pEncrypt 
) [protected]

Read a string from the input device and store it into a variant.

Parameters:
rVariantstore the string into this variable
pEncryptan encryption object which is used to decrypt strings during parsing

Member Data Documentation

const unsigned int PoDoFo::PdfTokenizer::HEX_NOT_FOUND = std::numeric_limits<unsigned int>::max() [static]

Constant which is returned for invalid hex values.