Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Abstract utility class for parsing binary files.
Provides a library of methods to quickly navigate and extract various data types (signed and unsigned integers, floating- and fixed-point numbers, strings, etc.) from the file.
File access is managed via a {@link Zend_Pdf_FileParserDataSource} object. This allows the same parser code to work with many different data sources: in-memory objects, filesystem files, etc.
BYTE_ORDER_LITTLE_ENDIAN = '0'
Little-endian byte order (0x04 0x03 0x02 0x01).
BYTE_ORDER_BIG_ENDIAN = '1'
Big-endian byte order (0x01 0x02 0x03 0x04).
Zend_Pdf_FileParserDataSource $_dataSource = 'null'
Object representing the data source to be parsed.
boolean $_isParsed = 'false'
Flag indicating that the file has been sucessfully parsed.
boolean $_isScreened = 'false'
Flag indicating that the file has passed a cursory validation check.
__construct(
Zend_Pdf_FileParserDataSource $dataSource
)
:
Object constructor.
Verifies that the data source has been properly initialized.
__destruct(
)
:
Object destructor.
Discards the data source object.
getDataSource(
)
:
Zend_Pdf_FileParserDataSource
Returns the data source object representing the file being parsed.
getOffset(
)
:
getSize(
)
:
isBitSet(
integer $bit, integer $bitField
)
:
boolean
Returns true if the specified bit is set in the integer bitfield.
isParsed(
)
:
boolean
Returns true if the file has been successfully parsed.
isScreened(
)
:
boolean
Returns true if the file has passed a cursory validation check.
moveToOffset(
integer $offset
)
:
Convenience wrapper for the data source object's moveToOffset() method.
parse(
)
:
Reads and parses the complete binary file.
Must set $this->_isParsed to true if successful.
readBytes(
integer $byteCount
)
:
string
Convenience wrapper for the data source object's readBytes() method.
readFixed(
integer $mantissaBits, integer $fractionBits, integer $byteOrder
=
Zend_Pdf_FileParser
)
:
float
Reads the signed fixed-point number from the binary file at the current byte offset.
Common fixed-point sizes are 2.14 and 16.16.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
readInt(
integer $size, integer $byteOrder
=
Zend_Pdf_FileParser
)
:
integer
Reads the signed integer value from the binary file at the current byte offset.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
readStringMacRoman(
integer $byteCount, string $characterSet
)
:
string
Reads the Mac Roman-encoded string from the binary file at the current byte offset.
You must supply the desired resulting character set.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
readStringPascal(
string $characterSet, integer $lengthBytes
=
1
)
:
string
Reads the Pascal string from the binary file at the current byte offset.
The length of the Pascal string is determined by reading the length bytes which preceed the character data. You must supply the desired resulting character set.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
readStringUTF16(
integer $byteCount, integer $byteOrder
=
Zend_Pdf_FileParser, string $characterSet
)
:
string
Reads the Unicode UTF-16-encoded string from the binary file at the current byte offset.
The byte order of the UTF-16 string must be specified. You must also supply the desired resulting character set.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
readUInt(
integer $size, integer $byteOrder
=
Zend_Pdf_FileParser
)
:
integer
Reads the unsigned integer value from the binary file at the current byte offset.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
NOTE: If you ask for a 4-byte unsigned integer on a 32-bit machine, the resulting value WILL BE SIGNED because PHP uses signed integers internally for everything. To guarantee portability, be sure to use bitwise operators operators on large unsigned integers!
screen(
)
:
Performs a cursory check to verify that the binary file is in the expected format. Intended to quickly weed out obviously bogus files.
Must set $this->_isScreened to true if successful.
skipBytes(
integer $byteCount
)
:
Convenience wrapper for the data source object's skipBytes() method.