liblcf
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LcfWriter Class Reference

#include <writer_lcf.h>

+ Collaboration diagram for LcfWriter:

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
 

Detailed Description

LcfWriter class.

Definition at line 23 of file writer_lcf.h.

Constructor & Destructor Documentation

LcfWriter::LcfWriter ( const char *  filename,
std::string  encoding = "" 
)

Constructs a new File Writer.

Parameters
filenamefile to open.
encodingname 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.

Parameters
filenamefile to open.
encodingname 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().

+ Here is the call graph for this function:

Member Function Documentation

void LcfWriter::Close ( )

Closes the opened file.

Definition at line 27 of file writer_lcf.cpp.

References stream.

Referenced by ~LcfWriter().

+ Here is the caller graph for this function:

std::string LcfWriter::Decode ( const std::string &  str_to_encode)

Decodes a string from Utf8 to the set encoding in the Writer constructor.

Parameters
str_to_encodeUTF-8 string to encode.
Returns
native version of string.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool LcfWriter::IsOk ( ) const

Checks if the file is writable and if no error occurred.

Returns
true the stream is okay.

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().

+ Here is the caller graph for this function:

void LcfWriter::SwapByteOrder ( int16_t &  us)
staticprivate

Converts a 16bit signed integer to/from little-endian.

Parameters
usinteger to convert.

Definition at line 155 of file writer_lcf.cpp.

void LcfWriter::SwapByteOrder ( uint16_t &  us)
staticprivate

Converts a 16bit unsigned integer to/from little-endian.

Parameters
usinteger to convert.

Definition at line 150 of file writer_lcf.cpp.

void LcfWriter::SwapByteOrder ( uint32_t &  ui)
staticprivate

Converts a 32bit unsigned integer to/from little-endian.

Parameters
uiinteger to convert.

Definition at line 151 of file writer_lcf.cpp.

void LcfWriter::SwapByteOrder ( double &  d)
staticprivate

Converts a double to/from little-endian.

Parameters
ddouble to convert.

Definition at line 152 of file writer_lcf.cpp.

template<>
void LcfWriter::Write ( uint8_t  val)

Definition at line 42 of file writer_lcf.cpp.

template<>
void LcfWriter::Write ( int16_t  val)

Definition at line 47 of file writer_lcf.cpp.

template<>
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 
)
template<>
void LcfWriter::Write ( int  val)

Definition at line 66 of file writer_lcf.cpp.

template<class T >
void LcfWriter::Write ( val)

Write a primitive value to the stream.

Parameters
valthe value.
template<>
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.

Parameters
strthe string. Note: the string is converted to the native encoding.

Definition at line 110 of file writer_lcf.cpp.

References Decode(), and Write().

+ Here is the call graph for this function:

template<>
void LcfWriter::Write ( double  val)

Definition at line 77 of file writer_lcf.cpp.

template<>
void LcfWriter::Write ( const std::vector< bool > &  buffer)

Definition at line 83 of file writer_lcf.cpp.

template<class T >
void LcfWriter::Write ( const std::vector< T > &  buffer)

Write a vector of primitive values to the stream.

Parameters
buffervector to write.
template<>
void LcfWriter::Write ( const std::vector< uint8_t > &  buffer)

Definition at line 92 of file writer_lcf.cpp.

template<>
void LcfWriter::Write ( const std::vector< int16_t > &  buffer)

Definition at line 97 of file writer_lcf.cpp.

template<>
void LcfWriter::Write ( const std::vector< uint32_t > &  buffer)

Definition at line 104 of file writer_lcf.cpp.

Member Data Documentation

std::string LcfWriter::encoding
private

Name of the encoding.

Definition at line 112 of file writer_lcf.h.

Referenced by Decode().

std::string LcfWriter::filename
private

Name of the file that is associated with the stream.

Definition at line 110 of file writer_lcf.h.

FILE* LcfWriter::stream
private

File-stream managed by this Writer.

Definition at line 114 of file writer_lcf.h.

Referenced by Close(), IsOk(), and Write().


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