Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Flash::Stream Class Reference

Data stream manager for flash file parsing. More...

Collaboration diagram for Burger::Flash::Stream:

Public Member Functions

 Stream (const Manager *pFlashPlayer, InputMemoryStream *pInput)
 Default constructor.
 
 ~Stream ()
 Release data.
 
const ManagerGetManager (void) const
 Get the parent manager class.
 
void ByteAlign (void)
 Byte align the data stream.
 
InputMemoryStreamGetStream (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

InputMemoryStreamm_pStream
 Pointer to the input stream.
 
const Managerm_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.
 

Detailed Description

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.

See also
Manager or InputMemoryStream

Constructor & Destructor Documentation

◆ Stream()

Burger::Flash::Stream::Stream ( const Manager * pFlashPlayer,
InputMemoryStream * pInput )

Default constructor.


Attaches an InputMemoryStream and a parent Flash Manager to a new input stream.

Note
This class does not take ownership of the InputMemoryStream. It will not release the Manager nor the InputMemoryStream on shutdown
Parameters
pFlashPlayerPointer to the parent flash player manager
pInputPointer to an InputMemoryStream to read flash player data from
See also
Manager or InputMemoryStream

◆ ~Stream()

Burger::Flash::Stream::~Stream ( )

Release data.


Note
This class did not take ownership of the InputMemoryStream. It will not release the Manager nor the InputMemoryStream on shutdown
See also
Stream(const Manager *,InputMemoryStream *)

Member Function Documentation

◆ ByteAlign()

void Burger::Flash::Stream::ByteAlign ( void )
inline

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)

See also
GetWord(uint_t) or GetInt(uint_t)

◆ CloseTag()

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.

See also
OpenTag(void) or GetTagEndPosition(void) const

◆ GetBoolean()

uint_t Burger::Flash::Stream::GetBoolean ( void )
inline

Get a single bit from the stream.


Extract a single bit from the stream and return it as a TRUE or FALSE

Returns
TRUE or FALSE
See also
ByteAlign(void) or GetWord(uint_t)

◆ GetByte()

uint8_t Burger::Flash::Stream::GetByte ( void )
inline

Read an 8 bit unsigned integer.


Parse a single unsigned byte from the byte stream.

Returns
An 8 bit unsigned integer.
See also
GetInt8(void)

◆ GetDouble()

double Burger::Flash::Stream::GetDouble ( void )
inline

Read a 64 bit floating point number.


Parse a little endian 4 bit floating point number from the byte stream.

Returns
64 bit floating point number from the byte stream.
See also
GetFloat16(void), GetFixedAsFloat(void) or GetFloat(void)

◆ GetEncodedInt32()

int32_t Burger::Flash::Stream::GetEncodedInt32 ( void )
inline

Read a byte compressed 32 bit signed integer.


Call GetEncodedU32(void) and return the value as a signed integer.

Returns
A 32 bit signed integer.
See also
GetEncodedU32(void) or GetEncodedU30(void)

◆ GetEncodedU30()

uint32_t Burger::Flash::Stream::GetEncodedU30 ( void )
inline

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).

Returns
A 32 bit unsigned integer.
See also
GetEncodedU32(void) or GetEncodedInt32(void)

◆ GetEncodedU32()

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.

Returns
An unsigned integer decompressed from the byte stream
See also
GetWord32(void), GetWord(uint_t) or GetBoolean(void)

◆ GetFixedAsFloat()

float Burger::Flash::Stream::GetFixedAsFloat ( void )
inline

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.

Returns
Floating point version of the 16.16 fixed point number.
See also
GetFloat16(void), GetFloat(void) or GetDouble(void)

◆ GetFloat()

float Burger::Flash::Stream::GetFloat ( void )
inline

Read a 32 bit floating point number.


Parse a little endian 32 bit floating point number from the byte stream.

Returns
32 bit floating point number from the byte stream.
See also
GetFloat16(void), GetFixedAsFloat(void) or GetDouble(void)

◆ GetFloat16()

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.

Returns
Floating point version of the 16 bit floating point number.
See also
GetFixedAsFloat(void), GetFloat(void) or GetDouble(void)

◆ GetInt()

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.

Parameters
uBitCountThe number of bits to parse (0-32).
Returns
An signed integer of the requested number of bits.
See also
GetWord(uint_t), ByteAlign(void) or GetBoolean(void)

◆ GetInt16()

int16_t Burger::Flash::Stream::GetInt16 ( void )
inline

Read a 16 bit signed integer.


Parse a 16 bit signed integer from the byte stream.

Returns
A 16 bit signed integer.
See also
GetShort(void)

◆ GetInt32()

int32_t Burger::Flash::Stream::GetInt32 ( void )
inline

Read a 32 bit signed integer.


Parse a 32 bit signed integer from the byte stream.

Returns
A 32 bit signed integer.
See also
GetWord32(void)

◆ GetInt8()

int8_t Burger::Flash::Stream::GetInt8 ( void )
inline

Read an 8 bit signed integer.


Parse a single signed byte from the byte stream.

Returns
An 8 bit signed integer.
See also
GetByte(void)

◆ GetManager()

const Manager * Burger::Flash::Stream::GetManager ( void ) const
inline

Get the parent manager class.


Some readers need access to the parent class, this function grants that access.

See also
Manager

◆ GetMark()

uintptr_t Burger::Flash::Stream::GetMark ( void ) const
inline

Return the current location of the byte stream.


Returns
The location in the stream where parsing is currently at.
See also
SetMark(uintptr_t)

◆ GetShort()

uint16_t Burger::Flash::Stream::GetShort ( void )
inline

Read a 16 bit unsigned integer.


Parse a 16 bit unsigned integer from the byte stream.

Returns
A 16 bit unsigned integer.
See also
GetInt16(void)

◆ GetStream()

InputMemoryStream * Burger::Flash::Stream::GetStream ( void ) const
inline

Get the InputMemoryStream pointer.


Returns
The pointer to the InputMemoryStream the class is using to read in data.
See also
InputMemoryStream

◆ GetTagEndPosition()

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

Returns
Input data mark from the last data tag.
See also
StartTag(void) or CloseTag(void)

◆ GetVariableCount()

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.

Returns
A 16 bit unsigned integer.
See also
GetEncodedU32(void)

◆ GetWord()

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.

Parameters
uBitCountThe number of bits to parse (0-32).
Returns
An unsigned integer of the requested number of bits.
See also
GetInt(uint_t), ByteAlign(void) or GetBoolean(void)

◆ GetWord32()

uint32_t Burger::Flash::Stream::GetWord32 ( void )
inline

Read a 32 bit unsigned integer.


Parse a 32 bit unsigned integer from the byte stream.

Returns
A 32 bit unsigned integer.
See also
GetInt32(void)

◆ ReadPString()

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.

Parameters
pOutputPointer to a String to store the parsed string data.
See also
ReadString(String *) or ReadString(uintptr_t,String *)

◆ ReadString() [1/2]

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.

Parameters
pOutputPointer to a String to store the parsed string data.
See also
ReadPString(String *) or ReadString(uintptr_t,String *)

◆ ReadString() [2/2]

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.

Parameters
uLengthNumber of bytes to read into the output string buffer.
pOutputPointer to a String to store the parsed string data.
See also
ReadString(String *) or ReadPString(String *)

◆ SetMark()

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.

Parameters
uMarkNew location in the byte stream to parse from.
See also
GetMark(void) const

◆ StartTag()

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.

Returns
Current tag ID (A 10 bit unsigned number)
See also
CloseTag(void) or GetTagEndPosition(void) const

Member Data Documentation

◆ m_pFlashPlayer

const Manager* Burger::Flash::Stream::m_pFlashPlayer
private

Pointer to the parent manager.

◆ m_pStream

InputMemoryStream* Burger::Flash::Stream::m_pStream
private

Pointer to the input stream.

◆ m_TagStack

SimpleArray<uintptr_t> Burger::Flash::Stream::m_TagStack
private

Stack of sections marks.

◆ m_uBitBucket

uint_t Burger::Flash::Stream::m_uBitBucket
private

Bit bucket for bit fields.

◆ m_uBitsRemaining

uint_t Burger::Flash::Stream::m_uBitsRemaining
private

Number of bits in the bit bucket.