|
#include "StdAfx.h"
#include "IncomingXMLPacket.h"
#include <shlwapi.h>
IncomingXMLPacket::IncomingXMLPacket( )
{
xRoot = XMLNode::emptyNode();
//
uBufferSize = 0;
pString = NULL;
}
IncomingXMLPacket::~IncomingXMLPacket( void )
{
if (pString)
{
delete[] pString;
}
}
bool IncomingXMLPacket::Decode(char* pBuffer, unsigned int uBufferSize)
{
this->uBufferSize = uBufferSize;
pString = new char[this->uBufferSize + 1];
CopyMemory(pString, pBuffer, uBufferSize);
pString[this->uBufferSize] = '\0';
//
xRoot = XMLNode::parseString(pString,"r");
if(xRoot.isEmpty())
return false;
return FragmentXML();
}
const char* IncomingXMLPacket::getArgumentAsText( char* argName, bool& updateSuccess )
{
XMLNode xChild = xRoot.getChildNode(argName);
if(xChild.isEmpty())
{
updateSuccess = false;
return NULL;
}
const char* pValue = xChild.getAttribute("v");
if (pValue == NULL)
updateSuccess = false;
return pValue;
}
int IncomingXMLPacket::getArgumentAsInt( char* argName, bool& updateSuccess )
{
XMLNode xChild = xRoot.getChildNode(argName);
if(xChild.isEmpty())
{
updateSuccess = false;
return NULL;
}
const char* pValue = xChild.getAttribute("v");
if (pValue == NULL){
updateSuccess = false;
return NULL;
}
return atoi(pValue);
}
bool IncomingXMLPacket::getArgumentAsBool( char* argName, bool& updateSuccess )
{
XMLNode xChild = xRoot.getChildNode(argName);
if(xChild.isEmpty())
{
updateSuccess = false;
return NULL;
}
const char* pValue = xChild.getAttribute("v");
if (pValue == NULL){
updateSuccess = false;
return NULL;
}
return strcmp(pValue, "1") == 0;
}
XMLNode IncomingXMLPacket::getInputXML()
{
return xRoot;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.