File: DOMNode.cpp

package info (click to toggle)
evqueue-core 2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,312 kB
  • sloc: cpp: 16,147; sql: 274; sh: 122; ansic: 72; makefile: 11
file content (139 lines) | stat: -rw-r--r-- 2,798 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * This file is part of evQueue
 * 
 * evQueue is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * evQueue is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with evQueue. If not, see <http://www.gnu.org/licenses/>.
 * 
 * Author: Thibault Kummer <bob@coldsource.net>
 */

#include <DOMNode.h>
#include <DOMElement.h>
#include <DOMNamedNodeMap.h>
#include <XMLString.h>

using namespace std;

DOMNode::DOMNode()
{
	this->node = 0;
}

DOMNode::DOMNode(xercesc::DOMNode *node)
{
	this->node = node;
}

DOMNode DOMNode::cloneNode(bool deep)
{
	return node->cloneNode(deep);
}

DOMNode DOMNode::getParentNode()
{
	return node->getParentNode();
}

DOMNode DOMNode::getFirstChild()
{
	return node->getFirstChild();
}

DOMNode DOMNode::getPreviousSibling()
{
	return node->getPreviousSibling();
}

DOMNode DOMNode::getNextSibling()
{
	return node->getNextSibling();
}

DOMNode DOMNode::appendChild(DOMNode newChild)
{
	return node->appendChild(newChild.node);
}

DOMNode DOMNode::removeChild(DOMNode oldChild)
{
	return node->removeChild(oldChild.node);
}

void DOMNode::replaceChild(DOMNode newChild,DOMNode oldChild)
{
	node->replaceChild(newChild.node,oldChild.node);
	oldChild.node->release();
}

DOMNode DOMNode::insertBefore(DOMNode newChild, DOMNode refChild)
{
	return node->insertBefore(newChild.node,refChild.node);
}

string DOMNode::getNodeName()
{
	char *str = xercesc::XMLString::transcode(node->getNodeName());
	string s(str);
	xercesc::XMLString::release(&str);
	
	return s;
}

string DOMNode::getNodeValue()
{
	char *str = xercesc::XMLString::transcode(node->getNodeValue());
	if(!str)
		str = xercesc::XMLString::transcode(node->getTextContent());
	
	if(!str)
		return "";
	
	string s(str);
	xercesc::XMLString::release(&str);
	
	return s;
}

DOMNode::NodeType DOMNode::getNodeType()
{
	return (NodeType)node->getNodeType();
}

string DOMNode::getTextContent()
{
	char *str = xercesc::XMLString::transcode(node->getTextContent());
	string s(str);
	xercesc::XMLString::release(&str);
	
	return s;
}

void DOMNode::setTextContent(const string &textContent)
{
	node->setTextContent(XMLString(textContent));
}

DOMNamedNodeMap DOMNode::getAttributes()
{
	return node->getAttributes();
}

DOMElement DOMNode::getOwnerElement()
{
	return ((xercesc::DOMAttr *)node)->getOwnerElement();
}

DOMNode::operator bool() const
{
	return node!=0;
}