![]() |
XII Release 0.1.0
|
The default class to use to write data to a file, implements the xiiStreamWriter interface. More...
#include <FileWriter.h>
Public Member Functions | |
xiiFileWriter ()=default | |
Constructor, does nothing. | |
~xiiFileWriter () | |
Destructor, closes the file, if it is still open (RAII). | |
xiiResult | Open (xiiStringView sFile, xiiUInt32 uiCacheSize=1024 *1024, xiiFileShareMode::Enum fileShareMode=xiiFileShareMode::Default, bool bAllowFileEvents=true) |
Opens the given file for writing. Returns XII_SUCCESS if the file could be opened. A cache is created to speed up small writes. | |
void | Close () |
Closes the file, if it is open. | |
virtual xiiResult | WriteBytes (const void *pWriteBuffer, xiiUInt64 uiBytesToWrite) override |
Writes the given number of bytes to the file. Returns XII_SUCCESS if all bytes were successfully written. | |
virtual xiiResult | Flush () override |
Will write anything that's currently in the write-cache to disk. Will decrease performance if used excessively. | |
![]() | |
xiiString128 | GetFilePathAbsolute () const |
Returns the absolute path with which the file was opened (including the prefix of the data directory). | |
xiiString128 | GetFilePathRelative () const |
Returns the relative path of the file within its data directory (excluding the prefix of the data directory). | |
xiiDataDirectoryType * | GetDataDirectory () const |
Returns the xiiDataDirectoryType over which this file has been opened. | |
bool | IsOpen () const |
Returns true, if the file is currently open. | |
xiiUInt64 | GetFileSize () const |
Returns the current total size of the file. | |
![]() | |
xiiStreamWriter () | |
Constructor. | |
virtual | ~xiiStreamWriter () |
Virtual destructor to ensure correct cleanup. | |
template<typename T> | |
xiiResult | WriteWordValue (const T *pWordValue) |
Helper method to write a word value correctly (copes with potentially different endianess). | |
template<typename T> | |
xiiResult | WriteDWordValue (const T *pDWordValue) |
Helper method to write a dword value correctly (copes with potentially different endianess). | |
template<typename T> | |
xiiResult | WriteQWordValue (const T *pQWordValue) |
Helper method to write a qword value correctly (copes with potentially different endianess). | |
XII_ALWAYS_INLINE void | WriteVersion (xiiTypeVersion version) |
Writes a type version to the stream. | |
template<typename ArrayType, typename ValueType> | |
xiiResult | WriteArray (const xiiArrayBase< ValueType, ArrayType > &array) |
Writes an array of elements to the stream. | |
template<typename ValueType, xiiUInt16 uiSize> | |
xiiResult | WriteArray (const xiiSmallArrayBase< ValueType, uiSize > &array) |
Writes a small array of elements to the stream. | |
template<typename ValueType, xiiUInt32 uiSize> | |
xiiResult | WriteArray (const ValueType(&array)[uiSize]) |
Writes a C style fixed array. | |
template<typename KeyType, typename Comparer> | |
xiiResult | WriteSet (const xiiSetBase< KeyType, Comparer > &set) |
Writes a set. | |
template<typename KeyType, typename ValueType, typename Comparer> | |
xiiResult | WriteMap (const xiiMapBase< KeyType, ValueType, Comparer > &map) |
Writes a map. | |
template<typename KeyType, typename ValueType, typename Hasher> | |
xiiResult | WriteHashTable (const xiiHashTableBase< KeyType, ValueType, Hasher > &hashTable) |
Writes a hash table (note that the entry order might change on read) | |
xiiResult | WriteString (const xiiStringView sStringView) |
Writes a string. | |
Additional Inherited Members | |
![]() | |
xiiDataDirectoryWriter * | GetFileWriter (xiiStringView sFile, xiiFileShareMode::Enum FileShareMode, bool bAllowFileEvents) |
![]() | |
xiiDataDirectoryWriter * | m_pDataDirWriter |
The default class to use to write data to a file, implements the xiiStreamWriter interface.
This file writer buffers writes up to a certain amount of bytes (configurable). It closes the file automatically once it goes out of scope.
|
overridevirtual |
Will write anything that's currently in the write-cache to disk. Will decrease performance if used excessively.
Reimplemented from xiiStreamWriter.
xiiResult xiiFileWriter::Open | ( | xiiStringView | sFile, |
xiiUInt32 | uiCacheSize = 1024 * 1024, | ||
xiiFileShareMode::Enum | fileShareMode = xiiFileShareMode::Default, | ||
bool | bAllowFileEvents = true ) |
Opens the given file for writing. Returns XII_SUCCESS if the file could be opened. A cache is created to speed up small writes.
You should typically not disable bAllowFileEvents, unless you need to prevent recursive file events, which is only the case, if you are doing file accesses from within a File Event Handler.
|
overridevirtual |
Writes the given number of bytes to the file. Returns XII_SUCCESS if all bytes were successfully written.
As this class buffers writes with an internal cache, XII_SUCCESS does NOT mean that the data is actually written to disk.
Implements xiiStreamWriter.