-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathValueTextNode.cpp
49 lines (36 loc) · 950 Bytes
/
ValueTextNode.cpp
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
#include "ValueTextNode.h"
#include "Tokens.h"
#include <cstring>
namespace Bxml {
ValueTextNode::ValueTextNode(char* data, size_t length) :
Node(data, length)
{
last = (*(data+size)) == ValueTextLast;
// skipping StringType byte
size += 2 * (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);
}
ValueTextNode::~ValueTextNode(void)
{
delete []string;
}
size_t ValueTextNode::getLength() {
return length;
}
std::wstring* ValueTextNode::toXml() {
if (Xml != NULL) {
Xml = new std::wstring(string);
}
return Xml;
}
bool ValueTextNode::isLast() {
return last;
}
}