10#include "lcf/dbstring.h"
28 static void ReadLcf(DBString& ref, LcfReader& stream, uint32_t length);
29 static void WriteLcf(
const DBString& ref, LcfWriter& stream);
30 static int LcfSize(
const DBString& ref, LcfWriter& stream);
31 static void WriteXml(
const DBString& ref, XmlWriter& stream);
32 static void BeginXml(DBString& ref, XmlReader& stream);
37 static void ReadLcf(std::vector<DBString>& ref, LcfReader& stream, uint32_t length);
38 static void WriteLcf(
const std::vector<DBString>& ref, LcfWriter& stream);
39 static int LcfSize(
const std::vector<DBString>& ref, LcfWriter& stream);
40 static void WriteXml(
const std::vector<DBString>& ref, XmlWriter& stream);
41 static void BeginXml(std::vector<DBString>& ref, XmlReader& stream);
45 stream.ReadString(ref, length);
47 fprintf(stderr,
" %s\n", ref.c_str());
56 return stream.Decode(ref).size();
88 uint32_t startpos = stream.Tell();
89 uint32_t endpos = startpos + length;
90 while (stream.Tell() < endpos) {
93 auto size = stream.ReadUInt64();
94 if (size > std::numeric_limits<uint32_t>::max()) {
95 index +=
static_cast<uint32_t
>(0x800000000 - size);
99 stream.ReadString(string_var, size);
100#ifdef LCF_DEBUG_TRACE
101 fprintf(stderr,
"t[%d]: %s\n", index + 1, string_var.c_str());
103 ref.push_back(string_var);
109 if (stream.Tell() != endpos) {
110 Log::Warning(
"vector<string> Misaligned at 0x%" PRIx32
"", stream.Tell());
118 for (
size_t i = 0; i < ref.size(); ++i) {
119 const auto& e = ref[i];
126 stream.WriteUInt64(0x800000000 -
static_cast<uint64_t
>(gap_size));
131 stream.WriteInt(len);
140 for (
size_t i = 0; i < ref.size(); ++i) {
141 const auto& e = ref[i];
148 result += LcfReader::UInt64Size(0x800000000 -
static_cast<uint64_t
>(gap_size));
153 result += LcfReader::IntSize(size);
161 for (
size_t i = 0; i < ref.size(); ++i) {
162 const auto& e = ref[i];
167 stream.BeginElement(
"item", i + 1);
169 stream.EndElement(
"item");
178 if (strcmp(
name,
"item") != 0) {
185 for (
int i = 0; atts[i] != NULL && atts[i + 1] != NULL; i += 2) {
186 if (strcmp(atts[i],
"id") == 0) {
187 id = atoi(atts[i + 1]);
192 if (
id <= last_id ||
id < -1) {
193 Log::Error(
"XML: Bad Id %d / %d",
id, last_id);
198 DBString& obj =
ref.back();
203 std::vector<DBString>&
ref;
std::vector< DBString > & ref
DbStringVectorXmlHandler(std::vector< DBString > &ref)
void StartElement(XmlReader &stream, const char *name, const char **atts)
void StartElement(XmlReader &, const char *, const char **)
void CharacterData(XmlReader &, const std::string &data)
DbStringXmlHandler(DBString &ref)
void EndElement(XmlReader &, const char *)
void Warning(const char *fmt,...) LIKE_PRINTF
void Error(const char *fmt,...) LIKE_PRINTF
const char *const Struct< rpg::Actor >::name
static void ReadLcf(std::vector< DBString > &ref, LcfReader &stream, uint32_t length)
static void WriteLcf(const std::vector< DBString > &ref, LcfWriter &stream)
static void WriteXml(const std::vector< DBString > &ref, XmlWriter &stream)
static void BeginXml(std::vector< DBString > &ref, XmlReader &stream)
static int LcfSize(const std::vector< DBString > &ref, LcfWriter &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)