diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/xml/xmlApi.cpp | 20 | ||||
-rw-r--r-- | src/modules/xml/xmlParser.h | 28 |
2 files changed, 20 insertions, 28 deletions
diff --git a/src/modules/xml/xmlApi.cpp b/src/modules/xml/xmlApi.cpp index 2335b7c6d7..113f2e9ecd 100644 --- a/src/modules/xml/xmlApi.cpp +++ b/src/modules/xml/xmlApi.cpp @@ -37,6 +37,19 @@ static void xmlapiDestroyNode(HXML n) XMLNode tmp; tmp.attach(n);
}
+static HXML xmlapiParseFile(LPCTSTR str, int* datalen, LPCTSTR tag)
+{
+ if (str == NULL) return NULL;
+
+ XMLResults res;
+ XMLNode result = XMLNode::parseFile(str, tag, &res);
+
+ if (datalen != NULL)
+ datalen[0] += res.nChars;
+
+ return (res.error == eXMLErrorNone || (tag != NULL && res.error == eXMLErrorMissingEndTag)) ? result.detach() : NULL;
+}
+
static HXML xmlapiParseString(LPCTSTR str, int* datalen, LPCTSTR tag)
{
if (str == NULL) return NULL;
@@ -155,6 +168,11 @@ static LPTSTR xmlapiToString(HXML _n, int* datalen) return XMLNode(_n).createXMLString(0, datalen);
}
+static XMLError xmlapiToFile(HXML _n, LPCTSTR filename)
+{
+ return XMLNode(_n).writeToFile(filename, NULL, NULL);
+}
+
static void xmlapiAddAttr(HXML _n, LPCTSTR attrName, LPCTSTR attrValue)
{
if (attrName != NULL && attrValue != NULL)
@@ -382,6 +400,8 @@ static INT_PTR GetXmlApi(WPARAM, LPARAM lParam) xi->parseString = xmlapiParseString;
xi->toString = xmlapiToString;
xi->freeMem = xmlapiFree;
+ xi->parseFile = xmlapiParseFile;
+ xi->toFile = xmlapiToFile;
xi->addChild = xmlapiAddChild;
xi->addChild2 = xmlapiAddChild2;
diff --git a/src/modules/xml/xmlParser.h b/src/modules/xml/xmlParser.h index 3820c93c12..546171324f 100644 --- a/src/modules/xml/xmlParser.h +++ b/src/modules/xml/xmlParser.h @@ -150,34 +150,6 @@ #define TRUE 1
#endif /* TRUE */
-/// Enumeration for XML parse errors.
-typedef enum XMLError
-{
- eXMLErrorNone = 0,
- eXMLErrorMissingEndTag,
- eXMLErrorNoXMLTagFound,
- eXMLErrorEmpty,
- eXMLErrorMissingTagName,
- eXMLErrorMissingEndTagName,
- eXMLErrorUnmatchedEndTag,
- eXMLErrorUnmatchedEndClearTag,
- eXMLErrorUnexpectedToken,
- eXMLErrorNoElements,
- eXMLErrorFileNotFound,
- eXMLErrorFirstTagNotFound,
- eXMLErrorUnknownCharacterEntity,
- eXMLErrorCharacterCodeAbove255,
- eXMLErrorCharConversionError,
- eXMLErrorCannotOpenWriteFile,
- eXMLErrorCannotWriteFile,
-
- eXMLErrorBase64DataSizeIsNotMultipleOf4,
- eXMLErrorBase64DecodeIllegalCharacter,
- eXMLErrorBase64DecodeTruncatedData,
- eXMLErrorBase64DecodeBufferTooSmall
-} XMLError;
-
-
/// Enumeration used to manage type of data. Use in conjunction with structure XMLNodeContents
typedef enum XMLElementType
{
|