Gorgon Game Engine
FileReader Class Reference

This is a file reader. Allows a Gorgon Resource to be loaded from a file. More...

Inheritance diagram for FileReader:
[legend]

Public Member Functions

 FileReader (const std::string &filename)
 Constructor requires a file to be opened later. More...
 
- Public Member Functions inherited from Reader
 Reader ()
 
virtual ~Reader ()
 
std::istream & GetStream ()
 This should be last resort, use if the actual stream is needed. More...
 
bool IsFailed () const
 Checks if the stream is open and it can be read from. More...
 
bool IsGood () const
 Checks if the stream is open and it can be read from. More...
 
bool IsOpen () const
 Checks if the stream is open. More...
 
void KeepOpen ()
 Request reader to keep reading stream open. More...
 
void NoLongerNeeded ()
 Marks that this reader is no longer needed. More...
 
void Open ()
 Opens the reader. If this operation fails, it will throw LoadError. More...
 
bool ReadCommonChunk (Base &self, GID::Type gid, unsigned long size)
 
void Seek (const Mark &pos)
 Seeks to the given position. More...
 
void Seek (unsigned long pos)
 Seeks to the given position. More...
 
Mark Target (unsigned long delta)
 Creates mark to the the target that is delta distance from current point in file. More...
 
unsigned long Tell () const
 Tells the current position. More...
 
bool TryOpen ()
 Tries to open the stream, if it fails, this function returns false. More...
 
template<class E_ >
E_ ReadEnum32 ()
 Reads an enumeration as 32-bit integer from the stream. More...
 
long ReadInt32 ()
 Reads a 32-bit integer from the stream. More...
 
unsigned long ReadUInt32 ()
 Reads a 32-bit unsigned integer from the stream. More...
 
int ReadInt16 ()
 Reads a 16-bit integer from the stream. More...
 
unsigned ReadUInt16 ()
 Reads a 16-bit unsigned integer from the stream. More...
 
char ReadInt8 ()
 Reads an 8-bit integer from the stream. More...
 
Byte ReadUInt8 ()
 Reads an 8-bit unsigned integer from the stream. More...
 
float ReadFloat ()
 Reads a 32 bit IEEE floating point number from the file. More...
 
double ReadDouble ()
 Reads a 64 bit IEEE double precision floating point number from the file. More...
 
bool ReadBool ()
 Reads a boolean value. In resource 1.0, booleans are stored as 32bit integers. More...
 
Graphics::RGBA ReadRGBA ()
 Reads a RGBA color, R will be read first. More...
 
Graphics::RGBAf ReadRGBAf ()
 Reads a RGBAf color, R will be read first. More...
 
std::string ReadString ()
 Reads a string from a given stream. More...
 
std::string ReadString (unsigned long size)
 Reads a string with the given size. More...
 
template<class T_ >
void ReadArray (T_ *data, unsigned long size)
 Reads an array from the file. More...
 
GID::Type ReadGID ()
 Reads a GID from the given stream. More...
 
SGuid ReadGuid ()
 Reads a GUID from the given stream. More...
 
Geometry::Point ReadPoint ()
 Reads a Point from the given stream. More...
 
Geometry::Point ReadPointf ()
 Reads a Pointf from the given stream. More...
 
Geometry::Size ReadSize ()
 Reads a Size from the given stream. More...
 
unsigned long ReadChunkSize ()
 Reads chunk size from a stream. More...
 
void EatChunk (long size)
 Removes a chunk of data with the given size from the stream. More...
 
void EatChunk ()
 Removes a chunk of data from the stream, the size will be read from the stream. More...
 

Protected Member Functions

virtual void close () override
 This function should close the stream. More...
 
virtual bool open (bool thrw) override
 This function should open the stream and set stream member. More...
 

Additional Inherited Members

- Protected Attributes inherited from Reader
std::istream * stream
 This is the stream that will be used to read data from. More...
 

Detailed Description

This is a file reader. Allows a Gorgon Resource to be loaded from a file.

Constructor & Destructor Documentation

◆ FileReader()

FileReader ( const std::string &  filename)

Constructor requires a file to be opened later.

References Gorgon::Filesystem::Canonical().

Member Function Documentation

◆ close()

virtual void close ( )
overrideprotectedvirtual

This function should close the stream.

The pointer will be unset by Reader class

Implements Reader.

◆ open()

virtual bool open ( bool  thrw)
overrideprotectedvirtual

This function should open the stream and set stream member.

If thrw is set to true and stream cannot be opened, a LoadError should be thrown. Otherwise this function is not allowed to throw.

Implements Reader.

References Gorgon::Filesystem::Canonical(), LoadError::FileNotFound, and Reader::stream.


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