|
liblcf
|
#include <reader_lcf.h>
Collaboration diagram for LcfReader:Classes | |
| struct | Chunk |
Public Types | |
| enum | SeekMode { FromStart, FromEnd, FromCurrent } |
Public Member Functions | |
| LcfReader (const char *filename, std::string encoding="") | |
| LcfReader (const std::string &filename, std::string encoding="") | |
| ~LcfReader () | |
| void | Close () |
| size_t | Read0 (void *ptr, size_t size, size_t nmemb) |
| void | Read (void *ptr, size_t size, size_t nmemb) |
| template<class T > | |
| void | Read (T &ref) |
| template<class T > | |
| void | Read (std::vector< T > &buffer, size_t size) |
| int | ReadInt () |
| void | ReadString (std::string &ref, size_t size) |
| bool | IsOk () const |
| bool | Eof () const |
| void | Seek (size_t pos, SeekMode mode=FromStart) |
| uint32_t | Tell () |
| bool | Ungetch (uint8_t ch) |
| void | Skip (const struct LcfReader::Chunk &chunk_info) |
| std::string | Encode (const std::string &str_to_encode) |
| template<> | |
| void | Read (bool &ref) |
| template<> | |
| void | Read (uint8_t &ref) |
| template<> | |
| void | Read (int16_t &ref) |
| template<> | |
| void | Read (uint32_t &ref) |
| template<> | |
| void | Read (int &ref) |
| template<> | |
| void | Read (double &ref) |
| template<> | |
| void | Read (std::vector< bool > &buffer, size_t size) |
| template<> | |
| void | Read (std::vector< uint8_t > &buffer, size_t size) |
| template<> | |
| void | Read (std::vector< int16_t > &buffer, size_t size) |
| template<> | |
| void | Read (std::vector< uint32_t > &buffer, size_t size) |
Static Public Member Functions | |
| static const std::string & | GetError () |
| static void | SetError (const char *fmt,...) |
| static int | IntSize (unsigned int x) |
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 |
Static Private Attributes | |
| static std::string | error_str |
LcfReader class.
Definition at line 30 of file reader_lcf.h.
| enum LcfReader::SeekMode |
Defines the Seek start position for the Seek function.
| Enumerator | |
|---|---|
| FromStart | |
| FromEnd | |
| FromCurrent | |
Definition at line 90 of file reader_lcf.h.
| LcfReader::LcfReader | ( | const char * | filename, |
| std::string | encoding = "" |
||
| ) |
Constructs a new File Reader.
| filename | file to open. |
| encoding | name of the encoding. |
Definition at line 18 of file reader_lcf.cpp.
| LcfReader::LcfReader | ( | const std::string & | filename, |
| std::string | encoding = "" |
||
| ) |
Constructs a new File Reader.
| filename | file to open. |
| encoding | name of the encoding. |
Definition at line 25 of file reader_lcf.cpp.
| LcfReader::~LcfReader | ( | ) |
Destructor. Closes the opened file.
Definition at line 32 of file reader_lcf.cpp.
References Close().
Here is the call graph for this function:| void LcfReader::Close | ( | ) |
Closes the opened file.
Definition at line 36 of file reader_lcf.cpp.
References stream.
Referenced by ~LcfReader().
Here is the caller graph for this function:| std::string LcfReader::Encode | ( | const std::string & | str_to_encode | ) |
Encodes a string to UTF-8 using the set encoding in the reader constructor.
| str_to_encode | string to encode. |
Definition at line 251 of file reader_lcf.cpp.
References encoding, and ReaderUtil::Recode().
Referenced by ReadString().
Here is the call graph for this function:
Here is the caller graph for this function:| bool LcfReader::Eof | ( | ) | const |
Checks if the end of the file has been reached.
Definition at line 174 of file reader_lcf.cpp.
References stream.
Referenced by Read0(), and Struct< S >::ReadLcf().
Here is the caller graph for this function:
|
static |
Returns the last set error.
Definition at line 247 of file reader_lcf.cpp.
References error_str.
|
static |
Calculates the size of a compressed integer.
| x | the integer. |
Definition at line 255 of file reader_lcf.cpp.
Referenced by IDReaderT< S, true >::IDSize(), RawStruct< RPG::MoveCommand >::LcfSize(), RawStruct< RPG::EventCommand >::LcfSize(), Primitive< int >::LcfSize(), SizeField< S, T >::LcfSize(), and Struct< S >::LcfSize().
Here is the caller graph for this function:| bool LcfReader::IsOk | ( | ) | const |
Checks if the file is readable and if no error occured.
Definition at line 170 of file reader_lcf.cpp.
References stream.
Referenced by LMU_Reader::Load(), LMT_Reader::Load(), LSD_Reader::Load(), and LDB_Reader::Load().
Here is the caller graph for this function:| void LcfReader::Read | ( | bool & | ref | ) |
Definition at line 61 of file reader_lcf.cpp.
| void LcfReader::Read | ( | uint8_t & | ref | ) |
Definition at line 66 of file reader_lcf.cpp.
| void LcfReader::Read | ( | int16_t & | ref | ) |
Definition at line 71 of file reader_lcf.cpp.
| void LcfReader::Read | ( | uint32_t & | ref | ) |
Definition at line 77 of file reader_lcf.cpp.
| void LcfReader::Read | ( | int & | ref | ) |
Definition at line 98 of file reader_lcf.cpp.
| void LcfReader::Read | ( | double & | ref | ) |
Definition at line 103 of file reader_lcf.cpp.
| void LcfReader::Read | ( | std::vector< bool > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 109 of file reader_lcf.cpp.
| void LcfReader::Read | ( | void * | ptr, |
| size_t | size, | ||
| size_t | nmemb | ||
| ) |
Reads raw data from the stream (fread() wrapper).
| ptr | pointer to buffer. |
| size | size of each element. |
| nmemb | number of elements. |
Definition at line 52 of file reader_lcf.cpp.
References Read0().
Referenced by RawStruct< RPG::MoveCommand >::ReadLcf(), RawStruct< RPG::Parameters >::ReadLcf(), RawStruct< RPG::Rect >::ReadLcf(), RawStruct< RPG::Equipment >::ReadLcf(), RawStruct< RPG::EventCommand >::ReadLcf(), RawStruct< std::vector< RPG::EventCommand > >::ReadLcf(), Primitive< T >::ReadLcf(), Primitive< std::vector< T > >::ReadLcf(), Flags< S >::ReadLcf(), and ReadString().
Here is the call graph for this function:
Here is the caller graph for this function:| void LcfReader::Read | ( | std::vector< uint8_t > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 120 of file reader_lcf.cpp.
| void LcfReader::Read | ( | T & | ref | ) |
Reads a primitive type.
| ref | reference to store result. |
| void LcfReader::Read | ( | std::vector< T > & | buffer, |
| size_t | size | ||
| ) |
Reads a vector of primitive type.
| buffer | vector to fill. |
| size | how many bytes to read. |
| void LcfReader::Read | ( | std::vector< int16_t > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 131 of file reader_lcf.cpp.
References Data::items.
| void LcfReader::Read | ( | std::vector< uint32_t > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 147 of file reader_lcf.cpp.
References Data::items.
| size_t LcfReader::Read0 | ( | void * | ptr, |
| size_t | size, | ||
| size_t | nmemb | ||
| ) |
Reads raw data from the stream (fread() wrapper).
| ptr | pointer to buffer. |
| size | size of each element. |
| nmemb | number of elements. |
Definition at line 42 of file reader_lcf.cpp.
Referenced by Read(), and ReadInt().
Here is the call graph for this function:
Here is the caller graph for this function:| int LcfReader::ReadInt | ( | ) |
Reads a compressed integer from the stream.
Definition at line 82 of file reader_lcf.cpp.
References Read0().
Referenced by LMU_Reader::Load(), LMT_Reader::Load(), LSD_Reader::Load(), LDB_Reader::Load(), IDReaderT< S, true >::ReadID(), RawStruct< RPG::MoveCommand >::ReadLcf(), RawStruct< RPG::TreeMap >::ReadLcf(), RawStruct< RPG::EventCommand >::ReadLcf(), Primitive< int >::ReadLcf(), and Struct< S >::ReadLcf().
Here is the call graph for this function:
Here is the caller graph for this function:| void LcfReader::ReadString | ( | std::string & | ref, |
| size_t | size | ||
| ) |
Reads a string.
| size | string length. |
| ref | reference to store result. Note: The string is converted to UTF-8. |
Definition at line 162 of file reader_lcf.cpp.
References Encode(), and Read().
Referenced by LMU_Reader::Load(), LMT_Reader::Load(), LSD_Reader::Load(), LDB_Reader::Load(), RawStruct< RPG::MoveCommand >::ReadLcf(), RawStruct< RPG::EventCommand >::ReadLcf(), and Primitive< std::string >::ReadLcf().
Here is the call graph for this function:
Here is the caller graph for this function:Moves the read pointer to a different position in the stream.
| pos | new position. |
| mode | seek mode. |
Definition at line 178 of file reader_lcf.cpp.
References FromCurrent, FromEnd, FromStart, and stream.
Referenced by RawStruct< std::vector< RPG::EventCommand > >::ReadLcf(), Primitive< int >::ReadLcf(), and Skip().
Here is the caller graph for this function:
|
static |
Sets the error message of the Reader. This is not used by the Reader directly but by the classes that are using the Reader.
| fmt | error message. |
Definition at line 234 of file reader_lcf.cpp.
References error_str.
Referenced by LMU_Reader::Load(), LMT_Reader::Load(), LSD_Reader::Load(), LDB_Reader::Load(), LMU_Reader::LoadXml(), LMT_Reader::LoadXml(), LSD_Reader::LoadXml(), LDB_Reader::LoadXml(), LMU_Reader::Save(), LMT_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), LMU_Reader::SaveXml(), LMT_Reader::SaveXml(), LSD_Reader::SaveXml(), and LDB_Reader::SaveXml().
Here is the caller graph for this function:| void LcfReader::Skip | ( | const struct LcfReader::Chunk & | chunk_info | ) |
Skips a chunk (seeks chunk_info.length bytes from the current stream position). In debug builds, dumps the content of the skipped chunk to stderr.
| chunk_info | chunk that will be skipped. |
Definition at line 229 of file reader_lcf.cpp.
References FromCurrent, LcfReader::Chunk::length, and Seek().
Referenced by Struct< S >::ReadLcf().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Converts a 16bit signed integer to/from little-endian.
| us | integer to convert. |
Definition at line 294 of file reader_lcf.cpp.
|
staticprivate |
Converts a 16bit unsigned integer to/from little-endian.
| us | integer to convert. |
Definition at line 289 of file reader_lcf.cpp.
|
staticprivate |
Converts a 32bit unsigned integer to/from little-endian.
| ui | integer to convert. |
Definition at line 290 of file reader_lcf.cpp.
|
staticprivate |
Converts a double to/from little-endian.
| d | double to convert. |
Definition at line 291 of file reader_lcf.cpp.
| uint32_t LcfReader::Tell | ( | ) |
Returns the current position of the read pointer in the stream.
Definition at line 194 of file reader_lcf.cpp.
References stream.
Referenced by RawStruct< std::vector< RPG::MoveCommand > >::ReadLcf(), RawStruct< std::vector< RPG::EventCommand > >::ReadLcf(), Primitive< int >::ReadLcf(), and Struct< S >::ReadLcf().
Here is the caller graph for this function:| bool LcfReader::Ungetch | ( | uint8_t | ch | ) |
Puts a character (ch) back into the stream. This should usually be the last read one.
| ch | char that will be readded to the stream. |
Definition at line 198 of file reader_lcf.cpp.
References stream.
Referenced by RawStruct< std::vector< RPG::EventCommand > >::ReadLcf().
Here is the caller graph for this function:
|
private |
|
staticprivate |
Contains the last set error.
Definition at line 235 of file reader_lcf.h.
Referenced by GetError(), and SetError().
|
private |
Name of the file that is associated with the stream.
Definition at line 229 of file reader_lcf.h.
|
private |