From a8119d531ad0264b45b22c03a847b98286872b21 Mon Sep 17 00:00:00 2001 From: OV2 Date: Sat, 15 Dec 2018 14:08:45 +0100 Subject: [PATCH] win32: remove unused xml class --- win32/CDirect3D.cpp | 3 - win32/CXML.cpp | 163 ---------------------------------- win32/CXML.h | 29 ------ win32/snes9xw.vcxproj | 5 +- win32/snes9xw.vcxproj.filters | 7 +- 5 files changed, 3 insertions(+), 204 deletions(-) delete mode 100644 win32/CXML.cpp delete mode 100644 win32/CXML.h diff --git a/win32/CDirect3D.cpp b/win32/CDirect3D.cpp index 035c89fe..6c6073da 100644 --- a/win32/CDirect3D.cpp +++ b/win32/CDirect3D.cpp @@ -14,9 +14,6 @@ #include "wsnes9x.h" #include "dxerr.h" #include -#include "CXML.h" - - #include "../filter/hq2x.h" #include "../filter/2xsai.h" diff --git a/win32/CXML.cpp b/win32/CXML.cpp deleted file mode 100644 index cfcc7015..00000000 --- a/win32/CXML.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "CXML.h" -#include -#include -#include "_tfwopen.h" -#ifndef UNICODE -#define _tFromTCHAR(x) CPToWide(x,CP_ACP) -#define _tToTCHAR(x) WideToCP(x,CP_ACP) -#else -#define _tFromTCHAR -#define _tToTCHAR -#endif - -CXML::CXML(void) -{ - pXMLDoc = NULL; - xmlLoaded = false; - nodeContent = NULL; - attrValue = NULL; -} - -CXML::~CXML(void) -{ - unloadXml(); -} - -void CXML::unloadXml() -{ - if(pXMLDoc) { - pXMLDoc->Release(); - pXMLDoc = NULL; - } - if(nodeContent) { - delete [] nodeContent; - nodeContent = NULL; - } - if(attrValue) { - delete [] attrValue; - attrValue = NULL; - } - xmlLoaded = false; -} - -bool CXML::loadXmlFile(TCHAR const *file) -{ - unloadXml(); - - if(!file) - return false; - - TCHAR errorMsg[MAX_PATH + 50]; - - HRESULT hr = CoCreateInstance(CLSID_DOMDocument,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pXMLDoc)); - - if(FAILED(hr)) { - MessageBox(NULL, TEXT("Error creating XML Parser"), TEXT("XML Error"), - MB_OK|MB_ICONEXCLAMATION); - pXMLDoc = NULL; - return false; - } - - - VARIANT fileName; - VARIANT_BOOL ret; - fileName.vt = VT_BSTR; - fileName.bstrVal = SysAllocString(_tFromTCHAR(file)); - hr = pXMLDoc->load(fileName,&ret); - SysFreeString(fileName.bstrVal); - - if(FAILED(hr) || hr==S_FALSE) { - _stprintf(errorMsg,TEXT("Error loading XML file:\n%s"),file); - MessageBox(NULL, errorMsg, TEXT("XML Error"), - MB_OK|MB_ICONEXCLAMATION); - unloadXml(); - return false; - } - - hr = pXMLDoc->get_documentElement(&pXrootElement); - if(FAILED(hr) || hr==S_FALSE) { - _stprintf(errorMsg,TEXT("Error loading root element from file:\n%s"),file); - MessageBox(NULL, errorMsg, TEXT("XML Error"), MB_OK|MB_ICONEXCLAMATION); - unloadXml(); - return false; - } - - xmlLoaded = true; - return true; -} - -IXMLDOMNode *CXML::getNode(TCHAR const *searchNode) -{ - IXMLDOMNode *pXDN; - BSTR queryString=SysAllocString(_tFromTCHAR(searchNode)); - HRESULT hr = pXMLDoc->selectSingleNode(queryString,&pXDN); - SysFreeString(queryString); - - return pXDN; -} - -TCHAR *CXML::getAttribute(TCHAR const *searchNode, TCHAR const *attrName) -{ - IXMLDOMNode *pXDN = getNode(searchNode); - - if(!pXDN) - return NULL; - - VARIANT attributeValue; - BSTR attributeName; - - IXMLDOMElement * pXDE = NULL; - HRESULT hr = pXDN->QueryInterface(IID_PPV_ARGS(&pXDE)); - if(FAILED(hr)) { - pXDN->Release(); - return NULL; - } - - attributeName=SysAllocString(_tFromTCHAR(attrName)); - pXDE->getAttribute(attributeName,&attributeValue); - SysFreeString(attributeName); - pXDE->Release(); - - if(attributeValue.vt!=VT_BSTR) - return NULL; - - if(attrValue) { - delete [] attrValue; - attrValue = NULL; - } - - attrValue = new TCHAR[lstrlen(_tToTCHAR(attributeValue.bstrVal)) + 1]; - lstrcpy(attrValue,_tToTCHAR(attributeValue.bstrVal)); - - SysFreeString(attributeValue.bstrVal); - - return attrValue; -} - -TCHAR *CXML::getNodeContent(TCHAR const *searchNode) -{ - IXMLDOMNode *pXDN = getNode(searchNode); - - if(!pXDN) - return NULL; - - BSTR nodeText; - - HRESULT hr = pXDN->get_text(&nodeText); - pXDN->Release(); - - if(hr != S_OK) - return NULL; - - if(nodeContent) { - delete [] nodeContent; - nodeContent = NULL; - } - - nodeContent = new TCHAR[lstrlen(_tToTCHAR(nodeText)) + 1]; - lstrcpy(nodeContent,_tToTCHAR(nodeText)); - - SysFreeString(nodeText); - - return nodeContent; -} diff --git a/win32/CXML.h b/win32/CXML.h deleted file mode 100644 index 95cf2e27..00000000 --- a/win32/CXML.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CXML_H -#define CXML_H - -#include "msxml2.h" -#include - -class CXML -{ -private: - IXMLDOMDocument * pXMLDoc; - IXMLDOMElement * pXrootElement; - bool xmlLoaded; - TCHAR *nodeContent; - TCHAR *attrValue; - - IXMLDOMNode *getNode(TCHAR const *searchNode); - -public: - CXML(void); - ~CXML(void); - - bool loadXmlFile(TCHAR const *xmlFile); - void unloadXml(); - - TCHAR *getAttribute(TCHAR const *searchNode, TCHAR const *attrName); - TCHAR *getNodeContent(TCHAR const *searchNode); -}; - -#endif \ No newline at end of file diff --git a/win32/snes9xw.vcxproj b/win32/snes9xw.vcxproj index a79bcdd7..0e4fbd4a 100644 --- a/win32/snes9xw.vcxproj +++ b/win32/snes9xw.vcxproj @@ -433,7 +433,6 @@ - @@ -572,7 +571,6 @@ - @@ -707,6 +705,7 @@ + @@ -726,4 +725,4 @@ - + \ No newline at end of file diff --git a/win32/snes9xw.vcxproj.filters b/win32/snes9xw.vcxproj.filters index 84f147ef..6518ec19 100644 --- a/win32/snes9xw.vcxproj.filters +++ b/win32/snes9xw.vcxproj.filters @@ -81,9 +81,6 @@ GUI - - GUI - GUI @@ -458,9 +455,6 @@ GUI - - GUI - GUI @@ -649,6 +643,7 @@ Resource\Other +