liblcf
LcfWriter Class Reference

#include <writer_lcf.h>

+ Collaboration diagram for LcfWriter:

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
 

Detailed Description

LcfWriter class.

Definition at line 27 of file writer_lcf.h.

Constructor & Destructor Documentation

◆ LcfWriter()

LcfWriter::LcfWriter ( std::ostream &  filestream,
std::string  encoding = "" 
)

Constructs a new File Writer.

Parameters
filestreamalready opened filestream.
encodingname of the encoding.

Definition at line 14 of file writer_lcf.cpp.

◆ ~LcfWriter()

LcfWriter::~LcfWriter ( )

Destructor. Closes the opened file.

Definition at line 20 of file writer_lcf.cpp.

Member Function Documentation

◆ Decode()

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 129 of file writer_lcf.cpp.

References Encoder::Decode(), and encoder.

Referenced by RawStruct< RPG::EventCommand >::LcfSize(), RawStruct< RPG::MoveCommand >::LcfSize(), Primitive< std::string >::LcfSize(), Write(), RawStruct< RPG::EventCommand >::WriteLcf(), and RawStruct< RPG::MoveCommand >::WriteLcf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsOk()

bool LcfWriter::IsOk ( ) const

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

Returns
true the stream is okay.

Definition at line 125 of file writer_lcf.cpp.

References encoder, Encoder::IsOk(), and stream.

Referenced by LMU_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), and LMT_Reader::Save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SwapByteOrder() [1/5]

void LcfWriter::SwapByteOrder ( double &  d)
staticprivate

Converts a double to/from little-endian.

Parameters
ddouble to convert.

Definition at line 162 of file writer_lcf.cpp.

◆ SwapByteOrder() [2/5]

void LcfWriter::SwapByteOrder ( int16_t &  us)
staticprivate

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

Parameters
usinteger to convert.

Definition at line 165 of file writer_lcf.cpp.

Referenced by SwapByteOrder(), and Write().

+ Here is the caller graph for this function:

◆ SwapByteOrder() [3/5]

void LcfWriter::SwapByteOrder ( int32_t &  us)
staticprivate

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

Parameters
usinteger to convert.

Definition at line 170 of file writer_lcf.cpp.

References SwapByteOrder().

+ Here is the call graph for this function:

◆ SwapByteOrder() [4/5]

void LcfWriter::SwapByteOrder ( uint16_t &  us)
staticprivate

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

Parameters
usinteger to convert.

Definition at line 160 of file writer_lcf.cpp.

◆ SwapByteOrder() [5/5]

void LcfWriter::SwapByteOrder ( uint32_t &  ui)
staticprivate

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

Parameters
uiinteger to convert.

Definition at line 161 of file writer_lcf.cpp.

◆ Tell()

uint32_t LcfWriter::Tell ( )

Returns the current position of the read pointer in the stream.

Returns
current location in the stream.

Definition at line 121 of file writer_lcf.cpp.

References stream.

◆ Write() [1/16]

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

Definition at line 64 of file writer_lcf.cpp.

References Write().

+ Here is the call graph for this function:

◆ Write() [2/16]

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 114 of file writer_lcf.cpp.

References Decode(), and Write().

+ Here is the call graph for this function:

◆ Write() [3/16]

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

Definition at line 76 of file writer_lcf.cpp.

References Write().

+ Here is the call graph for this function:

◆ Write() [4/16]

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

Definition at line 90 of file writer_lcf.cpp.

References Write().

+ Here is the call graph for this function:

◆ Write() [5/16]

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

Definition at line 97 of file writer_lcf.cpp.

References SwapByteOrder(), and Write().

+ Here is the call graph for this function:

◆ Write() [6/16]

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

Write a vector of primitive values to the stream.

Parameters
buffervector to write.

◆ Write() [7/16]

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

Definition at line 108 of file writer_lcf.cpp.

References Write().

+ Here is the call graph for this function:

◆ Write() [8/16]

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

Definition at line 85 of file writer_lcf.cpp.

References Write().

+ Here is the call graph for this function:

◆ Write() [9/16]

void LcfWriter::Write ( const void *  ptr,
size_t  size,
size_t  nmemb 
)

Writes raw data to the stream (fwrite() wrapper).

Parameters
ptrpointer to buffer.
sizesize of each element.
nmembnumber of elements.

Definition at line 24 of file writer_lcf.cpp.

References stream.

Referenced by LMU_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), LMT_Reader::Save(), Write(), RawStruct< RPG::Equipment >::WriteLcf(), RawStruct< RPG::EventCommand >::WriteLcf(), RawStruct< RPG::MoveCommand >::WriteLcf(), RawStruct< RPG::Parameters >::WriteLcf(), RawStruct< RPG::Rect >::WriteLcf(), Flags< S >::WriteLcf(), Primitive< std::string >::WriteLcf(), Primitive< std::vector< T > >::WriteLcf(), and Primitive< T >::WriteLcf().

+ Here is the caller graph for this function:

◆ Write() [10/16]

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

Definition at line 70 of file writer_lcf.cpp.

References SwapByteOrder(), and Write().

+ Here is the call graph for this function:

◆ Write() [11/16]

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

Definition at line 40 of file writer_lcf.cpp.

References SwapByteOrder(), and Write().

+ Here is the call graph for this function:

◆ Write() [12/16]

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

Definition at line 59 of file writer_lcf.cpp.

References WriteInt().

+ Here is the call graph for this function:

◆ Write() [13/16]

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

Definition at line 30 of file writer_lcf.cpp.

References Write().

+ Here is the call graph for this function:

◆ Write() [14/16]

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

Write a primitive value to the stream.

Parameters
valthe value.

◆ Write() [15/16]

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

Definition at line 46 of file writer_lcf.cpp.

References SwapByteOrder(), and Write().

+ Here is the call graph for this function:

◆ Write() [16/16]

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

Definition at line 35 of file writer_lcf.cpp.

References Write().

+ Here is the call graph for this function:

◆ WriteInt()

void LcfWriter::WriteInt ( int  val)

Writes a compressed integer to the stream.

Parameters
valthe integer.

Definition at line 51 of file writer_lcf.cpp.

Referenced by conditional_zero_writer(), LMU_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), LMT_Reader::Save(), Write(), IDReaderT< S, true >::WriteID(), Primitive< int32_t >::WriteLcf(), RawStruct< RPG::EventCommand >::WriteLcf(), RawStruct< RPG::MoveCommand >::WriteLcf(), RawStruct< RPG::TreeMap >::WriteLcf(), Struct< S >::WriteLcf(), and RawStruct< std::vector< RPG::EventCommand > >::WriteLcf().

+ Here is the caller graph for this function:

Member Data Documentation

◆ encoder

Encoder LcfWriter::encoder
private

Encoder object

Definition at line 111 of file writer_lcf.h.

Referenced by Decode(), and IsOk().

◆ stream

std::ostream& LcfWriter::stream
private

File-stream managed by this Writer.

Definition at line 109 of file writer_lcf.h.

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


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