Loading [MathJax]/extensions/tex2jax.js
Gorgon Game Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileWriter Class Reference

Allows data to be written to a file. More...

Inheritance diagram for FileWriter:
[legend]

Public Member Functions

 FileWriter (const std::string &filename)
 Constructs a new object with the given filename. More...
 
- Public Member Functions inherited from Writer
virtual ~Writer ()
 Any writer implementation should close and set the stream to nullptr in destructor. More...
 
void Close ()
 
std::ostream & GetStream ()
 This should be last resort, use if the actual stream is needed. More...
 
bool IsGood () const
 Checks if the stream is open and it can be written to. More...
 
void Seek (unsigned long pos)
 Seeks to the given position. More...
 
unsigned long Tell () const
 Tells the current position. More...
 
void WriteChunkHeader (GID::Type type, unsigned long size)
 Writes the header of a chunk. More...
 
Marker WriteChunkStart (GID::Type type)
 Writes the start of a chunk. Should have a matching WriteEnd. More...
 
void WriteEnd (Marker &marker)
 This function performs writes necessary to end a chunk that is represented by the marker. More...
 
Marker WriteObjectStart (const Base &base)
 Writes the start of an object. Should have a matching WriteEnd with the returned marker. More...
 
Marker WriteObjectStart (const Base &base, GID::Type type)
 Writes the start of an object. More...
 
Marker WriteObjectStart (const Base *base)
 Writes the start of an object. Should have a matching WriteEnd with the returned marker. More...
 
Marker WriteObjectStart (const Base *base, GID::Type type)
 Writes the start of an object. More...
 
template<class E_ >
void WriteEnum32 (E_ value)
 Writes an enumeration as 32-bit integer to the stream. More...
 
void WriteInt32 (long value)
 Writes a 32-bit integer to the stream. More...
 
void WriteUInt32 (unsigned long value)
 Writes a 32-bit unsigned integer to the stream. More...
 
void WriteInt16 (int value)
 Writes a 16-bit integer to the stream. More...
 
void WriteUInt16 (unsigned value)
 Writes a 16-bit unsigned integer to the stream. More...
 
void WriteInt8 (char value)
 Writes an 8-bit integer to the stream. More...
 
void WriteUInt8 (Byte value)
 Writes an 8-bit unsigned integer to the stream. More...
 
void WriteFloat (float value)
 Writes a 32 bit IEEE floating point number to the file. More...
 
void WriteDouble (double value)
 Writes a 64 bit IEEE double precision floating point number to the file. More...
 
void WriteBool (bool value)
 Writes a boolean value. In resource 1.0, booleans are stored as 32bit integers. More...
 
void WriteRGBA (Graphics::RGBA value)
 Writes a RGBA color, R will be saved first. RGBA takes 4 x 1 bytes. More...
 
void WriteRGBAf (Graphics::RGBAf value)
 Writes a RGBAf color, R will be saved first. RGBAf takes 4 x 4 bytes. More...
 
void WritePoint (Geometry::Point value)
 Writes a point to the stream, point takes 2 x 4 bytes. More...
 
void WritePointf (Geometry::Pointf value)
 Writes a point to the stream, point takes 2 x 4 bytes. More...
 
void WriteSize (Geometry::Size value)
 Writes a size to the stream, size takes 2 x 4 bytes. More...
 
void WriteStringWithSize (const std::string &value)
 Writes a string from a given stream. More...
 
void WriteString (const std::string &value)
 Writes a string without its size. More...
 
template<class T_ >
void WriteArray (const T_ *data, unsigned long size)
 Writes an array to the file. More...
 
template<class T_ >
void WriteVector (const std::vector< T_ > &data)
 Writes a vector to the stream. More...
 
void WriteGID (GID::Type value)
 Writes a GID to the given stream. More...
 
void WriteGuid (const SGuid &value)
 Writes a GUID to the given stream. More...
 
void WriteChunkSize (unsigned long value)
 Writes chunk size to 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 Writer
std::ostream * stream
 This is the stream that will be used to write data to. More...
 

Detailed Description

Allows data to be written to a file.

Constructor & Destructor Documentation

◆ FileWriter()

FileWriter ( const std::string &  filename)

Member Function Documentation

◆ close()

virtual void close ( )
overrideprotectedvirtual

This function should close the stream.

The pointer will be unset by Writeer class

Implements Writer.

◆ 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 WriteError should be thrown. Otherwise this function is not allowed to throw.

Implements Writer.

References WriteError::CannotOpenFile, and Writer::stream.


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