ezEngine  Milestone 9
ezDeferredFileWriter Class Reference

A file writer that caches all written data and only opens and writes to the output file when everything is finished. Useful to ensure that only complete files are written, or nothing at all, in case of a crash. More...

#include <DeferredFileWriter.h>

Inheritance diagram for ezDeferredFileWriter:

Public Member Functions

 ~ezDeferredFileWriter ()
 Upon destruction the file is closed and thus written, unless Discard was called before.
 
void SetOutput (const char *szFileToWriteTo)
 This must be configured before anything is written to the file.
 
virtual ezResult WriteBytes (const void *pWriteBuffer, ezUInt64 uiBytesToWrite) override
 Writes a raw number of bytes from the buffer, this is the only method which has to be implemented to fully implement the interface.
 
ezResult Close ()
 Upon calling this the content is written to the file specified with SetOutput(). The return value is EZ_FAILURE if the file could not be opened or not completely written.
 
void Discard ()
 Calling this abandons the content and a later Close or destruction of the instance will no longer write anything to file.
 
- Public Member Functions inherited from ezStreamWriter
 ezStreamWriter ()
 Constructor.
 
virtual ~ezStreamWriter ()
 Virtual destructor to ensure correct cleanup.
 
virtual ezResult Flush ()
 Flushes the stream, may be implemented (not necessary to implement the interface correctly) so that user code can ensure that content is written.
 
template<typename T >
ezResult WriteWordValue (const T *pWordValue)
 Helper method to write a word value correctly (copes with potentially different endianess)
 
template<typename T >
ezResult WriteDWordValue (const T *pDWordValue)
 Helper method to write a dword value correctly (copes with potentially different endianess)
 
template<typename T >
ezResult WriteQWordValue (const T *pQWordValue)
 Helper method to write a qword value correctly (copes with potentially different endianess)
 
EZ_ALWAYS_INLINE void WriteVersion (ezTypeVersion uiVersion)
 Writes a type version to the stream.
 
template<typename ArrayType , typename ValueType >
ezResult WriteArray (const ezArrayBase< ValueType, ArrayType > &Array)
 Writes an array of elements to the stream.
 
template<typename ValueType , ezUInt32 uiSize>
ezResult WriteArray (const ValueType(&Array)[uiSize])
 Writes a C style fixed array.
 
template<typename KeyType , typename Comparer >
ezResult WriteSet (const ezSetBase< KeyType, Comparer > &Set)
 Writes a set.
 
template<typename KeyType , typename ValueType , typename Comparer >
ezResult WriteMap (const ezMapBase< KeyType, ValueType, Comparer > &Map)
 Writes a map.
 
ezResult WriteString (const ezStringView szStringView)
 Writes a string.
 

Detailed Description

A file writer that caches all written data and only opens and writes to the output file when everything is finished. Useful to ensure that only complete files are written, or nothing at all, in case of a crash.


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