PoDoFo 0.7.0
|
#include <PdfTokenizer.h>
Public Member Functions | |
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) |
A simple tokenizer for PDF files and PDF content streams
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.
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).
ch | hex character |
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.
bool PoDoFo::PdfTokenizer::GetNextToken | ( | const char *& | pszToken, |
EPdfTokenType * | peType = NULL |
||
) |
Reads the next token from the current file position ignoring all comments.
[out] | pszBuf | On 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] | peType | On true return, if not NULL the type of the read token will be stored into this parameter. Undefined on false return. |
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.
rVariant | write the read variant to this value |
pEncrypt | an 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.
pszToken | a token that has already been read |
eType | type of the passed token |
rVariant | write the read variant to this value |
pEncrypt | an 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
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.
pszToken | a token that is compared to the read 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
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.
pszToken | string of the token |
eType | type of the token |
void PoDoFo::PdfTokenizer::ReadArray | ( | PdfVariant & | rVariant, |
PdfEncrypt * | pEncrypt | ||
) | [protected] |
Read an array from the input device and store it into a variant.
rVariant | store the array into this variable |
pEncrypt | an 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.
rVariant | store the dictionary into this variable |
pEncrypt | an 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.
rVariant | store the hex string into this variable |
pEncrypt | an 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.
rVariant | store 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.
rVariant | store the string into this variable |
pEncrypt | an encryption object which is used to decrypt strings during parsing |
const unsigned int PoDoFo::PdfTokenizer::HEX_NOT_FOUND = std::numeric_limits<unsigned int>::max() [static] |
Constant which is returned for invalid hex values.