Drag[en]gine Game Engine  1.21
decZFileWriter Class Reference

Z-Compressed file writer. More...

#include <decZFileWriter.h>

Inheritance diagram for decZFileWriter:
decBaseFileWriter deObject

Public Types

typedef deTObjectReference< decZFileWriterRef
 Type holding strong reference. More...
 
- Public Types inherited from decBaseFileWriter
typedef deTObjectReference< decBaseFileWriterRef
 Type holding strong reference. More...
 
- Public Types inherited from deObject
typedef deTObjectReference< deObjectRef
 Type holding strong reference. More...
 

Constructors and Destructors

 decZFileWriter (decBaseFileWriter *writer)
 Create z-compressed file writer object for another file writer. More...
 
 decZFileWriter (decBaseFileWriter *writer, bool pureMode)
 Create z-compressed file writer object for another file writer. More...
 
virtual ~decZFileWriter ()
 Close file and cleans up. More...
 

Management

virtual const char * GetFilename ()
 Name of the file. More...
 
virtual int GetPosition ()
 Current writing position in the file. More...
 
virtual void SetPosition (int position)
 Set file position for the next write action. More...
 
virtual void MovePosition (int offset)
 Move file position by the given offset. More...
 
virtual void SetPositionEnd (int position)
 Set file position to the given position measured from the end of the file. More...
 
virtual void Write (const void *buffer, int size)
 Write size bytes from buffer and advances the file pointer. More...
 
virtual decBaseFileWriter::Ref Duplicate ()
 Duplicate file writer. More...
 
void EndZWriting ()
 End writing flushing remaining data and closing the z-stream. More...
 

Additional Inherited Members

- Public Member Functions inherited from decBaseFileWriter
void WriteChar (int8_t value)
 Write one byte to file and advances write pointer. More...
 
void WriteByte (uint8_t value)
 Write one unsigned byte to file and advances write pointer. More...
 
void WriteShort (int16_t value)
 Write one short integer (2 bytes) to file and advances write pointer. More...
 
void WriteUShort (uint16_t value)
 Write one unsigned short integer (2 bytes) to file and advances write pointer. More...
 
void WriteInt (int32_t value)
 Write one integer (4 bytes) to file and advances write pointer. More...
 
void WriteUInt (uint32_t value)
 Write one unsigned integer (4 bytes) to file and advances write pointer. More...
 
void WriteLong (int64_t value)
 Write one integer (8 bytes) to file and advances write pointer. More...
 
void WriteULong (uint64_t value)
 Write one unsigned integer (8 bytes) to file and advances write pointer. More...
 
void WriteFloat (float value)
 Write one float (4 bytes) to file and advances write pointer. More...
 
void WriteDouble (double value)
 Write one double (8 bytes) to file and advances write pointer. More...
 
void WriteString (const char *string)
 Write string-length bytes of string to file without length field and advances write pointer. More...
 
void WriteString8 (const char *string)
 Write string-length bytes of string to file with a 1-byte length field in front and advances write pointer. More...
 
void WriteString16 (const char *string)
 Write string-length bytes of string to file with a 2-byte length field in front and advances write pointer. More...
 
void WriteVector (const decVector &vector)
 Write a 3-float vector to the file ( order x, y, z ) and advances write pointer. More...
 
void WriteVector2 (const decVector2 &vector)
 Write a 2-float vector to the file ( order x, y, z ) and advances write pointer. More...
 
void WriteQuaternion (const decQuaternion &quaternion)
 Write a 4-float quaternion to the file ( order x, y, z, w ) and advances write pointer. More...
 
void WritePoint (const decPoint &point)
 Write a 2-int point to the file ( order x, y ) and advances write pointer. More...
 
void WritePoint3 (const decPoint3 &point)
 Write a 3-int point to the file ( order x, y, z ) and advances write pointer. More...
 
void WriteDVector (const decDVector &vector)
 Write a 3-double vector to the file ( order x, y, z ) and advances write pointer. More...
 
void WriteColor (const decColor &color)
 Write a 4-component color to the file ( order r, g, b, a ) and advances write pointer. More...
 
void WriteColor3 (const decColor &color)
 Write a 3-component color to the file ( order r, g, b, a ) and advances write pointer. More...
 
 decBaseFileWriter ()
 Create file writer. More...
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
 
void AddReference ()
 Add reference increasing reference count by 1. More...
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 
 deObject ()
 Create object with reference count of 1. More...
 
- Protected Member Functions inherited from decBaseFileWriter
virtual ~decBaseFileWriter ()
 Clean up file writer. More...
 
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...
 

Detailed Description

Z-Compressed file writer.

Writes data to another file writer using Zlib compression. The user is responsible to place the file writer to the position where the Z-compressed data begins. This allows the user to place arbitrary headers in front of the z-compressed data. The compressed data is always written sequentially hence file writers unable to seek can be used. The z-writer takes over the original writer pointer deleting it once the z-writer itself is destroyed. The typical use case is to create a writer, writing the header, creating the z-writer and then handing back the z-writer to write the compressed file content. This way pointers are handled properly and the z-writer can be transparently used everywhere a file writer is used.

Member Typedef Documentation

◆ Ref

Type holding strong reference.

Constructor & Destructor Documentation

◆ decZFileWriter() [1/2]

decZFileWriter::decZFileWriter ( decBaseFileWriter writer)

Create z-compressed file writer object for another file writer.

The file writer is taken over and deleted once the z-writer is deleted. The file pointer has to be set to the starting position of the z-compressed data.

Note
To ensure future feature compatibility this class stored private data in front of the actual compress data. To write a pure z compressed stream use decZFileWriter(decBaseFileReader*,bool) .
Exceptions
deeInvalidParamwriter is NULL.

◆ decZFileWriter() [2/2]

decZFileWriter::decZFileWriter ( decBaseFileWriter writer,
bool  pureMode 
)

Create z-compressed file writer object for another file writer.

The file writer is taken over and deleted once the z-writer is deleted. The file pointer has to be set to the starting position of the z-compressed data.

Parameters
[in]pureModeIf true does not write private compression data. Use this mode if you want to write pure z compressed data. If false behaves identical to decZFileWriter(decBaseFileReader*) .
Exceptions
deeInvalidParamwriter is NULL.

◆ ~decZFileWriter()

virtual decZFileWriter::~decZFileWriter ( )
protectedvirtual

Close file and cleans up.

Note
Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ Duplicate()

virtual decBaseFileWriter::Ref decZFileWriter::Duplicate ( )
virtual

Duplicate file writer.

Implements decBaseFileWriter.

◆ EndZWriting()

void decZFileWriter::EndZWriting ( )

End writing flushing remaining data and closing the z-stream.

Exceptions
deeInvalidParamError compressing data.

◆ GetFilename()

virtual const char* decZFileWriter::GetFilename ( )
virtual

Name of the file.

Implements decBaseFileWriter.

◆ GetPosition()

virtual int decZFileWriter::GetPosition ( )
virtual

Current writing position in the file.

Implements decBaseFileWriter.

◆ MovePosition()

virtual void decZFileWriter::MovePosition ( int  offset)
virtual

Move file position by the given offset.

Implements decBaseFileWriter.

◆ SetPosition()

virtual void decZFileWriter::SetPosition ( int  position)
virtual

Set file position for the next write action.

Implements decBaseFileWriter.

◆ SetPositionEnd()

virtual void decZFileWriter::SetPositionEnd ( int  position)
virtual

Set file position to the given position measured from the end of the file.

Implements decBaseFileWriter.

◆ Write()

virtual void decZFileWriter::Write ( const void *  buffer,
int  size 
)
virtual

Write size bytes from buffer and advances the file pointer.

Exceptions
deeInvalidParambuffer is NULL.
deeInvalidParamsize is less than 0.
deeInvalidParamError compressing data.

Implements decBaseFileWriter.


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