liblcf
|
#include <writer_lcf.h>
Public Member Functions | |
LcfWriter (const char *filename, std::string encoding="") | |
LcfWriter (const std::string &filename, std::string encoding="") | |
~LcfWriter () | |
void | Close () |
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) |
bool | IsOk () const |
std::string | Decode (const std::string &str_to_encode) |
template<> | |
void | Write (uint8_t val) |
template<> | |
void | Write (int16_t val) |
template<> | |
void | Write (uint32_t val) |
template<> | |
void | Write (int 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< uint32_t > &buffer) |
Static Private Member Functions | |
static void | SwapByteOrder (int16_t &us) |
static void | SwapByteOrder (uint16_t &us) |
static void | SwapByteOrder (uint32_t &ui) |
static void | SwapByteOrder (double &d) |
Private Attributes | |
std::string | filename |
std::string | encoding |
FILE * | stream |
LcfWriter class.
Definition at line 23 of file writer_lcf.h.
LcfWriter::LcfWriter | ( | const char * | filename, |
std::string | encoding = "" |
||
) |
Constructs a new File Writer.
filename | file to open. |
encoding | name of the encoding. |
Definition at line 9 of file writer_lcf.cpp.
LcfWriter::LcfWriter | ( | const std::string & | filename, |
std::string | encoding = "" |
||
) |
Constructs a new File Writer.
filename | file to open. |
encoding | name of the encoding. |
Definition at line 16 of file writer_lcf.cpp.
LcfWriter::~LcfWriter | ( | ) |
Destructor. Closes the opened file.
Definition at line 23 of file writer_lcf.cpp.
References Close().
void LcfWriter::Close | ( | ) |
Closes the opened file.
Definition at line 27 of file writer_lcf.cpp.
References stream.
Referenced by ~LcfWriter().
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 121 of file writer_lcf.cpp.
References encoding, and ReaderUtil::Recode().
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 117 of file writer_lcf.cpp.
References stream.
Referenced by LMU_Reader::Save(), LMT_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 155 of file writer_lcf.cpp.
|
staticprivate |
Converts a 16bit unsigned integer to/from little-endian.
us | integer to convert. |
Definition at line 150 of file writer_lcf.cpp.
|
staticprivate |
Converts a 32bit unsigned integer to/from little-endian.
ui | integer to convert. |
Definition at line 151 of file writer_lcf.cpp.
|
staticprivate |
Converts a double to/from little-endian.
d | double to convert. |
Definition at line 152 of file writer_lcf.cpp.
void LcfWriter::Write | ( | uint8_t | val | ) |
Definition at line 42 of file writer_lcf.cpp.
void LcfWriter::Write | ( | int16_t | val | ) |
Definition at line 47 of file writer_lcf.cpp.
void LcfWriter::Write | ( | uint32_t | val | ) |
Definition at line 53 of file writer_lcf.cpp.
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 33 of file writer_lcf.cpp.
References stream.
Referenced by LMU_Reader::Save(), LMT_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), Write(), RawStruct< RPG::MoveCommand >::WriteLcf(), RawStruct< RPG::Parameters >::WriteLcf(), RawStruct< RPG::Equipment >::WriteLcf(), RawStruct< RPG::Rect >::WriteLcf(), RawStruct< RPG::EventCommand >::WriteLcf(), Primitive< T >::WriteLcf(), Primitive< std::vector< T > >::WriteLcf(), Primitive< std::string >::WriteLcf(), and Flags< S >::WriteLcf().
void LcfWriter::Write | ( | int | val | ) |
Definition at line 66 of file writer_lcf.cpp.
void LcfWriter::Write | ( | T | val | ) |
Write a primitive value to the stream.
val | the value. |
void LcfWriter::Write | ( | bool | val | ) |
Definition at line 71 of file writer_lcf.cpp.
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 110 of file writer_lcf.cpp.
References Decode(), and Write().
void LcfWriter::Write | ( | double | val | ) |
Definition at line 77 of file writer_lcf.cpp.
void LcfWriter::Write | ( | const std::vector< bool > & | buffer | ) |
Definition at line 83 of file writer_lcf.cpp.
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 92 of file writer_lcf.cpp.
void LcfWriter::Write | ( | const std::vector< int16_t > & | buffer | ) |
Definition at line 97 of file writer_lcf.cpp.
void LcfWriter::Write | ( | const std::vector< uint32_t > & | buffer | ) |
Definition at line 104 of file writer_lcf.cpp.
void LcfWriter::WriteInt | ( | int | val | ) |
Writes a compressed integer to the stream.
val | the integer. |
Definition at line 58 of file writer_lcf.cpp.
Referenced by LMU_Reader::Save(), LMT_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), IDReaderT< S, true >::WriteID(), RawStruct< RPG::MoveCommand >::WriteLcf(), RawStruct< RPG::TreeMap >::WriteLcf(), RawStruct< RPG::EventCommand >::WriteLcf(), RawStruct< std::vector< RPG::EventCommand > >::WriteLcf(), Primitive< int >::WriteLcf(), and Struct< S >::WriteLcf().
|
private |
|
private |
Name of the file that is associated with the stream.
Definition at line 110 of file writer_lcf.h.
|
private |
File-stream managed by this Writer.
Definition at line 114 of file writer_lcf.h.