liblcf
|
#include <writer_lcf.h>
Public Member Functions | |
LcfWriter (std::ostream &filestream, std::string encoding="") | |
~LcfWriter () | |
void | Write (const void *ptr, size_t size, size_t nmemb) |
template<class T > | |
void | Write (T val) |
void | Write (const std::string &str) |
void | WriteInt (int val) |
template<class T > | |
void | Write (const std::vector< T > &buffer) |
uint32_t | Tell () |
bool | IsOk () const |
std::string | Decode (const std::string &str_to_encode) |
template<> | |
void | Write (int8_t val) |
template<> | |
void | Write (uint8_t val) |
template<> | |
void | Write (int16_t val) |
template<> | |
void | Write (uint32_t val) |
template<> | |
void | Write (int32_t val) |
template<> | |
void | Write (bool val) |
template<> | |
void | Write (double val) |
template<> | |
void | Write (const std::vector< bool > &buffer) |
template<> | |
void | Write (const std::vector< uint8_t > &buffer) |
template<> | |
void | Write (const std::vector< int16_t > &buffer) |
template<> | |
void | Write (const std::vector< int32_t > &buffer) |
template<> | |
void | Write (const std::vector< uint32_t > &buffer) |
Static Private Member Functions | |
static void | SwapByteOrder (int16_t &us) |
static void | SwapByteOrder (uint16_t &us) |
static void | SwapByteOrder (int32_t &us) |
static void | SwapByteOrder (uint32_t &ui) |
static void | SwapByteOrder (double &d) |
Private Attributes | |
std::ostream & | stream |
Encoder | encoder |
LcfWriter class.
Definition at line 27 of file writer_lcf.h.
LcfWriter::LcfWriter | ( | std::ostream & | filestream, |
std::string | encoding = "" |
||
) |
Constructs a new File Writer.
filestream | already opened filestream. |
encoding | name of the encoding. |
Definition at line 14 of file writer_lcf.cpp.
LcfWriter::~LcfWriter | ( | ) |
Destructor. Closes the opened file.
Definition at line 20 of file writer_lcf.cpp.
std::string LcfWriter::Decode | ( | const std::string & | str_to_encode | ) |
Decodes a string from Utf8 to the set encoding in the Writer constructor.
str_to_encode | UTF-8 string to encode. |
Definition at line 129 of file writer_lcf.cpp.
References Encoder::Decode(), and encoder.
Referenced by RawStruct< RPG::MoveCommand >::LcfSize(), RawStruct< RPG::EventCommand >::LcfSize(), Primitive< std::string >::LcfSize(), Write(), RawStruct< RPG::MoveCommand >::WriteLcf(), and RawStruct< RPG::EventCommand >::WriteLcf().
bool LcfWriter::IsOk | ( | ) | const |
Checks if the file is writable and if no error occurred.
Definition at line 125 of file writer_lcf.cpp.
References encoder, Encoder::IsOk(), and stream.
Referenced by LMT_Reader::Save(), LMU_Reader::Save(), LSD_Reader::Save(), and LDB_Reader::Save().
|
staticprivate |
Converts a 16bit signed integer to/from little-endian.
us | integer to convert. |
Definition at line 165 of file writer_lcf.cpp.
Referenced by SwapByteOrder(), and Write().
|
staticprivate |
Converts a 16bit unsigned integer to/from little-endian.
us | integer to convert. |
Definition at line 160 of file writer_lcf.cpp.
|
staticprivate |
Converts a 32bit signed integer to/from little-endian.
us | integer to convert. |
Definition at line 170 of file writer_lcf.cpp.
References SwapByteOrder().
|
staticprivate |
Converts a 32bit unsigned integer to/from little-endian.
ui | integer to convert. |
Definition at line 161 of file writer_lcf.cpp.
|
staticprivate |
Converts a double to/from little-endian.
d | double to convert. |
Definition at line 162 of file writer_lcf.cpp.
uint32_t LcfWriter::Tell | ( | ) |
Returns the current position of the read pointer in the stream.
Definition at line 121 of file writer_lcf.cpp.
References stream.
void LcfWriter::Write | ( | int8_t | val | ) |
Definition at line 30 of file writer_lcf.cpp.
References Write().
void LcfWriter::Write | ( | uint8_t | val | ) |
Definition at line 35 of file writer_lcf.cpp.
References Write().
void LcfWriter::Write | ( | int16_t | val | ) |
Definition at line 40 of file writer_lcf.cpp.
References SwapByteOrder(), and Write().
void LcfWriter::Write | ( | uint32_t | val | ) |
Definition at line 46 of file writer_lcf.cpp.
References SwapByteOrder(), and Write().
void LcfWriter::Write | ( | const void * | ptr, |
size_t | size, | ||
size_t | nmemb | ||
) |
Writes raw data to the stream (fwrite() wrapper).
ptr | pointer to buffer. |
size | size of each element. |
nmemb | number of elements. |
Definition at line 24 of file writer_lcf.cpp.
References stream.
Referenced by LMT_Reader::Save(), LMU_Reader::Save(), LDB_Reader::Save(), LSD_Reader::Save(), Write(), RawStruct< RPG::MoveCommand >::WriteLcf(), RawStruct< RPG::Equipment >::WriteLcf(), RawStruct< RPG::Rect >::WriteLcf(), RawStruct< RPG::Parameters >::WriteLcf(), RawStruct< RPG::EventCommand >::WriteLcf(), Primitive< T >::WriteLcf(), Primitive< std::vector< T > >::WriteLcf(), Primitive< std::string >::WriteLcf(), and Flags< S >::WriteLcf().
void LcfWriter::Write | ( | T | val | ) |
Write a primitive value to the stream.
val | the value. |
void LcfWriter::Write | ( | int32_t | val | ) |
Definition at line 59 of file writer_lcf.cpp.
References WriteInt().
void LcfWriter::Write | ( | bool | val | ) |
Definition at line 64 of file writer_lcf.cpp.
References Write().
void LcfWriter::Write | ( | const std::string & | str | ) |
Writes a string to the stream.
str | the string. Note: the string is converted to the native encoding. |
Definition at line 114 of file writer_lcf.cpp.
References Decode(), and Write().
void LcfWriter::Write | ( | double | val | ) |
Definition at line 70 of file writer_lcf.cpp.
References SwapByteOrder(), and Write().
void LcfWriter::Write | ( | const std::vector< bool > & | buffer | ) |
Definition at line 76 of file writer_lcf.cpp.
References Write().
void LcfWriter::Write | ( | const std::vector< T > & | buffer | ) |
Write a vector of primitive values to the stream.
buffer | vector to write. |
void LcfWriter::Write | ( | const std::vector< uint8_t > & | buffer | ) |
Definition at line 85 of file writer_lcf.cpp.
References Write().
void LcfWriter::Write | ( | const std::vector< int16_t > & | buffer | ) |
Definition at line 90 of file writer_lcf.cpp.
References Write().
void LcfWriter::Write | ( | const std::vector< int32_t > & | buffer | ) |
Definition at line 97 of file writer_lcf.cpp.
References SwapByteOrder(), and Write().
void LcfWriter::Write | ( | const std::vector< uint32_t > & | buffer | ) |
Definition at line 108 of file writer_lcf.cpp.
References Write().
void LcfWriter::WriteInt | ( | int | val | ) |
Writes a compressed integer to the stream.
val | the integer. |
Definition at line 51 of file writer_lcf.cpp.
Referenced by conditional_zero_writer(), LMT_Reader::Save(), LMU_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), Write(), IDReaderT< S, true >::WriteID(), RawStruct< RPG::TreeMap >::WriteLcf(), RawStruct< RPG::MoveCommand >::WriteLcf(), RawStruct< RPG::EventCommand >::WriteLcf(), RawStruct< std::vector< RPG::EventCommand > >::WriteLcf(), Primitive< int32_t >::WriteLcf(), and Struct< S >::WriteLcf().
|
private |
|
private |
File-stream managed by this Writer.
Definition at line 109 of file writer_lcf.h.