diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/auth/Loginbox/xmlInt32Parser.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/auth/Loginbox/xmlInt32Parser.cpp')
-rw-r--r-- | Src/auth/Loginbox/xmlInt32Parser.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
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 <shlwapi.h> +#include <strsafe.h> + + +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 |