mirror of https://github.com/snes9xgit/snes9x.git
win32: remove unused xml class
This commit is contained in:
parent
1634fe33f7
commit
a8119d531a
|
@ -14,9 +14,6 @@
|
|||
#include "wsnes9x.h"
|
||||
#include "dxerr.h"
|
||||
#include <commctrl.h>
|
||||
#include "CXML.h"
|
||||
|
||||
|
||||
|
||||
#include "../filter/hq2x.h"
|
||||
#include "../filter/2xsai.h"
|
||||
|
|
163
win32/CXML.cpp
163
win32/CXML.cpp
|
@ -1,163 +0,0 @@
|
|||
#include "CXML.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
29
win32/CXML.h
29
win32/CXML.h
|
@ -1,29 +0,0 @@
|
|||
#ifndef CXML_H
|
||||
#define CXML_H
|
||||
|
||||
#include "msxml2.h"
|
||||
#include <tchar.h>
|
||||
|
||||
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
|
|
@ -433,7 +433,6 @@
|
|||
<ClInclude Include="COpenGL.h" />
|
||||
<ClInclude Include="CShaderParamDlg.h" />
|
||||
<ClInclude Include="CXAudio2.h" />
|
||||
<ClInclude Include="CXML.h" />
|
||||
<ClInclude Include="dxerr.h" />
|
||||
<ClInclude Include="globals.h" />
|
||||
<ClInclude Include="gl_core_3_1.h" />
|
||||
|
@ -572,7 +571,6 @@
|
|||
<ClCompile Include="COpenGL.cpp" />
|
||||
<ClCompile Include="CShaderParamDlg.cpp" />
|
||||
<ClCompile Include="CXAudio2.cpp" />
|
||||
<ClCompile Include="CXML.cpp" />
|
||||
<ClCompile Include="DumpAtEnd.cpp" />
|
||||
<ClCompile Include="dxerr.cpp" />
|
||||
<ClCompile Include="gl_core_3_1.c" />
|
||||
|
@ -707,6 +705,7 @@
|
|||
<Image Include="rsrc\hd.bmp" />
|
||||
<Image Include="rsrc\hiddir.bmp" />
|
||||
<Image Include="rsrc\icon1.ico" />
|
||||
<Image Include="rsrc\icon2.ico" />
|
||||
<Image Include="rsrc\nd.bmp" />
|
||||
<Image Include="rsrc\openfold.bmp" />
|
||||
<Image Include="rsrc\pad.bmp" />
|
||||
|
|
|
@ -81,9 +81,6 @@
|
|||
<ClInclude Include="AVIOutput.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CXML.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InputCustom.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
|
@ -458,9 +455,6 @@
|
|||
<ClCompile Include="AVIOutput.cpp">
|
||||
<Filter>GUI</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CXML.cpp">
|
||||
<Filter>GUI</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputCustom.cpp">
|
||||
<Filter>GUI</Filter>
|
||||
</ClCompile>
|
||||
|
@ -649,6 +643,7 @@
|
|||
<Image Include="rsrc\ud.bmp">
|
||||
<Filter>Resource\Other</Filter>
|
||||
</Image>
|
||||
<Image Include="rsrc\icon2.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\65c816.h">
|
||||
|
|
Loading…
Reference in New Issue