|
liblcf
|
#include <reader_lcf.h>
Collaboration diagram for LcfReader:Classes | |
| struct | Chunk |
Public Types | |
| enum | SeekMode { FromStart , FromEnd , FromCurrent } |
Public Member Functions | |
| LcfReader (std::istream &filestream, std::string encoding="") | |
| ~LcfReader () | |
| 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 () |
| int | Peek () |
| void | Skip (const struct LcfReader::Chunk &chunk_info) |
| void | Encode (std::string &str) |
| std::vector< int32_t > & | IntBuffer () |
| template<> | |
| void | Read (bool &ref) |
| template<> | |
| void | Read (int8_t &ref) |
| template<> | |
| void | Read (uint8_t &ref) |
| template<> | |
| void | Read (int16_t &ref) |
| template<> | |
| void | Read (uint32_t &ref) |
| template<> | |
| void | Read (int32_t &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< int32_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 (int32_t &us) |
| static void | SwapByteOrder (uint32_t &ui) |
| static void | SwapByteOrder (double &d) |
Private Attributes | |
| std::istream & | stream |
| int64_t | offset |
| Encoder | encoder |
| std::vector< int32_t > | buffer |
Static Private Attributes | |
| static std::string | error_str |
LcfReader class.
Definition at line 35 of file reader_lcf.h.
| enum LcfReader::SeekMode |
Defines the Seek start position for the Seek function.
| Enumerator | |
|---|---|
| FromStart | |
| FromEnd | |
| FromCurrent | |
Definition at line 82 of file reader_lcf.h.
| LcfReader::LcfReader | ( | std::istream & | filestream, |
| std::string | encoding = "" |
||
| ) |
Constructs a new File Reader.
| filestream | already opened filestream. |
| encoding | name of the encoding. |
Definition at line 20 of file reader_lcf.cpp.
References offset.
| LcfReader::~LcfReader | ( | ) |
Destructor. Closes the opened file.
Definition at line 27 of file reader_lcf.cpp.
| void LcfReader::Encode | ( | std::string & | str | ) |
Encodes a string to UTF-8 using the set encoding in the reader constructor.
| str | to convert from encoding to UTF-8 |
Definition at line 295 of file reader_lcf.cpp.
References Encoder::Encode(), and encoder.
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 196 of file reader_lcf.cpp.
References stream.
Referenced by Read0(), Struct< S >::ReadLcf(), and RawStruct< std::vector< RPG::EventCommand > >::ReadLcf().
Here is the caller graph for this function:
|
static |
Returns the last set error.
Definition at line 291 of file reader_lcf.cpp.
References error_str.
|
inline |
Definition at line 267 of file reader_lcf.h.
References buffer.
Referenced by RawStruct< RPG::EventCommand >::ReadLcf().
Here is the caller graph for this function:
|
static |
Calculates the size of a compressed integer.
| x | the integer. |
Definition at line 299 of file reader_lcf.cpp.
Referenced by IDReaderT< S, true >::IDSize(), Primitive< int32_t >::LcfSize(), RawStruct< RPG::EventCommand >::LcfSize(), RawStruct< RPG::MoveCommand >::LcfSize(), CountField< S, T >::LcfSize(), Struct< S >::LcfSize(), and SizeField< S, T >::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 192 of file reader_lcf.cpp.
References encoder, Encoder::IsOk(), and stream.
Referenced by LDB_Reader::Load(), LMT_Reader::Load(), LMU_Reader::Load(), and LSD_Reader::Load().
Here is the call graph for this function:
Here is the caller graph for this function:| int LcfReader::Peek | ( | ) |
Returns the next char in the stream and doesn't advance the position.
Definition at line 239 of file reader_lcf.cpp.
References stream.
Referenced by RawStruct< std::vector< RPG::EventCommand > >::ReadLcf().
Here is the caller graph for this function:| void LcfReader::Read | ( | bool & | ref | ) |
Definition at line 58 of file reader_lcf.cpp.
References ReadInt().
Here is the call graph for this function:| void LcfReader::Read | ( | double & | ref | ) |
Definition at line 111 of file reader_lcf.cpp.
References Read(), and SwapByteOrder().
Here is the call graph for this function:| void LcfReader::Read | ( | int16_t & | ref | ) |
Definition at line 73 of file reader_lcf.cpp.
References Read(), and SwapByteOrder().
Here is the call graph for this function:| void LcfReader::Read | ( | int32_t & | ref | ) |
Definition at line 106 of file reader_lcf.cpp.
References ReadInt().
Here is the call graph for this function:| void LcfReader::Read | ( | int8_t & | ref | ) |
Definition at line 63 of file reader_lcf.cpp.
References Read().
Here is the call graph for this function:| void LcfReader::Read | ( | std::vector< bool > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 117 of file reader_lcf.cpp.
References buffer, and Read().
Here is the call graph for this function:| void LcfReader::Read | ( | std::vector< int16_t > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 139 of file reader_lcf.cpp.
References buffer, FromCurrent, Data::items, Read(), Seek(), and SwapByteOrder().
Here is the call graph for this function:| void LcfReader::Read | ( | std::vector< int32_t > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 155 of file reader_lcf.cpp.
References buffer, FromCurrent, Data::items, Read(), Seek(), and SwapByteOrder().
Here is the call graph for this function:| 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< uint32_t > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 171 of file reader_lcf.cpp.
References buffer, FromCurrent, Data::items, Read(), Seek(), and SwapByteOrder().
Here is the call graph for this function:| void LcfReader::Read | ( | std::vector< uint8_t > & | buffer, |
| size_t | size | ||
| ) |
Definition at line 128 of file reader_lcf.cpp.
References buffer, and Read().
Here is the call graph for this function:| void LcfReader::Read | ( | T & | ref | ) |
Reads a primitive type.
| ref | reference to store result. |
| void LcfReader::Read | ( | uint32_t & | ref | ) |
Definition at line 79 of file reader_lcf.cpp.
References Read(), and SwapByteOrder().
Here is the call graph for this function:| void LcfReader::Read | ( | uint8_t & | ref | ) |
Definition at line 68 of file reader_lcf.cpp.
References Read().
Here is the call graph for this function:| 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 47 of file reader_lcf.cpp.
References Read0(), and Tell().
Referenced by Read(), RawStruct< RPG::Equipment >::ReadLcf(), RawStruct< RPG::EventCommand >::ReadLcf(), RawStruct< RPG::MoveCommand >::ReadLcf(), RawStruct< RPG::Parameters >::ReadLcf(), RawStruct< RPG::Rect >::ReadLcf(), Flags< S >::ReadLcf(), RawStruct< std::vector< RPG::EventCommand > >::ReadLcf(), Primitive< std::vector< T > >::ReadLcf(), Primitive< T >::ReadLcf(), and ReadString().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 30 of file reader_lcf.cpp.
References Eof(), offset, and stream.
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 84 of file reader_lcf.cpp.
References Read0(), and Tell().
Referenced by LDB_Reader::Load(), LMT_Reader::Load(), LMU_Reader::Load(), LSD_Reader::Load(), Read(), IDReaderT< S, true >::ReadID(), Primitive< int32_t >::ReadLcf(), RawStruct< RPG::EventCommand >::ReadLcf(), RawStruct< RPG::MoveCommand >::ReadLcf(), RawStruct< RPG::TreeMap >::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 186 of file reader_lcf.cpp.
References Encode(), and Read().
Referenced by LDB_Reader::Load(), LMT_Reader::Load(), LMU_Reader::Load(), LSD_Reader::Load(), RawStruct< RPG::EventCommand >::ReadLcf(), RawStruct< RPG::MoveCommand >::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 200 of file reader_lcf.cpp.
References FromCurrent, FromEnd, FromStart, offset, and stream.
Referenced by Read(), Primitive< int32_t >::ReadLcf(), Struct< S >::ReadLcf(), RawStruct< std::vector< RPG::EventCommand > >::ReadLcf(), Primitive< T >::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 278 of file reader_lcf.cpp.
References error_str.
Referenced by LDB_Reader::Load(), LMT_Reader::Load(), LMU_Reader::Load(), LSD_Reader::Load(), LDB_Reader::LoadXml(), LMT_Reader::LoadXml(), LMU_Reader::LoadXml(), LSD_Reader::LoadXml(), LMU_Reader::Save(), LSD_Reader::Save(), LDB_Reader::Save(), LMT_Reader::Save(), LDB_Reader::SaveXml(), LMT_Reader::SaveXml(), LMU_Reader::SaveXml(), and LSD_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 273 of file reader_lcf.cpp.
References FromCurrent, LcfReader::Chunk::length, and Seek().
Referenced by RawStruct< RPG::Equipment >::ReadLcf(), and Struct< S >::ReadLcf().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Converts a double to/from little-endian.
| d | double to convert. |
Definition at line 335 of file reader_lcf.cpp.
|
staticprivate |
Converts a 16bit signed integer to/from little-endian.
| us | integer to convert. |
Definition at line 338 of file reader_lcf.cpp.
Referenced by Read(), and SwapByteOrder().
Here is the caller graph for this function:
|
staticprivate |
Converts a 32bit signed integer to/from little-endian.
| us | integer to convert. |
Definition at line 343 of file reader_lcf.cpp.
References SwapByteOrder().
Here is the call graph for this function:
|
staticprivate |
Converts a 16bit unsigned integer to/from little-endian.
| us | integer to convert. |
Definition at line 333 of file reader_lcf.cpp.
|
staticprivate |
Converts a 32bit unsigned integer to/from little-endian.
| ui | integer to convert. |
Definition at line 334 of file reader_lcf.cpp.
| uint32_t LcfReader::Tell | ( | ) |
Returns the current position of the read pointer in the stream.
Definition at line 228 of file reader_lcf.cpp.
References offset.
Referenced by Read(), ReadInt(), Primitive< int32_t >::ReadLcf(), Struct< S >::ReadLcf(), RawStruct< std::vector< RPG::EventCommand > >::ReadLcf(), RawStruct< std::vector< RPG::MoveCommand > >::ReadLcf(), and Primitive< T >::ReadLcf().
Here is the caller graph for this function:
|
private |
A temporary buffer to be used in parsing
Definition at line 229 of file reader_lcf.h.
Referenced by IntBuffer(), and Read().
|
private |
The internal Encoder
Definition at line 227 of file reader_lcf.h.
|
staticprivate |
Contains the last set error.
Definition at line 225 of file reader_lcf.h.
Referenced by GetError(), and SetError().
|
private |
Cached file stream offset
Definition at line 223 of file reader_lcf.h.
Referenced by LcfReader(), Read0(), Seek(), and Tell().
|
private |