Guiliani  Version 2.5 revision 7293 (documentation build 13)
GUIStreamReader.h
Go to the documentation of this file.
1/*
2* Copyright (C) TES Electronic Solutions GmbH,
3* All Rights Reserved.
4* Contact: info@guiliani.de
5*
6* This file is part of the Guiliani HMI framework
7* for the development of graphical user interfaces on embedded systems.
8*/
9
10#ifdef GUILIANI_STREAM_GUI
11
12#ifndef GUISTREAMREADER__H_
13#define GUISTREAMREADER__H_
14
19#include "eC_Types.h"
20#include "eC_String.h"
21
22#include "eC_TArrayStack.h"
23
24#include "GUICommonTypes.h"
25
27#include "GUIImageResource.h"
28#include "GUITextResource.h"
29#include "GUIFontResource.h"
30#include "GUISoundResource.h"
31#include "GUIGeneralResource.h"
32#include "GUIDataPoolResource.h"
33#include "GUIPropertyResource.h"
34#include "GUIColorResource.h"
36#include "GUIStreamTypes.h"
37
39#define READ_BOOL(x) ReadBool(x)
41#define READ_UBYTE(x) ReadUByte(x)
43#define READ_SBYTE(x) ReadSByte(x)
45#define READ_SHORT(x) ReadShort(x)
47#define READ_USHORT(x) ReadUShort(x)
49#define READ_INT(x) ReadInt(x)
51#define READ_UINT(x) ReadUInt(x)
53#define READ_HEX(x) ReadHex(x)
55#define READ_COLOR(x) ReadColor(x)
57#define READ_FLOAT(x) ReadFloat(x)
59#define READ_STRING(x) ReadString(x)
61#define READ_BINARY(a, x) ReadBinary(a, x)
63#define DELETE_COMMENT_TAG(x) DeleteCommentTag(x)
65#define READ_OBJECTID(x) ReadObjectID(x)
67#define READ_IMAGEID(x) ReadImageID(x)
69#define READ_TEXTID(x) ReadTextID(x)
71#define READ_FONTID(x) ReadFontID(x)
73#define READ_SOUNDID(x) ReadSoundID(x)
75#define READ_GENRESID(x) ReadGeneralResourceID(x)
77#define READ_DATAPOOLID(x) ReadDataPoolID(x)
79#define READ_PROPERTYID(x) ReadPropertyID(x)
80
82#define GETINPUTSTREAM CGUIStreamReader::GetInstance()
83
84class eC_File;
85
87#define BUFFER_LENGTH 1024
88
90
127{
128public:
131 static void CreateInstance();
132
135 static void DeleteInstance();
136
142
145
147 virtual CGUIStreamReader* Clone() const = 0;
148
153 virtual const eC_String& GetFileSuffix() const;
154
161 void SetStreamingFile(eC_File* pkStreamingFile);
162
169
174 virtual eC_UByte ReadUByte(const eC_Char* pcTag = NULL) = 0;
175
180 virtual eC_Byte ReadByte(const eC_Char* pcTag = NULL) = 0;
181
186 virtual eC_UInt ReadUInt(const eC_Char* pcTag = NULL) = 0;
187
192 virtual eC_Int ReadInt(const eC_Char* pcTag = NULL) = 0;
193
198 virtual eC_UInt ReadHex(const eC_Char* pcTag = NULL) = 0;
199
204 virtual ColorValue_t ReadColor(const eC_Char* pcTag = NULL) = 0;
205
210 virtual eC_Float ReadFloat(const eC_Char* pcTag = NULL) = 0;
211
216 virtual eC_String ReadString(const eC_Char* pcTag = NULL) = 0;
217
222 virtual eC_UShort ReadUShort(const eC_Char* pcTag = NULL) = 0;
223
228 virtual eC_Short ReadShort(const eC_Char* pcTag = NULL) = 0;
229
234 virtual eC_Bool ReadBool(const eC_Char* pcTag = NULL) = 0;
235
240 virtual void ReadBinary(eC_TArray<eC_UByte>& aData, const eC_Char* pcTag = NULL) = 0;
241
247 virtual ObjectHandle_t ReadObjectID(const eC_Char* pcTag = NULL)
248 {
249 return static_cast<ObjectHandle_t>(READ_INT(pcTag));
250 }
251
257 virtual ImageResource_t ReadImageID(const eC_Char* pcTag = NULL)
258 {
259 return static_cast<ImageResource_t>(READ_INT(pcTag));
260 }
261
267 virtual TextResource_t ReadTextID(const eC_Char* pcTag = NULL)
268 {
269 return static_cast<TextResource_t>(READ_INT(pcTag));
270 }
271
277 virtual FontResource_t ReadFontID(const eC_Char* pcTag = NULL)
278 {
279 return static_cast<FontResource_t>(READ_INT(pcTag));
280 }
281
287 virtual SoundResource_t ReadSoundID(const eC_Char* pcTag = NULL)
288 {
289 return static_cast<SoundResource_t>(READ_INT(pcTag));
290 }
291
299 virtual GeneralResource_t ReadGeneralResourceID(const eC_Char* pcTag = NULL)
300 {
301 return static_cast<GeneralResource_t>(READ_INT(pcTag));
302 }
303
309 virtual DataPoolResource_t ReadDataPoolID(const eC_Char* pcTag = NULL)
310 {
311 return static_cast<DataPoolResource_t>(READ_INT(pcTag));
312 }
313
319 virtual GlobalProperty_t ReadPropertyID(const eC_Char* pcTag = NULL)
320 {
321 return static_cast<GlobalProperty_t>(READ_INT(pcTag));
322 }
323
329 virtual AnimationHandle_t ReadAnimationChainID(const eC_Char* pcTag = NULL)
330 {
331 return static_cast<AnimationHandle_t>(READ_INT(pcTag));
332 }
333
337 eC_UInt GetCurLine() const
338 {
339 return m_uiCurLine;
340 }
341
346 virtual void DeleteCommentTag(const eC_Char* pcTag = NULL) = 0;
347
352 virtual void DeleteCommentTag(const eC_String &kTag) = 0;
353
357 virtual eC_Int ReadStreamingFileHeader() = 0;
358
362 FileEndianess_t GetFileEndianess() const
363 {
364 return m_eFileEndianess;
365 }
366
370 FileType_t GetFileType() const
371 {
372 return m_eFileType;
373 }
374
378 FileAlignment_t GetFileAlignment() const
379 {
380 return m_eFileAlignment;
381 }
382
386 eC_String GetLastReadTag() const
387 {
388 return m_kLastReadTag;
389 }
390
391protected:
399 CGUIStreamReader(FileType_t eFileType, FileEndianess_t eFileEndianess, FileAlignment_t eFileAlignment);
400
407 void ResizeReadBuffer (eC_Bool bReset);
408
409protected:
412
414 eC_TArray<eC_Char> m_aReadBuffer;
415
417 eC_UInt m_uiCurLine;
418
420 FileType_t m_eFileType;
421
423 FileEndianess_t m_eFileEndianess;
424
426 FileAlignment_t m_eFileAlignment;
427
429 eC_String m_kLastReadTag;
430
431private:
434 CGUIStreamReader(const CGUIStreamReader& kSource);
435
438 CGUIStreamReader& operator=(const CGUIStreamReader& kSource);
439};
440
441#endif
442#endif
Helper Macros in Guiliani
AnimationHandle_t
List of animation resource ids.
Definition: GUIAnimationResource.h:49
Helper Macros in Guiliani
Helper Macros in Guiliani
DataPoolResource_t
List of data pool resource ids.
Definition: GUIDataPoolResource.h:35
Helper Macros in Guiliani
FontResource_t
List of font resource ids.
Definition: GUIFontResource.h:54
Helper Macros in Guiliani
GeneralResource_t
List of general resource ids.
Definition: GUIGeneralResource.h:52
Helper Macros in Guiliani
ImageResource_t
Enumeration of image resource ids.
Definition: GUIImageResource.h:126
Helper Macros in Guiliani
ObjectHandle_t
List of object resource ids.
Definition: GUIObjectHandleResource.h:55
Helper Macros in Guiliani
GlobalProperty_t
List of property resource ids.
Definition: GUIPropertyResource.h:67
Helper Macros in Guiliani
SoundResource_t
List of sound resource ids.
Definition: GUISoundResource.h:48
#define READ_INT(x)
Helper macro that should be used instead of calling CGUIStreamReader::ReadInt().
Definition: GUIStreamReader.h:49
Helper Macros in Guiliani
TextResource_t
List of text resource ids.
Definition: GUITextResource.h:40
Base class for stream readers.
Definition: GUIStreamReader.h:127
virtual TextResource_t ReadTextID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:267
void ResizeReadBuffer(eC_Bool bReset)
eC_String GetLastReadTag() const
Definition: GUIStreamReader.h:386
eC_File * m_pkCurrentInputFile
Pointer to the current streaming file. All reading operations will be performed on this file.
Definition: GUIStreamReader.h:411
virtual FontResource_t ReadFontID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:277
eC_UInt GetCurLine() const
Definition: GUIStreamReader.h:337
eC_UInt m_uiCurLine
Line number in current streaming file.
Definition: GUIStreamReader.h:417
virtual const eC_String & GetFileSuffix() const
void SetStreamingFile(eC_File *pkStreamingFile)
virtual eC_Int ReadStreamingFileHeader()=0
virtual void DeleteCommentTag(const eC_String &kTag)=0
virtual eC_Short ReadShort(const eC_Char *pcTag=NULL)=0
FileEndianess_t m_eFileEndianess
Endianess of the file.
Definition: GUIStreamReader.h:423
static void CreateInstance()
virtual eC_Byte ReadByte(const eC_Char *pcTag=NULL)=0
eC_TArray< eC_Char > m_aReadBuffer
Dynamic array to hold currently read tag content.
Definition: GUIStreamReader.h:414
virtual ColorValue_t ReadColor(const eC_Char *pcTag=NULL)=0
virtual eC_UInt ReadHex(const eC_Char *pcTag=NULL)=0
virtual void ReadBinary(eC_TArray< eC_UByte > &aData, const eC_Char *pcTag=NULL)=0
eC_String m_kLastReadTag
Last tag which was read, used to skip to the end of an corrupted object.
Definition: GUIStreamReader.h:429
static void DeleteInstance()
static CGUIStreamReader & GetInstance()
virtual eC_Int ReadInt(const eC_Char *pcTag=NULL)=0
FileType_t GetFileType() const
Definition: GUIStreamReader.h:370
virtual void DeleteCommentTag(const eC_Char *pcTag=NULL)=0
virtual AnimationHandle_t ReadAnimationChainID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:329
void ResetStreamingFile()
virtual ~CGUIStreamReader()
virtual DataPoolResource_t ReadDataPoolID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:309
virtual eC_Float ReadFloat(const eC_Char *pcTag=NULL)=0
virtual eC_Bool ReadBool(const eC_Char *pcTag=NULL)=0
FileAlignment_t m_eFileAlignment
Alignment of the file.
Definition: GUIStreamReader.h:426
FileAlignment_t GetFileAlignment() const
Definition: GUIStreamReader.h:378
virtual SoundResource_t ReadSoundID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:287
CGUIStreamReader(FileType_t eFileType, FileEndianess_t eFileEndianess, FileAlignment_t eFileAlignment)
virtual eC_UByte ReadUByte(const eC_Char *pcTag=NULL)=0
virtual eC_String ReadString(const eC_Char *pcTag=NULL)=0
virtual eC_UShort ReadUShort(const eC_Char *pcTag=NULL)=0
FileType_t m_eFileType
File Type.
Definition: GUIStreamReader.h:420
virtual ImageResource_t ReadImageID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:257
virtual GeneralResource_t ReadGeneralResourceID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:299
FileEndianess_t GetFileEndianess() const
Definition: GUIStreamReader.h:362
virtual GlobalProperty_t ReadPropertyID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:319
virtual eC_UInt ReadUInt(const eC_Char *pcTag=NULL)=0
virtual ObjectHandle_t ReadObjectID(const eC_Char *pcTag=NULL)
Definition: GUIStreamReader.h:247
virtual CGUIStreamReader * Clone() const =0
structure used to stream colors
Definition: GUICommonTypes.h:24