Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
HAPI_PugiXMLNode.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include "HAPI.hpp"
11
12#ifdef HAPI_USE_PUGIXML
13namespace HAPI {
14
15/*
16=========================================================
17 *
18 * @return
19 */
22 m_node( pugi::xml_node() ) {
23
24}
25/*
26=========================================================
27 *
28 * @param a_node
29 * @return
30 */
31PugiXMLNode::PugiXMLNode( pugi::xml_node a_node ) :
32 Node_internal( NodeInteralType::pugiXML ),
33 m_node( a_node ) {
34
35}
36/*
37============================================================
38====================== copy constructor ====================
39============================================================
40 */
41PugiXMLNode::PugiXMLNode(const PugiXMLNode &other) :
42 Node_internal( other ),
43 m_node( other.m_node ) {
44
45}
46/*
47=========================================================
48*/
49PugiXMLNode::~PugiXMLNode( ) {
50
51}
52/*
53============================================================
54=================== get attribute by name ==================
55============================================================
56 *
57 * @param a_name
58 * @return
59 */
60std::string PugiXMLNode::attribute(char const *a_name) {
61
62 pugi::xml_attribute attr = m_node.attribute( a_name );
63
64 return std::string(attr.value( ));
65
66}
67
68
69int PugiXMLNode::attribute_as_int(const char* a_name){
70 pugi::xml_attribute attr = m_node.attribute( a_name );
71
72 return atoi(attr.value( ));
73}
74long PugiXMLNode::attribute_as_long(const char* a_name){
75 pugi::xml_attribute attr = m_node.attribute( a_name );
76
77 return atol(attr.value( ));
78}
79double PugiXMLNode::attribute_as_double(const char* a_name){
80 pugi::xml_attribute attr = m_node.attribute( a_name );
81
82 return atof(attr.value( ));
83}
84
85/*
86============================================================
87===================== get child element ====================
88============================================================
89 *
90 * @return
91 */
92Node_internal *PugiXMLNode::child(char const *a_name) {
93
94 return new PugiXMLNode( m_node.child( a_name ) );
95
96}
97/*
98=========================================================
99*/
100Node_internal *PugiXMLNode::first_child() {
101
102 return new PugiXMLNode( m_node.first_child( ) );
103
104}
105/*
106============================================================
107===================== get sibling element ==================
108============================================================
109 *
110 * @return
111 */
112Node_internal *PugiXMLNode::next_sibling() {
113
114 return new PugiXMLNode( m_node.next_sibling( ) );
115
116}
117/*
118============================================================
119============= update self to point to next sibling =========
120============================================================
121 *
122 * @return
123 */
124void PugiXMLNode::to_next_sibling() {
125
126 m_node = m_node.next_sibling( );
127
128}
129/*
130============================================================
131======================== make a copy =======================
132============================================================
133 *
134 * @return
135 */
136Node_internal *PugiXMLNode::copy() {
137
138 return new PugiXMLNode( m_node );
139
140}
141/*
142============================================================
143===================== assignment operator ==================
144============================================================
145 */
146Node_internal &PugiXMLNode::operator=(const PugiXMLNode &other) {
147
148 this->m_node = other.m_node;
149 return *this;
150
151}
152/*
153============================================================
154===================== get tag name =========================
155============================================================
156 *
157 * @return
158 */
159std::string PugiXMLNode::name() const {
160
161 return std::string(m_node.name());
162
163}
164/*
165============================================================
166================== test for empty node =====================
167============================================================
168 *
169 * @return
170 */
171bool PugiXMLNode::empty() const {
172
173 return m_node.empty();
174
175}
176/*
177============================================================
178======================= text data ==========================
179============================================================
180 *
181 * @return
182 */
183Text PugiXMLNode::text() const {
184
185 return Text( std::string(m_node.text().get()) );
186
187}
188/*
189============================================================
190===================== numeric data =========================
191============================================================
192 *
193 * @return
194 */
195Data_internal *PugiXMLNode::data() const {
196
197 return new PugiXMLData( m_node );
198
199}
200
201}
202#endif
const char_t * value() const
Definition pugixml.cc:5289
Definition HAPI.hpp:34
NodeInteralType
Definition HAPI.hpp:36