10#ifndef LCF_READER_STRUCT_H
11#define LCF_READER_STRUCT_H
23#include "lcf/dbstring.h"
24#include "lcf/reader_lcf.h"
25#include "lcf/writer_lcf.h"
26#include "lcf/reader_xml.h"
27#include "lcf/writer_xml.h"
28#include "lcf/rpg/eventpagecondition.h"
29#include "lcf/rpg/trooppagecondition.h"
30#include "lcf/rpg/terrain.h"
31#include "lcf/rpg/equipment.h"
32#include "lcf/rpg/parameters.h"
33#include "lcf/rpg/eventcommand.h"
34#include "lcf/rpg/movecommand.h"
35#include "lcf/rpg/treemap.h"
36#include "lcf/rpg/rect.h"
37#include "lcf/rpg/savepicture.h"
38#include "lcf/rpg/terms.h"
39#include "lcf/rpg/saveeasyrpgtext.h"
40#include "lcf/rpg/saveeasyrpgwindow.h"
192#ifdef LCF_DEBUG_TRACE
198#ifdef LCF_DEBUG_TRACE
199 printf(
"Invalid %s at %X\n",
typeid(T).name(),
stream.Tell());
201 stream.Seek(
dif, LcfReader::FromCurrent);
214 XmlReader::Read(ref,
data);
217#ifdef LCF_DEBUG_TRACE
218 template <
typename U>
220 std::cout << ref <<
'\n';
222 static void DebugPrint(int8_t ref) {
223 std::cout << (int)ref <<
'\n';
225 static void DebugPrint(uint8_t ref) {
226 std::cout << (int)ref <<
'\n';
238#ifdef LCF_DEBUG_TRACE
239 typename std::vector<T>::iterator
it;
241 for (
it = ref.begin();
it != ref.end(); ++
it) {
242 printf(
"%d, ",
static_cast<int>(*
it));
257 XmlReader::Read(ref,
data);
269#ifdef LCF_DEBUG_TRACE
274#ifdef LCF_DEBUG_TRACE
285 return LcfReader::IntSize(ref);
291 XmlReader::Read(ref,
data);
302#ifdef LCF_DEBUG_TRACE
303 printf(
" %s\n", ref.c_str());
310 return stream.Decode(ref).size();
316 XmlReader::Read(ref,
data);
327#ifdef LCF_DEBUG_TRACE
330 print(
"%d",
static_cast<int>(
b));
346 XmlReader::Read(ref,
data);
398 if (std::is_same<S,rpg::Terms>::value &&
db_is2k3 && (
id == 0x3 ||
id == 0x1)) {
413template <
class S,
class T>
449template <
typename S,
typename T>
501template <
class S,
class T>
515 return LcfReader::IntSize(
size);
538template <
class S,
class T>
544 int size = (obj.*(this->
ref)).size();
548 int size = (obj.*(this->
ref)).size();
549 return LcfReader::IntSize(
size);
572template <
class S,
bool T>
579 obj.ID =
stream.ReadInt();
585 return LcfReader::IntSize(obj.ID);
588 stream.BeginElement(name, obj.ID);
604 stream.BeginElement(name);
697 static void ParseXml(std::vector<T>& ,
const std::string& ) {
711 static constexpr size_t num_flags = std::tuple_size<
decltype(S::flags)>::value;
712 static const std::array<const char* const, num_flags>
flag_names;
716 static const char*
tag(
int idx);
717 static int idx(
const char*
tag);
733 for (
size_t i = 0;
i < flag_names.size(); ++
i) {
734 if (std::strcmp(flag_names[
i], tag) == 0) {
776 stream.Error(
"Expecting %s but got %s", this->name,
name);
796 stream.Error(
"Expecting %s but got %s", this->name,
name);
static void BeginXml(S &obj, XmlReader &stream)
static const std::array< const char *const, num_flags > flag_names
static const std::array< bool, num_flags > flags_is2k3
static void ReadLcf(S &obj, LcfReader &stream, uint32_t length)
static void WriteXml(const S &obj, XmlWriter &stream)
static int idx(const char *tag)
static constexpr size_t num_flags
static int LcfSize(const S &obj, LcfWriter &stream)
static const char * tag(int idx)
static void WriteLcf(const S &obj, LcfWriter &stream)
static const char *const name
void StartElement(XmlReader &stream, const char *name, const char **)
RootXmlHandler(S &ref, const char *const name)
static void BeginXml(S &obj, XmlReader &stream)
static int LcfSize(const S &obj, LcfWriter &stream)
static void MakeFieldMap()
static const Field< S > * fields[]
static void WriteXml(const S &obj, XmlWriter &stream)
IDReaderT< S, IDChecker< S >::value > IDReader
std::map< const char *const, const Field< S > *, StringComparator > tag_map_type
static tag_map_type tag_map
static field_map_type field_map
static void WriteLcf(const S &obj, LcfWriter &stream)
std::map< int, const Field< S > * > field_map_type
static void ReadLcf(S &obj, LcfReader &stream)
static const char *const name
WrapperXmlHandler(const char *const name, XmlHandler *handler)
void StartElement(XmlReader &stream, const char *name, const char **)
int LcfSize(const S &obj, LcfWriter &) const
void WriteLcf(const S &obj, LcfWriter &stream) const
int LcfSize(const S &obj, LcfWriter &stream) const
bool IsDefault(const S &a, const S &b, bool is2k3) const
int LcfSize(const S &, LcfWriter &) const
void WriteXml(const S &, XmlWriter &) const
void ParseXml(S &, const std::string &) const
void ReadLcf(S &, LcfReader &, uint32_t) const
void BeginXml(S &, XmlReader &) const
void WriteLcf(const S &, LcfWriter &) const
bool IsDefault(const S &, const S &, bool) const
virtual void ParseXml(S &obj, const std::string &data) const =0
bool isPresentIfDefault(bool db_is2k3) const
Field(int id, const char *name, bool present_if_default, bool is2k3)
virtual void WriteLcf(const S &obj, LcfWriter &stream) const =0
virtual void BeginXml(S &obj, XmlReader &stream) const =0
virtual bool IsDefault(const S &obj, const S &ref, bool is2k3) const =0
virtual void WriteXml(const S &obj, XmlWriter &stream) const =0
virtual void ReadLcf(S &obj, LcfReader &stream, uint32_t length) const =0
virtual int LcfSize(const S &obj, LcfWriter &stream) const =0
static yes check(type_check< int C::*, &C::ID > *)
static void WriteID(const S &, LcfWriter &)
static void ReadIDXml(S &, const char **)
static void WriteXmlTag(const S &, const std::string &name, XmlWriter &stream)
static int IDSize(const S &)
static void ReadID(S &, LcfReader &)
static void WriteID(const S &obj, LcfWriter &stream)
static void ReadID(S &obj, LcfReader &stream)
static void WriteXmlTag(const S &obj, const std::string &name, XmlWriter &stream)
static int IDSize(const S &obj)
static void ReadIDXml(S &obj, const char **atts)
static const uint32_t value
static void ReadLcf(DBBitArray &ref, LcfReader &stream, uint32_t length)
static void ParseXml(DBBitArray &ref, const std::string &data)
static void WriteLcf(const DBBitArray &ref, LcfWriter &stream)
static int LcfSize(const DBBitArray &ref, LcfWriter &stream)
static void WriteXml(const DBBitArray &ref, XmlWriter &stream)
static int LcfSize(const int32_t &ref, LcfWriter &)
static void WriteLcf(const int32_t &ref, LcfWriter &stream)
static void ParseXml(int32_t &ref, const std::string &data)
static void ReadLcf(int32_t &ref, LcfReader &stream, uint32_t length)
static void WriteXml(const int32_t &ref, XmlWriter &stream)
static void WriteXml(const std::string &ref, XmlWriter &stream)
static void ReadLcf(std::string &ref, LcfReader &stream, uint32_t length)
static int LcfSize(const std::string &ref, LcfWriter &stream)
static void WriteLcf(const std::string &ref, LcfWriter &stream)
static void ParseXml(std::string &ref, const std::string &data)
static int LcfSize(const std::vector< T > &ref, LcfWriter &)
static void ParseXml(std::vector< T > &ref, const std::string &data)
static void WriteLcf(const std::vector< T > &ref, LcfWriter &stream)
static void WriteXml(const std::vector< T > &ref, XmlWriter &stream)
static void ReadLcf(std::vector< T > &ref, LcfReader &stream, uint32_t length)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static void WriteLcf(const T &ref, LcfWriter &stream)
static int LcfSize(const T &, LcfWriter &)
static void ParseXml(T &ref, const std::string &data)
static void WriteXml(const T &ref, XmlWriter &stream)
static void WriteXml(const T &ref, XmlWriter &stream)
static void BeginXml(T &ref, XmlReader &stream)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static void WriteLcf(const T &ref, LcfWriter &stream)
static int LcfSize(const T &ref, LcfWriter &stream)
void BeginXml(S &, XmlReader &) const
SizeField(const T S::*ref, int id, bool present_if_default, bool is2k3)
void WriteXml(const S &, XmlWriter &) const
bool IsDefault(const S &a, const S &b, bool) const
void ReadLcf(S &, LcfReader &stream, uint32_t length) const
void ParseXml(S &, const std::string &) const
void WriteLcf(const S &obj, LcfWriter &stream) const
int LcfSize(const S &obj, LcfWriter &stream) const
bool operator()(const char *const &lhs, const char *const &rhs) const
static const Category::Index value
static void WriteLcf(const T &ref, LcfWriter &stream)
static int LcfSize(const T &ref, LcfWriter &stream)
static void ParseXml(T &, const std::string &)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static void BeginXml(T &ref, XmlReader &stream)
static void WriteXml(const T &ref, XmlWriter &stream)
static int LcfSize(const T &ref, LcfWriter &stream)
static void BeginXml(T &, XmlReader &)
static void WriteXml(const T &ref, XmlWriter &stream)
static void WriteLcf(const T &ref, LcfWriter &stream)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static void ParseXml(T &ref, const std::string &data)
static void WriteXml(const T &ref, XmlWriter &stream)
static void ParseXml(T &, const std::string &)
static int LcfSize(const T &ref, LcfWriter &stream)
static void WriteLcf(const T &ref, LcfWriter &stream)
static void BeginXml(T &ref, XmlReader &stream)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static void ParseXml(T &, const std::string &)
static void WriteXml(const T &ref, XmlWriter &stream)
static void WriteLcf(const T &ref, LcfWriter &stream)
static void BeginXml(T &ref, XmlReader &stream)
static int LcfSize(const T &ref, LcfWriter &stream)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t)
static void BeginXml(T &, XmlReader &)
static int LcfSize(const T &, LcfWriter &)
static void WriteLcf(const T &, LcfWriter &)
static void ReadLcf(T &, LcfReader &stream, uint32_t length)
static void ParseXml(T &, const std::string &)
static void WriteXml(const T &, XmlWriter &)
static void WriteLcf(const std::vector< T > &ref, LcfWriter &stream)
static void BeginXml(std::vector< T > &ref, XmlReader &stream)
static void WriteXml(const std::vector< T > &ref, XmlWriter &stream)
static void ReadLcf(std::vector< T > &ref, LcfReader &stream, uint32_t)
static int LcfSize(const std::vector< T > &ref, LcfWriter &stream)
static void ParseXml(std::vector< T > &, const std::string &)
void BeginXml(S &obj, XmlReader &stream) const
TypedField(T S::*ref, int id, const char *name, bool present_if_default, bool is2k3)
void WriteLcf(const S &obj, LcfWriter &stream) const
void ReadLcf(S &obj, LcfReader &stream, uint32_t length) const
void WriteXml(const S &obj, XmlWriter &stream) const
bool IsDefault(const S &a, const S &b, bool) const
int LcfSize(const S &obj, LcfWriter &stream) const
void ParseXml(S &obj, const std::string &data) const