Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
HAPI_PugiXMLFile.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 */
21 m_name( "" ) {
22
23}
24/*
25=========================================================
26 *
27 * @param filename
28 * @return
29 */
30PugiXMLFile::PugiXMLFile(char const *filename, std::string const &a_callingFunctionName) :
31 m_name( filename ) {
32
33 pugi::xml_parse_result result = m_doc.load_file(filename);
34 if (result.status != pugi::status_ok) {
35 throw std::runtime_error( "ERROR from PugiXMLFile::PugiXMLFile via " + a_callingFunctionName + " for file '" + filename + "': " + result.description() );
36 }
37
38}
39/*
40=========================================================
41*/
42PugiXMLFile::~PugiXMLFile( ) {
43
44}
45/*
46============================================================
47===================== get child element ====================
48============================================================
49 *
50 * @return
51 */
52Node PugiXMLFile::child(char const *a_name) {
53
54 // Only one child element allowed in XML file
55 if (a_name == m_doc.first_child( ).name())
56 return Node(new PugiXMLNode( m_doc.first_child( ) ));
57 else
58 return Node(new PugiXMLNode( ));
59}
60/*
61=========================================================
62*/
63Node PugiXMLFile::first_child() {
64
65 return Node(new PugiXMLNode( m_doc.first_child( ) ));
66
67}
68/*
69=========================================================
70*/
71std::string PugiXMLFile::name() const {
72
73 return m_name;
74
75}
76
77}
78#endif
Definition HAPI.hpp:34
@ status_ok
Definition pugixml.hpp:982
xml_parse_status status
Definition pugixml.hpp:1010