From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/auth/Loginbox/xmlInt32Parser.cpp | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Src/auth/Loginbox/xmlInt32Parser.cpp (limited to 'Src/auth/Loginbox/xmlInt32Parser.cpp') diff --git a/Src/auth/Loginbox/xmlInt32Parser.cpp b/Src/auth/Loginbox/xmlInt32Parser.cpp new file mode 100644 index 00000000..1f4ab48b --- /dev/null +++ b/Src/auth/Loginbox/xmlInt32Parser.cpp @@ -0,0 +1,65 @@ +#include "./xmlInt32Parser.h" + +#include +#include + + +XmlInt32Parser::XmlInt32Parser() + : value(0), result(E_PENDING) +{ + memset(szBuffer, 0, sizeof(szBuffer)); +} + +XmlInt32Parser::~XmlInt32Parser() +{ + +} + +HRESULT XmlInt32Parser::GetValue(INT *pValue) +{ + if (NULL == pValue) return E_POINTER; + *pValue = value; + return result; +} + +void XmlInt32Parser::Event_XmlStartElement(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + szBuffer[0] = L'\0'; + result = S_FALSE; +} + +void XmlInt32Parser::Event_XmlEndElement(const wchar_t *xmlpath, const wchar_t *xmltag) +{ + if (SUCCEEDED(result)) + { + if (FALSE == StrToIntEx(szBuffer, STIF_SUPPORT_HEX, &value)) + result = E_FAIL; + else + result = S_OK; + } + szBuffer[0] = L'\0'; +} + +void XmlInt32Parser::Event_XmlCharData(const wchar_t *xmlpath, const wchar_t *xmltag, const wchar_t *value) +{ + if (SUCCEEDED(result)) + { + if (FAILED(StringCchCat(szBuffer, ARRAYSIZE(szBuffer), value))) + result = E_FAIL; + } +} + +void XmlInt32Parser::Event_XmlError(int linenum, int errcode, const wchar_t *errstr) +{ + szBuffer[0] = L'\0'; + result = E_FAIL; +} + +#define CBCLASS XmlInt32Parser +START_DISPATCH; +VCB(ONSTARTELEMENT, Event_XmlStartElement) +VCB(ONENDELEMENT, Event_XmlEndElement) +VCB(ONCHARDATA, Event_XmlCharData) +VCB(ONERROR, Event_XmlError) +END_DISPATCH; +#undef CBCLASS \ No newline at end of file -- cgit