-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCDATASectionNode.cpp
More file actions
50 lines (37 loc) · 1.01 KB
/
CDATASectionNode.cpp
File metadata and controls
50 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "CDATASectionNode.h"
#include "Tokens.h"
#include <sstream>
namespace Bxml {
CDATASectionNode::CDATASectionNode(char* data, size_t length) :
Node(data, length)
{
last = (*(data+size)) == CDATASectionLast;
size += sizeof byte;
uint16* lengthPtr = reinterpret_cast<uint16*>(data+size);
this->length = *lengthPtr;
size += sizeof uint16;
string = new wchar_t[this->length+1];
memset(string, 0, sizeof (wchar_t) * (this->length+1));
wchar_t* stringSrc = reinterpret_cast<wchar_t*>(data+size);
wcsncpy(string, stringSrc, this->length);
size += this->length * sizeof (wchar_t);
}
CDATASectionNode::~CDATASectionNode(void)
{
delete []string;
}
size_t CDATASectionNode::getLength() {
return length;
}
std::wstring* CDATASectionNode::toXml() {
if (Xml == NULL) {
std::wstringstream xmlStream;
xmlStream << L"<[CDATA[" << string << L"]]";
Xml = new std::wstring(xmlStream.str());
}
return Xml;
}
bool CDATASectionNode::isLast() {
return last;
}
}