Guiliani  Version 2.5 revision 7293 (documentation build 13)
CGUIStreamReader Class Referenceabstract

Base class for stream readers. More...

#include <GUIStreamReader.h>

Inheritance diagram for CGUIStreamReader:

Public Member Functions

virtual ~CGUIStreamReader ()
 
virtual CGUIStreamReaderClone () const =0
 
virtual void DeleteCommentTag (const eC_Char *pcTag=NULL)=0
 
virtual void DeleteCommentTag (const eC_String &kTag)=0
 
eC_UInt GetCurLine () const
 
FileAlignment_t GetFileAlignment () const
 
FileEndianess_t GetFileEndianess () const
 
virtual const eC_String & GetFileSuffix () const
 
FileType_t GetFileType () const
 
eC_String GetLastReadTag () const
 
virtual AnimationHandle_t ReadAnimationChainID (const eC_Char *pcTag=NULL)
 
virtual void ReadBinary (eC_TArray< eC_UByte > &aData, const eC_Char *pcTag=NULL)=0
 
virtual eC_Bool ReadBool (const eC_Char *pcTag=NULL)=0
 
virtual eC_Byte ReadByte (const eC_Char *pcTag=NULL)=0
 
virtual ColorValue_t ReadColor (const eC_Char *pcTag=NULL)=0
 
virtual DataPoolResource_t ReadDataPoolID (const eC_Char *pcTag=NULL)
 
virtual eC_Float ReadFloat (const eC_Char *pcTag=NULL)=0
 
virtual FontResource_t ReadFontID (const eC_Char *pcTag=NULL)
 
virtual GeneralResource_t ReadGeneralResourceID (const eC_Char *pcTag=NULL)
 
virtual eC_UInt ReadHex (const eC_Char *pcTag=NULL)=0
 
virtual ImageResource_t ReadImageID (const eC_Char *pcTag=NULL)
 
virtual eC_Int ReadInt (const eC_Char *pcTag=NULL)=0
 
virtual ObjectHandle_t ReadObjectID (const eC_Char *pcTag=NULL)
 
virtual GlobalProperty_t ReadPropertyID (const eC_Char *pcTag=NULL)
 
virtual eC_Short ReadShort (const eC_Char *pcTag=NULL)=0
 
virtual SoundResource_t ReadSoundID (const eC_Char *pcTag=NULL)
 
virtual eC_Int ReadStreamingFileHeader ()=0
 
virtual eC_String ReadString (const eC_Char *pcTag=NULL)=0
 
virtual TextResource_t ReadTextID (const eC_Char *pcTag=NULL)
 
virtual eC_UByte ReadUByte (const eC_Char *pcTag=NULL)=0
 
virtual eC_UInt ReadUInt (const eC_Char *pcTag=NULL)=0
 
virtual eC_UShort ReadUShort (const eC_Char *pcTag=NULL)=0
 
void ResetStreamingFile ()
 
void SetStreamingFile (eC_File *pkStreamingFile)
 

Static Public Member Functions

static void CreateInstance ()
 
static void DeleteInstance ()
 
static CGUIStreamReaderGetInstance ()
 

Protected Member Functions

 CGUIStreamReader (FileType_t eFileType, FileEndianess_t eFileEndianess, FileAlignment_t eFileAlignment)
 
void ResizeReadBuffer (eC_Bool bReset)
 

Protected Attributes

eC_TArray< eC_Char > m_aReadBuffer
 Dynamic array to hold currently read tag content.
 
FileAlignment_t m_eFileAlignment
 Alignment of the file.
 
FileEndianess_t m_eFileEndianess
 Endianess of the file.
 
FileType_t m_eFileType
 File Type.
 
eC_String m_kLastReadTag
 Last tag which was read, used to skip to the end of an corrupted object.
 
eC_File * m_pkCurrentInputFile
 Pointer to the current streaming file. All reading operations will be performed on this file.
 
eC_UInt m_uiCurLine
 Line number in current streaming file.
 

Detailed Description

Base class for stream readers.

Stream readers are used to read GUI definitions from files. This abstract base class defines the interfaces for handling streaming files and reading values from them.

Each instance of a stream reader operates on one file at a time. A file can be set by calling SetStreamingFile().

Note
CGUIStreamReader is NOT responsible for destruction of the streaming file, this should be done by the file creator. Call ResetStreamingFile() after destruction of it, to avoid streaming operations on a non valid file pointer.

After setting a file, the various read methods can be called. Each of them expects a 'tag' which can be a descriptive text string or something else. Implementations can use these tags in whatever way they want, for instance for error checking. They may also choose to ignore the tags. However, a CGUIStreamReader implementation in general is expected to be able to read what its counterpart CGUIStreamWriter implementation wrote. Each of the methods returns the value read from the file.

The stream reader offers the method GetCurLine() which returns an internal line number. Implementations are expected to increase the counter in a meaningful way that allows for printing debug messages that point users to errors in their streaming files.

Additionally the StreamReader can return the last read tag which can be used to e.g. check for corrupted elements and skip until the end of these.

For each of the Read... methods declared in this class there is an additional macro, for instance READ_INT for the method ReadInt(). Streaming code should use these macros instead of direct method calls.

See also
Streaming

Constructor & Destructor Documentation

◆ ~CGUIStreamReader()

virtual CGUIStreamReader::~CGUIStreamReader ( )
virtual

Destructor.

Removes this object from stream reader stack.

◆ CGUIStreamReader()

CGUIStreamReader::CGUIStreamReader ( FileType_t  eFileType,
FileEndianess_t  eFileEndianess,
FileAlignment_t  eFileAlignment 
)
protected

Constructs a stream reader. Initially, no file is set. The line number is initialized to 1. This reader will be pushed on top of the reader stack.

Parameters
eFileTypeinitial file type
eFileEndianessinitial file endianess
eFileAlignmentinitial file alignment

Member Function Documentation

◆ Clone()

virtual CGUIStreamReader * CGUIStreamReader::Clone ( ) const
pure virtual
Returns
Clone this StreamReader. Caller is responsible for deleting the allocated instance.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ CreateInstance()

static void CGUIStreamReader::CreateInstance ( )
static

Create Instance

◆ DeleteCommentTag() [1/2]

virtual void CGUIStreamReader::DeleteCommentTag ( const eC_Char *  pcTag = NULL)
pure virtual

Reads over (removes) a tag from the current streaming file without reading a value.

Parameters
pcTagOptional descriptive tag.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ DeleteCommentTag() [2/2]

virtual void CGUIStreamReader::DeleteCommentTag ( const eC_String &  kTag)
pure virtual

Reads over (removes) a tag from the current streaming file without reading a value.

Parameters
kTagdescriptive tag.

Implemented in CGUIStreamReaderXML, and CGUIStreamReaderBinary.

◆ DeleteInstance()

static void CGUIStreamReader::DeleteInstance ( )
static

Delete Instance

◆ GetCurLine()

eC_UInt CGUIStreamReader::GetCurLine ( ) const
inline

Returns the current line in the streaming file.

Returns
The line number in the current streaming file.

◆ GetFileAlignment()

FileAlignment_t CGUIStreamReader::GetFileAlignment ( ) const
inline

Gets the alignment of the file

Returns
alignment of the file

◆ GetFileEndianess()

FileEndianess_t CGUIStreamReader::GetFileEndianess ( ) const
inline

Gets the endianess of the file

Returns
Endianess of the file

◆ GetFileSuffix()

virtual const eC_String & CGUIStreamReader::GetFileSuffix ( ) const
virtual

Returns the file suffix which is associated with this reader's file format. This can be an empty string, if e.g. the reader works with formats which are unrelated to files.

Returns
String with the associated file suffix (e.g. ".xml")

Reimplemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ GetFileType()

FileType_t CGUIStreamReader::GetFileType ( ) const
inline

Gets the type of the file

Returns
type of the file

◆ GetInstance()

static CGUIStreamReader & CGUIStreamReader::GetInstance ( )
static
Returns
Returns instance of current stream stack's top.

◆ GetLastReadTag()

eC_String CGUIStreamReader::GetLastReadTag ( ) const
inline

Gets the last read Tag

Returns
last read tag

◆ ReadAnimationChainID()

virtual AnimationHandle_t CGUIStreamReader::ReadAnimationChainID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads an animation chain handle from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The object handle read from the file.

◆ ReadBinary()

virtual void CGUIStreamReader::ReadBinary ( eC_TArray< eC_UByte > &  aData,
const eC_Char *  pcTag = NULL 
)
pure virtual

Reads binary stream. Array will be retrieved from stream in raw mode.

Parameters
pcTagOptional descriptive tag.
[out]aDataArray the read data will be set to.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadBool()

virtual eC_Bool CGUIStreamReader::ReadBool ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a boolean value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadByte()

virtual eC_Byte CGUIStreamReader::ReadByte ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a signed byte value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadColor()

virtual ColorValue_t CGUIStreamReader::ReadColor ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a color from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadDataPoolID()

virtual DataPoolResource_t CGUIStreamReader::ReadDataPoolID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads a DataPool ID from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The DataPool ID read from the file.

◆ ReadFloat()

virtual eC_Float CGUIStreamReader::ReadFloat ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a float value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadFontID()

virtual FontResource_t CGUIStreamReader::ReadFontID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads a font ID from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The font ID read from the file.

◆ ReadGeneralResourceID()

virtual GeneralResource_t CGUIStreamReader::ReadGeneralResourceID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads a general resource ID from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The general resource ID read from the file.

◆ ReadHex()

virtual eC_UInt CGUIStreamReader::ReadHex ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a hexadecimal integer value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadImageID()

virtual ImageResource_t CGUIStreamReader::ReadImageID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads an image ID from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The image ID read from the file.

◆ ReadInt()

virtual eC_Int CGUIStreamReader::ReadInt ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a signed integer value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadObjectID()

virtual ObjectHandle_t CGUIStreamReader::ReadObjectID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads an object handle from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The object handle read from the file.

◆ ReadPropertyID()

virtual GlobalProperty_t CGUIStreamReader::ReadPropertyID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads a Property ID from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The Property ID read from the file.

◆ ReadShort()

virtual eC_Short CGUIStreamReader::ReadShort ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a short value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadSoundID()

virtual SoundResource_t CGUIStreamReader::ReadSoundID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads a sound ID from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The sound ID read from the file.

◆ ReadStreamingFileHeader()

virtual eC_Int CGUIStreamReader::ReadStreamingFileHeader ( )
pure virtual

Reads the file header of a streaming file

Returns
version of the file

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadString()

virtual eC_String CGUIStreamReader::ReadString ( const eC_Char *  pcTag = NULL)
pure virtual

Reads a string from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The string that has been read.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadTextID()

virtual TextResource_t CGUIStreamReader::ReadTextID ( const eC_Char *  pcTag = NULL)
inlinevirtual

Reads a text ID from the current streaming file. The call is directly forwarded to ReadInt().

Parameters
pcTagOptional descriptive tag.
Returns
The text ID read from the file.

◆ ReadUByte()

virtual eC_UByte CGUIStreamReader::ReadUByte ( const eC_Char *  pcTag = NULL)
pure virtual

Reads an unsigned byte value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadUInt()

virtual eC_UInt CGUIStreamReader::ReadUInt ( const eC_Char *  pcTag = NULL)
pure virtual

Reads an unsigned integer value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ReadUShort()

virtual eC_UShort CGUIStreamReader::ReadUShort ( const eC_Char *  pcTag = NULL)
pure virtual

Reads an unsigned short value from the current streaming file.

Parameters
pcTagOptional descriptive tag.
Returns
The value read from the file.

Implemented in CGUIStreamReaderBinary, and CGUIStreamReaderXML.

◆ ResetStreamingFile()

void CGUIStreamReader::ResetStreamingFile ( )

Removes the streaming file. This method must be called whenever a file is no longer used and is closed by another instance. This method resets the line number and the internal pointer, ensuring that further read operations do not use invalid file pointers.

◆ ResizeReadBuffer()

void CGUIStreamReader::ResizeReadBuffer ( eC_Bool  bReset)
protected

The local read buffer will be resized by power-of-2 or reset to initial size of 128 Bytes.

Parameters
bResetSet this flag true initializes a new, empty buffer with initial size. False increments the current array size and preserves content.

◆ SetStreamingFile()

void CGUIStreamReader::SetStreamingFile ( eC_File *  pkStreamingFile)

Sets the file to read from. When the file is no longer needed, call ResetStreamingFile(). Always sets the streaming file mode to eC_File::FS_BIGENDIAN.

Parameters
pkStreamingFileThe streaming file. Subsequent read method calls operate on this file.

The documentation for this class was generated from the following file: