Data stream manager for flash file parsing. More...
Public Member Functions | |
Stream (const Manager *pFlashPlayer, InputMemoryStream *pInput) | |
Default constructor. | |
~Stream () | |
Release data. | |
const Manager * | GetManager (void) const |
Get the parent manager class. | |
void | ByteAlign (void) |
Byte align the data stream. | |
InputMemoryStream * | GetStream (void) const |
Get the InputMemoryStream pointer. | |
uint_t | GetBoolean (void) |
Get a single bit from the stream. | |
uint32_t | GetEncodedU32 (void) |
Read a one to five bytes to create a 32 bit integer. | |
uint_t | GetWord (uint_t uBitCount) |
Read a number of bits from the stream. | |
int_t | GetInt (uint_t uBitCount) |
Read a number of signed bits from the stream. | |
float | GetFixedAsFloat (void) |
Read a 16.16 fixed point integer as a float. | |
float | GetFloat16 (void) |
Read a 16 bit float. | |
float | GetFloat (void) |
Read a 32 bit floating point number. | |
double | GetDouble (void) |
Read a 64 bit floating point number. | |
uint8_t | GetByte (void) |
Read an 8 bit unsigned integer. | |
int8_t | GetInt8 (void) |
Read an 8 bit signed integer. | |
uint16_t | GetShort (void) |
Read a 16 bit unsigned integer. | |
int16_t | GetInt16 (void) |
Read a 16 bit signed integer. | |
uint32_t | GetWord32 (void) |
Read a 32 bit unsigned integer. | |
int32_t | GetInt32 (void) |
Read a 32 bit signed integer. | |
int32_t | GetEncodedInt32 (void) |
Read a byte compressed 32 bit signed integer. | |
uint32_t | GetEncodedU30 (void) |
Read a byte compressed 30 bit unsigned integer. | |
uint_t | GetVariableCount (void) |
Read a byte compressed 16 bit unsigned integer. | |
void | ReadString (String *pOutput) |
Read in a zero terminated "C" string. | |
void | ReadPString (String *pOutput) |
Read in a pascal string. | |
void | ReadString (uintptr_t uLength, String *pOutput) |
Read in a specific number of bytes as a string. | |
uintptr_t | GetMark (void) const |
Return the current location of the byte stream. | |
void | SetMark (uintptr_t uMark) |
Set the location of the byte stream. | |
uintptr_t | GetTagEndPosition (void) const |
Return the file position of the end of the current tag. | |
uint_t | StartTag (void) |
Open a data tag. | |
void | CloseTag (void) |
Close a data tag. | |
Private Attributes | |
InputMemoryStream * | m_pStream |
Pointer to the input stream. | |
const Manager * | m_pFlashPlayer |
Pointer to the parent manager. | |
SimpleArray< uintptr_t > | m_TagStack |
Stack of sections marks. | |
uint_t | m_uBitBucket |
Bit bucket for bit fields. | |
uint_t | m_uBitsRemaining |
Number of bits in the bit bucket. | |
Data stream manager for flash file parsing.
Flash uses bit streams in addition to byte data. This class sits on top of a InputMemoryStream to handle parsing the special data types that are used exclusively by Flash.
Burger::Flash::Stream::Stream | ( | const Manager * | pFlashPlayer, |
InputMemoryStream * | pInput ) |
Default constructor.
Attaches an InputMemoryStream and a parent Flash Manager to a new input stream.
pFlashPlayer | Pointer to the parent flash player manager |
pInput | Pointer to an InputMemoryStream to read flash player data from |
Burger::Flash::Stream::~Stream | ( | ) |
Release data.
Byte align the data stream.
Forces the data stream to align to the next 8 bit boundary. This internal function will clear out and remaining bits left over from a bit stream parse from calls to GetWord(uint_t) or GetInt(uint_t)
void BURGER_API Burger::Flash::Stream::CloseTag | ( | void | ) |
Close a data tag.
Pops the last data tag end mark off of an internal stack and sets the input mark to this location. If Manager::GetVerboseParsingFlag(void) const flag is TRUE, it will output a console message notifying if there's a file mark mismatch, which is useful in debugging flash files.
Get a single bit from the stream.
Extract a single bit from the stream and return it as a TRUE or FALSE
Read an 8 bit unsigned integer.
Parse a single unsigned byte from the byte stream.
Read a 64 bit floating point number.
Parse a little endian 4 bit floating point number from the byte stream.
Read a byte compressed 32 bit signed integer.
Call GetEncodedU32(void) and return the value as a signed integer.
Read a byte compressed 30 bit unsigned integer.
Parse a 30 bit unsigned integer from the byte stream using the byte packing used in GetEncodedU32(void).
uint32_t BURGER_API Burger::Flash::Stream::GetEncodedU32 | ( | void | ) |
Read a one to five bytes to create a 32 bit integer.
Read in 1 to 5 bytes from the data stream. This variable length encoding is used by Flash to compress 32 bit integers.
This code was lovingly ripped off from the file http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf-file-format-spec.pdf at page 17.
Read a 16.16 fixed point integer as a float.
Parse a 32 bit 16.16 fixed point number and convert it to a float and then return the resulting float.
Read a 32 bit floating point number.
Parse a little endian 32 bit floating point number from the byte stream.
float BURGER_API Burger::Flash::Stream::GetFloat16 | ( | void | ) |
Read a 16 bit float.
Read in a compressed 16 bit float and convert it into a 32 bit floating point number.
int_t BURGER_API Burger::Flash::Stream::GetInt | ( | uint_t | uBitCount | ) |
Read a number of signed bits from the stream.
Read in 0 to 32 bits from the data stream. This will assert if a number higher than 32 is requested.
uBitCount | The number of bits to parse (0-32). |
Read a 16 bit signed integer.
Parse a 16 bit signed integer from the byte stream.
Read a 32 bit signed integer.
Parse a 32 bit signed integer from the byte stream.
Read an 8 bit signed integer.
Parse a single signed byte from the byte stream.
Get the parent manager class.
Some readers need access to the parent class, this function grants that access.
Return the current location of the byte stream.
Read a 16 bit unsigned integer.
Parse a 16 bit unsigned integer from the byte stream.
|
inline |
Get the InputMemoryStream pointer.
uintptr_t BURGER_API Burger::Flash::Stream::GetTagEndPosition | ( | void | ) | const |
Return the file position of the end of the current tag.
Return the file mark at the end of the data chunk from the last time StartTag(void) was called
uint_t BURGER_API Burger::Flash::Stream::GetVariableCount | ( | void | ) |
Read a byte compressed 16 bit unsigned integer.
Read a single byte, if the byte is equal to 0xFF, read in two more bytes and return the resulting 16 bit number, otherwise return the original single byte.
uint_t BURGER_API Burger::Flash::Stream::GetWord | ( | uint_t | uBitCount | ) |
Read a number of bits from the stream.
Read in 0 to 32 bits from the data stream. This will assert if a number higher than 32 is requested.
uBitCount | The number of bits to parse (0-32). |
Read a 32 bit unsigned integer.
Parse a 32 bit unsigned integer from the byte stream.
void BURGER_API Burger::Flash::Stream::ReadPString | ( | String * | pOutput | ) |
Read in a pascal string.
Read a single byte as a string length. Read in the following bytes into the output string. If the string length was zero, the output string is set to an empty string.
pOutput | Pointer to a String to store the parsed string data. |
void BURGER_API Burger::Flash::Stream::ReadString | ( | String * | pOutput | ) |
Read in a zero terminated "C" string.
Read from the data stream until a zero is found and capture the resulting string into the output.
pOutput | Pointer to a String to store the parsed string data. |
void BURGER_API Burger::Flash::Stream::ReadString | ( | uintptr_t | uLength, |
String * | pOutput ) |
Read in a specific number of bytes as a string.
Given a string length, read in the following bytes into the output string. If the string length was zero, the output string is set to an empty string.
uLength | Number of bytes to read into the output string buffer. |
pOutput | Pointer to a String to store the parsed string data. |
void BURGER_API Burger::Flash::Stream::SetMark | ( | uintptr_t | uMark | ) |
Set the location of the byte stream.
Move the mark position within the byte stream to parse at a different location.
uMark | New location in the byte stream to parse from. |
uint_t BURGER_API Burger::Flash::Stream::StartTag | ( | void | ) |
Open a data tag.
Read in 16 or 48 bits to get the next tag ID and the size of the data chunk. The end of chunk mark is pushed onto a stack so when CloseTag(void) is called, the marks can be checked for parsing errors.
|
private |
Pointer to the input stream.
|
private |
Stack of sections marks.
|
private |
Bit bucket for bit fields.
|
private |
Number of bits in the bit bucket.