21 if (!field_map.empty())
23 for (
int i = 0; fields[i] != NULL; i++)
24 field_map[fields[i]->
id] = fields[i];
31 for (
int i = 0; fields[i] != NULL; i++)
32 tag_map[fields[i]->name] = fields[i];
41 while (!stream.
Eof()) {
43 if (chunk_info.
ID == 0)
47 if (chunk_info.
length == 0)
50 typename field_map_type::const_iterator it = field_map.find(chunk_info.
ID);
51 if (it != field_map.end()) {
52 #ifdef LCF_DEBUG_TRACE
53 printf(
"0x%02x (size: %d, pos: 0x%x): %s\n", chunk_info.
ID, chunk_info.
length, stream.
Tell(), it->second->name);
55 it->second->ReadLcf(obj, stream, chunk_info.
length);
58 stream.
Skip(chunk_info);
66 for (
int i = 0; fields[i] != NULL; i++) {
69 std::cerr <<
"field order mismatch: " << field->
id
71 <<
" in struct " << name
89 for (
int i = 0; fields[i] != NULL; i++) {
92 std::cerr <<
"field order mismatch: " << field->
id
94 <<
" in struct " << name
96 printf(
"\n%s", field->
name);
98 printf(
" -> default");
112 for (
int i = 0; fields[i] != NULL; i++) {
118 int size = field->
LcfSize(obj, stream);
128 IDReader::WriteXmlTag(obj, name, stream);
129 for (
int i = 0; fields[i] != NULL; i++) {
187 for (
int i = 0; i < count; i++) {
188 IDReader::ReadID(vec[i], stream);
195 int count = vec.size();
197 for (
int i = 0; i < count; i++) {
198 IDReader::WriteID(vec[i], stream);
206 int count = vec.size();
208 for (
int i = 0; i < count; i++) {
209 result += IDReader::IDSize(vec[i]);
217 int count = vec.size();
218 for (
int i = 0; i < count; i++)
230 ref.resize(
ref.size() + 1);
static void BeginXml(S &obj, XmlReader &stream)
void SetHandler(XmlHandler *handler)
void Skip(const struct LcfReader::Chunk &chunk_info)
virtual void WriteLcf(const S &obj, LcfWriter &stream) const =0
void CharacterData(XmlReader &, const std::string &data)
virtual bool IsDefault(const S &obj, const S &ref) const =0
void EndElement(const std::string &name)
void Error(const char *fmt,...)
StructVectorXmlHandler(std::vector< S > &ref)
static void MakeFieldMap()
void StartElement(XmlReader &stream, const char *name, const char **atts)
virtual void WriteXml(const S &obj, XmlWriter &stream) const =0
static void ReadLcf(S &obj, LcfReader &stream)
bool Save(const std::string &filename, const std::string &encoding)
void StartElement(XmlReader &stream, const char *name, const char **atts)
void StartElement(XmlReader &stream, const char *name, const char **)
static int LcfSize(const S &obj, LcfWriter &stream)
static int IntSize(unsigned int x)
StructFieldXmlHandler(S &ref)
static void WriteLcf(const S &obj, LcfWriter &stream)
virtual int LcfSize(const S &obj, LcfWriter &stream) const =0
void EndElement(XmlReader &, const char *)
static void WriteXml(const S &obj, XmlWriter &stream)