BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_XML.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_XML_HPP
13#define BELFEM_CL_XML_HPP
14
15#ifdef BELFEM_XML
16#include <tinyxml2.h>
17#endif
18
19#include "typedefs.hpp"
20#include "filetools.hpp"
21
22namespace belfem
23{
24//------------------------------------------------------------------------------
31 class XML
32 {
33 const string mPath;
34#ifdef BELFEM_XML
35 tinyxml2::XMLDocument mFile;
36
37 tinyxml2::XMLElement* mActiveElement = nullptr;
38
39 // current level in XML file
40 uint mLevel = 0;
41#endif
42
43//------------------------------------------------------------------------------
44 public:
45//------------------------------------------------------------------------------
46
47 XML( const string & aPath,
48 const FileMode aMode = FileMode::OPEN_RDONLY );
49
50//------------------------------------------------------------------------------
51
52 ~XML();
53
54//------------------------------------------------------------------------------
55
59 inline const string &
60 path() const
61 {
62 return mPath ;
63 }
64
65//------------------------------------------------------------------------------
66
70 bool
71 child_exists( const string & aLabel );
72
73//------------------------------------------------------------------------------
74
78 uint
80
81//------------------------------------------------------------------------------
82
86 uint
87 number_of_children( const string & aLabel );
88
89//------------------------------------------------------------------------------
90
95 bool
97
98//------------------------------------------------------------------------------
99
100 void
101 select_first_child( const string & aLabel );
102
103//------------------------------------------------------------------------------
104
105 void
107
108//------------------------------------------------------------------------------
109
114 void
115 select_subtree( const string & aTree );
116
117//------------------------------------------------------------------------------
118
119 string
120 get_string( const string & aKey );
121
122//------------------------------------------------------------------------------
123
124 int
125 get_int( const string & aKey );
126
127//------------------------------------------------------------------------------
128
129 real
130 get_real( const string & aKey );
131
132//------------------------------------------------------------------------------
133
134 bool
135 get_bool( const string & aKey );
136
137//------------------------------------------------------------------------------
138
139 bool
140 key_exists( const string & aKey );
141
142//------------------------------------------------------------------------------
143 };
144//------------------------------------------------------------------------------
145}
146#endif //BELFEM_CL_XML_HPP
const string & path() const
return the path of this file
Definition cl_XML.hpp:60
void select_first_child(const string &aLabel)
Definition cl_XML.cpp:136
XML(const string &aPath, const FileMode aMode=FileMode::OPEN_RDONLY)
Definition cl_XML.cpp:20
void select_subtree(const string &aTree)
directly jump down to this element if you know that it exists separate element names using a "/"
Definition cl_XML.cpp:202
int get_int(const string &aKey)
Definition cl_XML.cpp:268
bool key_exists(const string &aKey)
Definition cl_XML.cpp:238
string get_string(const string &aKey)
Definition cl_XML.cpp:248
bool get_bool(const string &aKey)
Definition cl_XML.cpp:284
void select_parent()
Definition cl_XML.cpp:187
bool child_exists(const string &aLabel)
test if at least one child of that name exists
Definition cl_XML.cpp:55
real get_real(const string &aKey)
Definition cl_XML.cpp:276
uint number_of_children()
cont the number of children in current tag
Definition cl_XML.cpp:67
bool next_sibling_of_same_name()
move to the next sibling of the same name; returns false ( selection unchanged ) if there is none
Definition cl_XML.cpp:163
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
FileMode
Definition filetools.hpp:27
@ OPEN_RDONLY
Definition filetools.hpp:29
double real
Definition typedefs.hpp:36