28 mParser = XML_ParserCreate(NULL);
29 XML_SetUserData(
mParser, (
void *)
this);
44 wxFFile theXMLFile(fname,
wxT(
"rb"));
45 if (!theXMLFile.IsOpened()) {
46 mErrorStr =
XO(
"Could not open file: \"%s\"").Format( fname );
52 const size_t bufferSize = 16384;
56 size_t len = fread(buffer, 1, bufferSize, theXMLFile.fp());
57 done = (len < bufferSize);
58 if (!XML_Parse(
mParser, buffer, len, done)) {
65 XML_ErrorString(XML_GetErrorCode(
mParser))
70 (
long unsigned int)XML_GetCurrentLineNumber(
mParser)
130 mErrorStr =
XO(
"Could not load file: \"%s\"").Format( fname );
136 const wxString &xmldata)
138 auto utf8 = xmldata.ToUTF8();
139 const char *buffer = utf8.data();
140 int len = utf8.length();
144 if (!
ParseBuffer(baseHandler, utf8.data(), utf8.length(),
true))
164 for (
auto chunk : xmldata)
166 if (!
ParseBuffer(baseHandler,
static_cast<const char*
>(chunk.first), chunk.second,
false))
199 if (handlers.empty()) {
206 handlers.push_back(NULL);
214 const char*
name = *atts++;
215 const char* value = *atts++;
223 if (handlers.size() == 1)
248 handler->ReadXMLContent(s, len);
252 XMLTagHandler* baseHandler,
const char* buffer,
size_t len,
bool isFinal)
254 if (!XML_Parse(
mParser, buffer, len, isFinal))
268 (
long unsigned int)XML_GetCurrentLineNumber(
mParser));
271 wxT(
"ParseString error: %s\n===begin===%s\n===end==="),
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
A low overhead memory stream with O(1) append, low heap fragmentation and a linear memory view.
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Debug() const
Format as an English string for debugging logs and developers' eyes, not for end users.
A view into an attribute value. The class does not take the ownership of the data.
Reads a file and passes the results through an XMLTagHandler.
bool ParseString(XMLTagHandler *baseHandler, const wxString &xmldata)
const TranslatableString & GetErrorStr() const
static void startElement(void *userData, const char *name, const char **atts)
bool ParseMemoryStream(XMLTagHandler *baseHandler, const MemoryStream &xmldata)
bool Parse(XMLTagHandler *baseHandler, const FilePath &fname)
const TranslatableString & GetLibraryErrorStr() const
static void endElement(void *userData, const char *name)
std::vector< XMLTagHandler * > Handlers
TranslatableString mErrorStr
AttributesList mCurrentTagAttributes
XMLTagHandler * mBaseHandler
static void charHandler(void *userData, const char *s, int len)
bool ParseBuffer(XMLTagHandler *baseHandler, const char *buffer, size_t len, bool isFinal)
TranslatableString mLibraryErrorStr
This class is an interface which should be implemented by classes which wish to be able to load and s...
AuthorizationHandler handler