|
#include "StdAfx.h"
#include "OutgoingXMLPacket.h"
#include "Utilities.h"
OutgoingXMLPacket::OutgoingXMLPacket( unsigned int uCommandID )
{
this->uCommandID = uCommandID;
xRoot = XMLNode::createXMLTopNode("r");
//
bEncoded = false;
pEncodedString = NULL;
uBufferSize = 0;
}
OutgoingXMLPacket::~OutgoingXMLPacket()
{
freeXMLString(pEncodedString);
}
void OutgoingXMLPacket::setArgumentAsText( char* argName, const char* sArgVal )
{
xRoot.addChild(argName).addAttribute("v", sArgVal);
}
void OutgoingXMLPacket::setArgumentAsInt( char* argName, int iArgVal )
{
char sArgVal [33];
itoa (iArgVal,sArgVal,10);
setArgumentAsText(argName, sArgVal);
}
void OutgoingXMLPacket::setArgumentAsBool( char* argName, bool bArgVal )
{
setArgumentAsText(argName, bArgVal ? "1" : "0");
}
bool OutgoingXMLPacket::Encode()
{
if(bEncoded)
return true;
if(!ConstructXML())
return false;
int nSize;
pEncodedString = xRoot.createXMLString(0, &nSize);
uBufferSize = nSize * sizeof(char);
bEncoded = true;
return true;
}
unsigned int OutgoingXMLPacket::getBufferLen()
{
return uBufferSize;
}
char* OutgoingXMLPacket::getBuffer()
{
return pEncodedString;
}
unsigned int OutgoingXMLPacket::getRequestId()
{
return uCommandID;
}
XMLNode OutgoingXMLPacket::getOutputXML()
{
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.