UQTk: Uncertainty Quantification Toolkit 3.1.5
XMLElement.h
Go to the documentation of this file.
1/* =====================================================================================
2
3 The UQ Toolkit (UQTk) version 3.1.5
4 Copyright (2024) NTESS
5 https://www.sandia.gov/UQToolkit/
6 https://github.com/sandialabs/UQTk
7
8 Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
9 Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government
10 retains certain rights in this software.
11
12 This file is part of The UQ Toolkit (UQTk)
13
14 UQTk is open source software: you can redistribute it and/or modify
15 it under the terms of BSD 3-Clause License
16
17 UQTk is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 BSD 3 Clause License for more details.
21
22 You should have received a copy of the BSD 3 Clause License
23 along with UQTk. If not, see https://choosealicense.com/licenses/bsd-3-clause/.
24
25 Questions? Contact the UQTk Developers at https://github.com/sandialabs/UQTk/discussions
26 Sandia National Laboratories, Livermore, CA, USA
27===================================================================================== */
28// -*- C++ -*-
29
30#ifndef _util_xml_class_XMLElement_
31#define _util_xml_class_XMLElement_
32
33#include "Object.h"
34#include "XMLAttributeList.h"
35#include <vector>
36#include <set>
37
58class XMLElement : public Object {
59 template <class T> friend class RefPtr;
60 template <class T> friend class ConstRefPtr;
61public:
63 XMLElement(const std::string&);
64
65private:
68 XMLElement(const XMLElement&);
69
70public:
72 virtual ~XMLElement();
73
74private:
78
79public:
81 const std::string& label() const;
82
84 void set_label(const std::string&);
85
88 int count_attributes() const;
89
92
95
97 int count_children() const;
98
102
109 RefPtr<XMLElement> get_child(const std::string&);
110
117
120
122 void clear_children();
123
126 int count_content() const;
127
130 const std::string& get_content_line(int);
131
133 void add_content_line(const std::string&);
134
136 void clear_content();
137
139 //typedef std::vector< RefPtr<XMLElement> >::iterator child_iterator;
140
141private:
143 std::string label_;
144
147
149 std::vector< RefPtr<XMLElement> > children_;
150
152 std::vector<std::string> content_;
153
157};
158
159#endif // _util_xml_class_XMLElement_
Definition Object.h:47
Definition RefPtr.h:46
Definition XMLElement.h:58
std::string label_
The iterator type returned for list of children.
Definition XMLElement.h:143
RefPtr< XMLElement > get_child(int)
Definition XMLElement.cpp:111
int count_children() const
Utility function to check how many children this element has.
Definition XMLElement.cpp:104
RefPtr< XMLAttributeList > attributes_
The list of attributes associated with this element.
Definition XMLElement.h:146
void set_label(const std::string &)
Assign a new label to this node.
Definition XMLElement.cpp:76
void clear_content()
Clear all text content.
Definition XMLElement.cpp:227
std::vector< std::string > content_
The list of content associated with this element.
Definition XMLElement.h:152
void clear_children()
Erase all child elements from this node.
Definition XMLElement.cpp:196
std::vector< RefPtr< XMLElement > > children_
The list of children associated with this element.
Definition XMLElement.h:149
virtual ~XMLElement()
Destructor.
Definition XMLElement.cpp:56
void add_child(RefPtr< XMLElement >)
Definition XMLElement.cpp:145
void add_content_line(const std::string &)
Add a line of content.
Definition XMLElement.cpp:220
XMLElement & operator=(const XMLElement &)
Definition XMLElement.cpp:62
void set_attributes(RefPtr< XMLAttributeList >)
Assign an attribute list to this element.
Definition XMLElement.cpp:97
int count_attributes() const
Definition XMLElement.cpp:83
void recurse(RefPtr< XMLElement >, std::set< RefPtr< XMLElement > >)
Definition XMLElement.cpp:234
int count_content() const
Definition XMLElement.cpp:203
RefPtr< XMLAttributeList > attributes()
Get access to the attribute list.
Definition XMLElement.cpp:90
const std::string & label() const
Get the label of this node.
Definition XMLElement.cpp:69
friend class ConstRefPtr
Definition XMLElement.h:60
void add_child_rpt(RefPtr< XMLElement >)
Same as add_child, but this allows for repeating children.
Definition XMLElement.cpp:172
const std::string & get_content_line(int)
Definition XMLElement.cpp:210
XMLElement(const std::string &)
Construct a new xml element object and give it a label.
Definition XMLElement.cpp:40