liblcf
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
reader_struct.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 liblcf authors
3  * This file is released under the MIT License
4  * http://opensource.org/licenses/MIT
5  */
6 
7 #ifndef LCF_READER_STRUCT_H
8 #define LCF_READER_STRUCT_H
9 
10 #include <string>
11 #include <vector>
12 #include <map>
13 #include <memory>
14 #include <cstring>
15 #include <cstdlib>
16 #include <boost/preprocessor/cat.hpp>
17 #include <boost/preprocessor/stringize.hpp>
18 #include "reader_lcf.h"
19 #include "writer_lcf.h"
20 #include "reader_xml.h"
21 #include "writer_xml.h"
22 #include "rpg_eventpagecondition.h"
23 #include "rpg_trooppagecondition.h"
24 #include "rpg_terrain.h"
25 #include "rpg_equipment.h"
26 #include "rpg_parameters.h"
27 #include "rpg_eventcommand.h"
28 #include "rpg_movecommand.h"
29 #include "rpg_treemap.h"
30 #include "rpg_rect.h"
31 
32 // Forward declarations
33 
34 template <class T>
35 class Struct;
36 
37 // Type categories
38 
39 struct Category {
40  enum Index {
45  };
46 };
47 
48 template <class T>
49 struct TypeCategory {
51 };
52 
53 template <> struct TypeCategory<RPG::TroopPageCondition::Flags> { static const Category::Index value = Category::Flags; };
54 template <> struct TypeCategory<RPG::EventPageCondition::Flags> { static const Category::Index value = Category::Flags; };
55 template <> struct TypeCategory<RPG::Terrain::Flags> { static const Category::Index value = Category::Flags; };
56 
57 template <> struct TypeCategory<RPG::Equipment> { static const Category::Index value = Category::RawStruct; };
58 template <> struct TypeCategory<RPG::EventCommand> { static const Category::Index value = Category::RawStruct; };
59 template <> struct TypeCategory<RPG::MoveCommand> { static const Category::Index value = Category::RawStruct; };
60 template <> struct TypeCategory<RPG::Parameters> { static const Category::Index value = Category::RawStruct; };
61 template <> struct TypeCategory<RPG::TreeMap> { static const Category::Index value = Category::RawStruct; };
62 template <> struct TypeCategory<RPG::Rect> { static const Category::Index value = Category::RawStruct; };
63 
64 template <> struct TypeCategory<uint8_t> { static const Category::Index value = Category::Primitive; };
65 template <> struct TypeCategory<int16_t> { static const Category::Index value = Category::Primitive; };
66 template <> struct TypeCategory<uint32_t> { static const Category::Index value = Category::Primitive; };
67 template <> struct TypeCategory<int> { static const Category::Index value = Category::Primitive; };
68 template <> struct TypeCategory<bool> { static const Category::Index value = Category::Primitive; };
69 template <> struct TypeCategory<double> { static const Category::Index value = Category::Primitive; };
70 template <> struct TypeCategory<std::string> { static const Category::Index value = Category::Primitive; };
71 
72 template <class T>
73 struct TypeCategory<std::vector<T> > {
75 };
76 
80 template <class T, Category::Index cat = TypeCategory<T>::value>
81 struct TypeReader {};
82 
86 template <class T>
87 struct RawStruct {
88  static void ReadLcf(T& ref, LcfReader& stream, uint32_t length);
89  static void WriteLcf(const T& ref, LcfWriter& stream);
90  static int LcfSize(const T& ref, LcfWriter& stream);
91  static void WriteXml(const T& ref, XmlWriter& stream);
92  static void BeginXml(T& ref, XmlReader& stream);
93 };
94 
95 template <class T>
97  static void ReadLcf(T& ref, LcfReader& stream, uint32_t length) {
98  RawStruct<T>::ReadLcf(ref, stream, length);
99  }
100  static void WriteLcf(const T& ref, LcfWriter& stream) {
101  RawStruct<T>::WriteLcf(ref, stream);
102  }
103  static int LcfSize(const T& ref, LcfWriter& stream) {
104  return RawStruct<T>::LcfSize(ref, stream);
105  }
106  static void WriteXml(const T& ref, XmlWriter& stream) {
107  RawStruct<T>::WriteXml(ref, stream);
108  }
109  static void BeginXml(T& ref, XmlReader& stream) {
110  RawStruct<T>::BeginXml(ref, stream);
111  }
112  static void ParseXml(T& /* ref */, const std::string& /* data */) {
113  //no-op
114  }
115 };
116 
120 template <class T>
121 struct LcfSizeT {
122  static const uint32_t value = sizeof(T);
123 };
124 
128 template <>
129 struct LcfSizeT<bool> {
130  static const uint32_t value = 1;
131 };
132 
136 template <class T>
137 struct Primitive {
138  static void ReadLcf(T& ref, LcfReader& stream, uint32_t length) {
139  assert(length == LcfSizeT<T>::value);
140 
141  stream.Read(ref);
142  }
143  static void WriteLcf(const T& ref, LcfWriter& stream) {
144  stream.Write(ref);
145  }
146  static int LcfSize(const T& /* ref */, LcfWriter& /* stream */) {
147  return LcfSizeT<T>::value;
148  }
149  static void WriteXml(const T& ref, XmlWriter& stream) {
150  stream.Write(ref);
151  }
152  static void ParseXml(T& ref, const std::string& data) {
153  XmlReader::Read(ref, data);
154  }
155 };
156 
160 template <class T>
161 struct Primitive<std::vector<T> > {
162  static void ReadLcf(std::vector<T>& ref, LcfReader& stream, uint32_t length) {
163  stream.Read(ref, length);
164 #ifdef LCF_DEBUG_TRACE
165  typename std::vector<T>::iterator it;
166  printf(" ");
167  for (it = ref.begin(); it != ref.end(); ++it) {
168  printf("%d, ", *it);
169  }
170  printf("\n");
171 #endif
172  }
173  static void WriteLcf(const std::vector<T>& ref, LcfWriter& stream) {
174  stream.Write(ref);
175  }
176  static int LcfSize(const std::vector<T>& ref, LcfWriter& /* stream */) {
177  return LcfSizeT<T>::value * ref.size();
178  }
179  static void WriteXml(const std::vector<T>& ref, XmlWriter& stream) {
180  stream.Write(ref);
181  }
182  static void ParseXml(std::vector<T>& ref, const std::string& data) {
183  XmlReader::Read(ref, data);
184  }
185 };
186 
190 template <>
191 struct Primitive<int> {
192  static void ReadLcf(int& ref, LcfReader& stream, uint32_t length) {
193  if (length >= 1 || length <= 5) {
194  ref = stream.ReadInt();
195 #ifdef LCF_DEBUG_TRACE
196  printf(" %d\n", ref);
197 #endif
198  } else {
199  ref = 0;
200 #ifdef LCF_DEBUG_TRACE
201  printf("Invalid integer at %s\n", stream->Tell());
202 #endif
203  stream.Seek(length, LcfReader::FromCurrent);
204  }
205 
206  }
207  static void WriteLcf(const int& ref, LcfWriter& stream) {
208  stream.WriteInt(ref);
209  }
210  static int LcfSize(const int& ref, LcfWriter& /* stream */) {
211  return LcfReader::IntSize(ref);
212  }
213  static void WriteXml(const int& ref, XmlWriter& stream) {
214  stream.WriteInt(ref);
215  }
216  static void ParseXml(int& ref, const std::string& data) {
217  XmlReader::Read(ref, data);
218  }
219 };
220 
224 template <>
225 struct Primitive<std::string> {
226  static void ReadLcf(std::string& ref, LcfReader& stream, uint32_t length) {
227  stream.ReadString(ref, length);
228 #ifdef LCF_DEBUG_TRACE
229  printf(" %s\n", ref.c_str());
230 #endif
231  }
232  static void WriteLcf(const std::string& ref, LcfWriter& stream) {
233  stream.Write(ref);
234  }
235  static int LcfSize(const std::string& ref, LcfWriter& stream) {
236  return stream.Decode(ref).size();
237  }
238  static void WriteXml(const std::string& ref, XmlWriter& stream) {
239  stream.Write(ref);
240  }
241  static void ParseXml(std::string& ref, const std::string& data) {
242  XmlReader::Read(ref, data);
243  }
244 };
245 
249 template <class T>
251  static void ReadLcf(T& ref, LcfReader& stream, uint32_t length) {
252  Primitive<T>::ReadLcf(ref, stream, length);
253  }
254  static void WriteLcf(const T& ref, LcfWriter& stream) {
255  Primitive<T>::WriteLcf(ref, stream);
256  }
257  static int LcfSize(const T& ref, LcfWriter& stream) {
258  return Primitive<T>::LcfSize(ref, stream);
259  }
260  static void WriteXml(const T& ref, XmlWriter& stream) {
261  Primitive<T>::WriteXml(ref, stream);
262  }
263  static void BeginXml(T& /* ref */, XmlReader& /* stream */) {
264  // no-op
265  }
266  static void ParseXml(T& ref, const std::string& data) {
267  Primitive<T>::ParseXml(ref, data);
268  }
269 };
270 
274 template <class S, class T>
275 struct FieldReader {
276  static void ReadLcf(S& obj, T S::*ref, LcfReader& stream, uint32_t length) {
277  TypeReader<T>::ReadLcf(obj.*ref, stream, length);
278  }
279  static void WriteLcf(const S& obj, const T S::*ref, LcfWriter& stream) {
280  TypeReader<T>::WriteLcf(obj.*ref, stream);
281  }
282  static int LcfSize(const S& obj, const T S::*ref, LcfWriter& stream) {
283  return TypeReader<T>::LcfSize(obj.*ref, stream);
284  }
285  static void WriteXml(const S& obj, const T S::*ref, XmlWriter& stream) {
286  TypeReader<T>::WriteXml(obj.*ref, stream);
287  }
288  static void BeginXml(S& obj, T S::*ref, XmlReader& stream) {
289  TypeReader<T>::BeginXml(obj.*ref, stream);
290  }
291  static void ParseXml(S& obj, T S::*ref, const std::string& data) {
292  TypeReader<T>::ParseXml(obj.*ref, data);
293  }
294 };
295 
299 template <class S>
300 struct Field {
301  typedef S struct_type;
302 
303  int id;
304  const char* const name;
305 
306  virtual void ReadLcf(S& obj, LcfReader& stream, uint32_t length) const = 0;
307  virtual void WriteLcf(const S& obj, LcfWriter& stream) const = 0;
308  virtual int LcfSize(const S& obj, LcfWriter& stream) const = 0;
309  virtual bool IsDefault(const S& obj, const S& ref) const = 0;
310  virtual void WriteXml(const S& obj, XmlWriter& stream) const = 0;
311  virtual void BeginXml(S& obj, XmlReader& stream) const = 0;
312  virtual void ParseXml(S& obj, const std::string& data) const = 0;
313 
314  Field(int id, const char* name) :
315  id(id), name(name) {}
316 };
317 
318 // Equivalence traits
319 
320 template <class T>
321 struct Class_Test {
322  typedef char yes;
323  typedef int no;
324 
325  template <class C>
326  static yes& check(void(C::*)(void));
327  template <class C>
328  static no& check(...);
329 
330  static const bool value = sizeof(check<T>(0)) == sizeof(yes);
331 };
332 
333 template <class T>
334 struct Compare_Test {
335  static const bool value = !Class_Test<T>::value;
336 };
337 
338 template <class T>
339 struct Compare_Test<std::vector<T> > {
340  static const bool value = Compare_Test<T>::value;
341 };
342 
343 template <>
344 struct Compare_Test<std::string> {
345  static const bool value = true;
346 };
347 
348 template <class T, bool comparable>
350 
351 template <class T>
352 struct Compare_Traits_Impl<T, true> {
353  static bool IsEqual(const T& a, const T& b) {
354  return a == b;
355  }
356 };
357 
358 template <class T>
359 struct Compare_Traits_Impl<T, false> {
360  static bool IsEqual(const T& /* a */, const T& /* b */) {
361  return false;
362  }
363 };
364 
365 template <class T>
366 struct Compare_Traits_Impl<std::vector<T>, false> {
367  static bool IsEqual(const std::vector<T>& a, const std::vector<T>& b) {
368  return a.empty() && b.empty();
369  }
370 };
371 
372 template <class T>
375  static bool IsEqual(const T& a, const T& b) {
376  return impl_type::IsEqual(a, b);
377  }
378 };
379 
383 template <class S, class T>
384 struct TypedField : public Field<S> {
385  T S::*ref;
386 
387  void ReadLcf(S& obj, LcfReader& stream, uint32_t length) const {
388  FieldReader<S, T>::ReadLcf(obj, ref, stream, length);
389  }
390  void WriteLcf(const S& obj, LcfWriter& stream) const {
391  FieldReader<S, T>::WriteLcf(obj, ref, stream);
392  }
393  int LcfSize(const S& obj, LcfWriter& stream) const {
394  return FieldReader<S, T>::LcfSize(obj, ref, stream);
395  }
396  void WriteXml(const S& obj, XmlWriter& stream) const {
397  stream.BeginElement(this->name);
398  FieldReader<S, T>::WriteXml(obj, ref, stream);
399  stream.EndElement(this->name);
400  }
401  void BeginXml(S& obj, XmlReader& stream) const {
402  FieldReader<S, T>::BeginXml(obj, ref, stream);
403  }
404  void ParseXml(S& obj, const std::string& data) const {
405  FieldReader<S, T>::ParseXml(obj, ref, data);
406  }
407  bool IsDefault(const S& a, const S& b) const {
408  return Compare_Traits<T>::IsEqual(a.*ref, b.*ref);
409  }
410 
411  TypedField(T S::*ref, int id, const char* name) :
412  Field<S>(id, name), ref(ref) {}
413 };
414 
418 template <class S, class T>
419 struct SizeField : public Field<S> {
420  const std::vector<T> S::*ref;
421 
422  void ReadLcf(S& /* obj */, LcfReader& stream, uint32_t length) const {
423  int dummy;
424  TypeReader<int>::ReadLcf(dummy, stream, length);
425  }
426  void WriteLcf(const S& obj, LcfWriter& stream) const {
427  int size = TypeReader<std::vector<T> >::LcfSize(obj.*ref, stream);
428  TypeReader<int>::WriteLcf(size, stream);
429  }
430  int LcfSize(const S& obj, LcfWriter& stream) const {
431  int size = TypeReader<std::vector<T> >::LcfSize(obj.*ref, stream);
432  return LcfReader::IntSize(size);
433  }
434  void WriteXml(const S& /* obj */, XmlWriter& /* stream */) const {
435  // no-op
436  }
437  void BeginXml(S& /* obj */, XmlReader& /* stream */) const {
438  // no-op
439  }
440  void ParseXml(S& /* obj */, const std::string& /* data */) const {
441  // no-op
442  }
443  bool IsDefault(const S& a, const S& b) const {
444  return (a.*ref).empty() && (b.*ref).empty();
445  }
446 
447  SizeField(const std::vector<T> S::*ref, int id) :
448  Field<S>(id, ""), ref(ref) {}
449 };
450 
454 template <class T>
455 struct IDChecker {
456  typedef char no;
457  typedef int yes;
458 
459  template <typename U, U> struct type_check;
460  template <class C>
461  static yes check(type_check<int C::*, &C::ID> *);
462  template <class C>
463  static no check(...);
464 
465  static const bool value = sizeof(check<T>(0)) == sizeof(yes);
466 };
467 
468 // ID reader for Struct class
469 
470 template <class S, bool T>
471 struct IDReaderT {
472 };
473 
474 template <class S>
475 struct IDReaderT<S, true> {
476  static void ReadID(S& obj, LcfReader& stream) {
477  obj.ID = stream.ReadInt();
478  }
479  static void WriteID(const S& obj, LcfWriter& stream) {
480  stream.WriteInt(obj.ID);
481  }
482  static int IDSize(const S& obj) {
483  return LcfReader::IntSize(obj.ID);
484  }
485  static void WriteXmlTag(const S& obj, const std::string& name, XmlWriter& stream) {
486  stream.BeginElement(name, obj.ID);
487  }
488  static void ReadIDXml(S& obj, const char** atts) {
489  for (int i = 0; atts[i] != NULL && atts[i + 1] != NULL; i += 2) {
490  if (strcmp(atts[i], "id") == 0)
491  obj.ID = atoi(atts[i + 1]);
492  }
493  }
494 };
495 
496 template <class S>
497 struct IDReaderT<S, false> {
498  static void ReadID(S& /* obj */, LcfReader& /* stream */) {}
499  static void WriteID(const S& /* obj */, LcfWriter& /* stream */) {}
500  static int IDSize(const S& /* obj */) { return 0; }
501  static void WriteXmlTag(const S& /* obj */, const std::string& name, XmlWriter& stream) {
502  stream.BeginElement(name);
503  }
504  static void ReadIDXml(S& /* obj */, const char** /* atts */) {}
505 };
506 
508  bool operator() (const char* const& lhs, const char* const& rhs) const {
509  return strcmp(lhs, rhs) < 0;
510  }
511 };
512 
513 // Struct class template
514 
515 template <class S>
516 class Struct {
517 private:
518  typedef std::map<int, const Field<S>* > field_map_type;
519  typedef std::map<const char* const, const Field<S>*, StringComparator> tag_map_type;
521  static const Field<S>* fields[];
522  static field_map_type field_map;
523  static tag_map_type tag_map;
524  static const char* const name;
525 
526  static void MakeFieldMap();
527  static void MakeTagMap();
528 
529  template <class T> friend class StructXmlHandler;
530  template <class T> friend class StructVectorXmlHandler;
531  template <class T> friend class StructFieldXmlHandler;
532 
533 public:
534  static void ReadLcf(S& obj, LcfReader& stream);
535  static void WriteLcf(const S& obj, LcfWriter& stream);
536  static int LcfSize(const S& obj, LcfWriter& stream);
537  static void WriteXml(const S& obj, XmlWriter& stream);
538  static void BeginXml(S& obj, XmlReader& stream);
539 
540  static void ReadLcf(std::vector<S>& obj, LcfReader& stream);
541  static void WriteLcf(const std::vector<S>& obj, LcfWriter& stream);
542  static int LcfSize(const std::vector<S>& obj, LcfWriter& stream);
543  static void WriteXml(const std::vector<S>& obj, XmlWriter& stream);
544  static void BeginXml(std::vector<S>& obj, XmlReader& stream);
545 };
546 
547 template <class S>
548 std::map<int, const Field<S>* > Struct<S>::field_map;
549 
550 template <class S>
551 std::map<const char* const, const Field<S>*, StringComparator> Struct<S>::tag_map;
552 
556 template <class T>
558  static void ReadLcf(T& ref, LcfReader& stream, uint32_t /* length */) {
559  Struct<T>::ReadLcf(ref, stream);
560  }
561  static void WriteLcf(const T& ref, LcfWriter& stream) {
562  Struct<T>::WriteLcf(ref, stream);
563  }
564  static int LcfSize(const T& ref, LcfWriter& stream) {
565  return Struct<T>::LcfSize(ref, stream);
566  }
567  static void WriteXml(const T& ref, XmlWriter& stream) {
568  Struct<T>::WriteXml(ref, stream);
569  }
570  static void BeginXml(T& ref, XmlReader& stream) {
571  Struct<T>::BeginXml(ref, stream);
572  }
573  static void ParseXml(T& /* ref */, const std::string& /* data */) {
574  // no-op
575  }
576 };
577 
578 template <class T>
579 struct TypeReader<std::vector<T>, Category::Struct> {
580  static void ReadLcf(std::vector<T>& ref, LcfReader& stream, uint32_t /* length */) {
581  Struct<T>::ReadLcf(ref, stream);
582  }
583  static void WriteLcf(const std::vector<T>& ref, LcfWriter& stream) {
584  Struct<T>::WriteLcf(ref, stream);
585  }
586  static int LcfSize(const std::vector<T>& ref, LcfWriter& stream) {
587  return Struct<T>::LcfSize(ref, stream);
588  }
589  static void WriteXml(const std::vector<T>& ref, XmlWriter& stream) {
590  Struct<T>::WriteXml(ref, stream);
591  }
592  static void BeginXml(std::vector<T>& ref, XmlReader& stream) {
593  Struct<T>::BeginXml(ref, stream);
594  }
595  static void ParseXml(std::vector<T>& /* ref */, const std::string& /* data */) {
596  // no-op
597  }
598 };
599 
603 template <class S>
604 class Flags {
605 public:
606  struct Flag {
607  Flag(bool S::*ref, const char* const name) : ref(ref), name(name) {}
608  bool S::*ref;
609  const char* const name;
610  };
611 
612 private:
613  static const uint32_t max_size;
614  typedef std::map<const char* const, const Flag*, StringComparator> tag_map_type;
615  static const Flag* flags[];
616  static tag_map_type tag_map;
617  static const char* const name;
618 
619  static void MakeTagMap();
620 
621  template <class T> friend class FlagsXmlHandler;
622 
623 public:
624  static void ReadLcf(S& obj, LcfReader& stream, uint32_t length);
625  static void WriteLcf(const S& obj, LcfWriter& stream);
626  static int LcfSize(const S& obj, LcfWriter& stream);
627  static void WriteXml(const S& obj, XmlWriter& stream);
628  static void BeginXml(S& obj, XmlReader& stream);
629 };
630 
631 template <class S>
632 std::map<const char* const, const typename Flags<S>::Flag*, StringComparator> Flags<S>::tag_map;
633 
637 template <class T>
638 struct TypeReader<T, Category::Flags> {
639  static void ReadLcf(T& ref, LcfReader& stream, uint32_t length) {
640  Flags<T>::ReadLcf(ref, stream, length);
641  }
642  static void WriteLcf(const T& ref, LcfWriter& stream) {
643  Flags<T>::WriteLcf(ref, stream);
644  }
645  static int LcfSize(const T& ref, LcfWriter& stream) {
646  return Flags<T>::LcfSize(ref, stream);
647  }
648  static void WriteXml(const T& ref, XmlWriter& stream) {
649  Flags<T>::WriteXml(ref, stream);
650  }
651  static void BeginXml(T& ref, XmlReader& stream) {
652  Flags<T>::BeginXml(ref, stream);
653  }
654  static void ParseXml(T& /* ref */, const std::string& /* data */) {
655  // no-op
656  }
657 };
658 
663 public:
664  WrapperXmlHandler(const char* const name, XmlHandler* handler) :
665  name(name), handler(handler) {}
666 
667  void StartElement(XmlReader& stream, const char* name, const char** /* atts */) {
668  if (strcmp(name, this->name) != 0)
669  stream.Error("Expecting %s but got %s", this->name, name);
670  stream.SetHandler(handler);
671  }
672 
673 private:
674  const char* const name;
676 };
677 
681 template <class S>
682 class RootXmlHandler : public XmlHandler {
683 
684 public:
685  RootXmlHandler(S& ref, const char* const name) : ref(ref), name(name) {}
686 
687  void StartElement(XmlReader& stream, const char* name, const char** /* atts */) {
688  if (strcmp(name, this->name) != 0)
689  stream.Error("Expecting %s but got %s", this->name, name);
690  TypeReader<S>::BeginXml(ref, stream);
691  }
692 
693 private:
694  S& ref;
695  const char* const name;
696 
697 };
698 
699 // Macros
700 
701 // needs define of
702 // - LCF_CHUNK_SUFFIX
703 // - LCF_CURRENT_STRUCT
704 
705 #define LCF_STRUCT_FIELDS_BEGIN() \
706  template <> \
707  char const* const Struct<RPG::LCF_CURRENT_STRUCT>::name = BOOST_PP_STRINGIZE(LCF_CURRENT_STRUCT); \
708  template <> \
709  Field<RPG::LCF_CURRENT_STRUCT> const* Struct<RPG::LCF_CURRENT_STRUCT>::fields[] = { \
710 
711 #define LCF_STRUCT_FIELDS_END() \
712  NULL }; \
713 
714 #define LCF_STRUCT_TYPED_FIELD(T, REF) \
715  new TypedField<RPG::LCF_CURRENT_STRUCT, T>( \
716  &RPG::LCF_CURRENT_STRUCT::REF \
717  , LCF_CHUNK_SUFFIX::BOOST_PP_CAT(Chunk, LCF_CURRENT_STRUCT)::REF \
718  , BOOST_PP_STRINGIZE(REF) \
719  ) \
720 
721 #define LCF_STRUCT_SIZE_FIELD(T, REF) \
722  new SizeField<RPG::LCF_CURRENT_STRUCT, T>( \
723  &RPG::LCF_CURRENT_STRUCT::REF \
724  , LCF_CHUNK_SUFFIX::BOOST_PP_CAT(Chunk, LCF_CURRENT_STRUCT)::BOOST_PP_CAT(REF, _size) \
725  ) \
726 
727 #endif
static void MakeTagMap()
RootXmlHandler(S &ref, const char *const name)
static void ReadLcf(S &obj, T S::*ref, LcfReader &stream, uint32_t length)
WrapperXmlHandler(const char *const name, XmlHandler *handler)
static bool IsEqual(const T &, const T &)
void WriteInt(int val)
Definition: writer_xml.cpp:139
static void ParseXml(T &, const std::string &)
static void WriteXml(const T &ref, XmlWriter &stream)
Compare_Traits_Impl< T, Compare_Test< T >::value > impl_type
static void BeginXml(S &obj, XmlReader &stream)
RPG::Database data
Definition: data.cpp:11
bool S::* ref
static int LcfSize(const T &ref, LcfWriter &stream)
static void WriteLcf(const std::vector< T > &ref, LcfWriter &stream)
static tag_map_type tag_map
void StartElement(XmlReader &stream, const char *name, const char **)
void StartElement(XmlReader &stream, const char *name, const char **)
static void WriteXml(const S &obj, XmlWriter &stream)
void Seek(size_t pos, SeekMode mode=FromStart)
Definition: reader_lcf.cpp:178
void SetHandler(XmlHandler *handler)
Definition: reader_xml.cpp:92
virtual void BeginXml(S &obj, XmlReader &stream) const =0
static int LcfSize(const S &obj, const T S::*ref, LcfWriter &stream)
virtual void WriteLcf(const S &obj, LcfWriter &stream) const =0
void BeginElement(const std::string &name)
Definition: writer_xml.cpp:163
void WriteXml(const S &, XmlWriter &) const
std::string Decode(const std::string &str_to_encode)
Definition: writer_lcf.cpp:121
static const Category::Index value
Definition: reader_struct.h:50
static void ReadLcf(std::vector< T > &ref, LcfReader &stream, uint32_t)
static void ParseXml(std::vector< T > &, const std::string &)
virtual bool IsDefault(const S &obj, const S &ref) const =0
void WriteInt(int val)
Definition: writer_lcf.cpp:58
static void WriteLcf(const T &ref, LcfWriter &stream)
static void BeginXml(T &ref, XmlReader &stream)
static int LcfSize(const T &ref, LcfWriter &stream)
void Read(void *ptr, size_t size, size_t nmemb)
Definition: reader_lcf.cpp:52
static void WriteLcf(const T &ref, LcfWriter &stream)
void EndElement(const std::string &name)
Definition: writer_xml.cpp:177
void ReadLcf(S &, LcfReader &stream, uint32_t length) const
static yes & check(void(C::*)(void))
Field(int id, const char *name)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
void Error(const char *fmt,...)
Definition: reader_xml.cpp:71
static void WriteXml(const std::string &ref, XmlWriter &stream)
static void WriteXmlTag(const S &obj, const std::string &name, XmlWriter &stream)
static int LcfSize(const T &, LcfWriter &)
void BeginXml(S &obj, XmlReader &stream) const
STL namespace.
static void ParseXml(std::vector< T > &ref, const std::string &data)
static void MakeFieldMap()
void BeginXml(S &, XmlReader &) const
static void ReadLcf(S &obj, LcfReader &stream, uint32_t length)
static void ReadID(S &obj, LcfReader &stream)
static void BeginXml(S &obj, XmlReader &stream)
void Write(const void *ptr, size_t size, size_t nmemb)
Definition: writer_lcf.cpp:33
static void WriteLcf(const T &ref, LcfWriter &stream)
static void ParseXml(T &, const std::string &)
static bool IsEqual(const std::vector< T > &a, const std::vector< T > &b)
static bool IsEqual(const T &a, const T &b)
S struct_type
const char *const name
static void WriteXml(const std::vector< T > &ref, XmlWriter &stream)
TypedField(T S::*ref, int id, const char *name)
static void WriteLcf(const S &obj, LcfWriter &stream)
static void ParseXml(int &ref, const std::string &data)
static const bool value
int ReadInt()
Definition: reader_lcf.cpp:82
static void ReadLcf(std::string &ref, LcfReader &stream, uint32_t length)
static void WriteLcf(const std::vector< T > &ref, LcfWriter &stream)
static void WriteLcf(const std::string &ref, LcfWriter &stream)
static void WriteLcf(const int &ref, LcfWriter &stream)
static void ParseXml(std::string &ref, const std::string &data)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static tag_map_type tag_map
static void ReadLcf(int &ref, LcfReader &stream, uint32_t length)
void ReadString(std::string &ref, size_t size)
Definition: reader_lcf.cpp:162
static int LcfSize(const std::vector< T > &ref, LcfWriter &stream)
static const char *const name
void WriteLcf(const S &obj, LcfWriter &stream) const
static void WriteXml(const T &ref, XmlWriter &stream)
IDReaderT< S, IDChecker< S >::value > IDReader
bool IsDefault(const S &a, const S &b) const
virtual void ParseXml(S &obj, const std::string &data) const =0
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
Definition: reader_struct.h:97
static int LcfSize(const std::vector< T > &ref, LcfWriter &)
static int LcfSize(const T &ref, LcfWriter &stream)
std::map< const char *const, const Field< S > *, StringComparator > tag_map_type
Flag(bool S::*ref, const char *const name)
static void ParseXml(T &ref, const std::string &data)
static int LcfSize(const std::string &ref, LcfWriter &stream)
static void WriteLcf(const T &ref, LcfWriter &stream)
const char *const name
std::map< const char *const, const Flag *, StringComparator > tag_map_type
virtual void WriteXml(const S &obj, XmlWriter &stream) const =0
static void WriteXml(const T &ref, XmlWriter &stream)
SizeField(const std::vector< T > S::*ref, int id)
static void BeginXml(std::vector< T > &ref, XmlReader &stream)
void ParseXml(S &obj, const std::string &data) const
static void WriteXmlTag(const S &, const std::string &name, XmlWriter &stream)
static void ReadLcf(S &obj, LcfReader &stream)
static void ReadIDXml(S &, const char **)
static int LcfSize(const T &ref, LcfWriter &stream)
static void BeginXml(T &ref, XmlReader &stream)
int LcfSize(const S &obj, LcfWriter &stream) const
virtual void ReadLcf(S &obj, LcfReader &stream, uint32_t length) const =0
static void ParseXml(S &obj, T S::*ref, const std::string &data)
static const bool value
static void BeginXml(T &ref, XmlReader &stream)
static void ParseXml(T &, const std::string &)
const char *const name
const char *const name
static void ReadID(S &, LcfReader &)
static int IDSize(const S &obj)
void WriteLcf(const S &obj, LcfWriter &stream) const
static void ParseXml(T &ref, const std::string &data)
static const uint32_t max_size
static void WriteID(const S &obj, LcfWriter &stream)
static int LcfSize(const S &obj, LcfWriter &stream)
static int IntSize(unsigned int x)
Definition: reader_lcf.cpp:255
static void MakeTagMap()
Definition: rpg_actor.h:23
static void BeginXml(T &ref, XmlReader &stream)
std::map< int, const Field< S > * > field_map_type
void Write(const T &val)
static void WriteXml(const int &ref, XmlWriter &stream)
static const char *const name
static void WriteXml(const S &obj, const T S::*ref, XmlWriter &stream)
static field_map_type field_map
static void WriteXml(const T &ref, XmlWriter &stream)
static void ReadIDXml(S &obj, const char **atts)
static int IDSize(const S &)
static int LcfSize(const int &ref, LcfWriter &)
uint32_t Tell()
Definition: reader_lcf.cpp:194
static const Field< S > * fields[]
static void WriteXml(const T &ref, XmlWriter &stream)
static void WriteLcf(const S &obj, LcfWriter &stream)
int LcfSize(const S &obj, LcfWriter &stream) const
virtual int LcfSize(const S &obj, LcfWriter &stream) const =0
static int LcfSize(const S &obj, LcfWriter &stream)
const std::vector< T > S::* ref
static yes check(type_check< int C::*,&C::ID > *)
void WriteXml(const S &obj, XmlWriter &stream) const
static void BeginXml(S &obj, T S::*ref, XmlReader &stream)
static void ReadLcf(std::vector< T > &ref, LcfReader &stream, uint32_t length)
static void WriteLcf(const T &ref, LcfWriter &stream)
static void WriteXml(const T &ref, XmlWriter &stream)
XmlHandler * handler
static void WriteLcf(const S &obj, const T S::*ref, LcfWriter &stream)
void ReadLcf(S &obj, LcfReader &stream, uint32_t length) const
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t)
static void WriteXml(const std::vector< T > &ref, XmlWriter &stream)
const Flags< flags_type >::Flag * flags[]
void ParseXml(S &, const std::string &) const
static const bool value
static void WriteID(const S &, LcfWriter &)
bool IsDefault(const S &a, const S &b) const
static void WriteLcf(const T &ref, LcfWriter &stream)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static const uint32_t value
static int LcfSize(const T &ref, LcfWriter &stream)
bool operator()(const char *const &lhs, const char *const &rhs) const
static void Read(T &ref, const std::string &data)
static void WriteXml(const S &obj, XmlWriter &stream)
static bool IsEqual(const T &a, const T &b)
static void BeginXml(T &, XmlReader &)