UQTk: Uncertainty Quantification Toolkit  3.1.1
XMLAttributeList.h
Go to the documentation of this file.
1 /* =====================================================================================
2 
3  The UQ Toolkit (UQTk) version 3.1.1
4  Copyright (2021) NTESS
5  https://www.sandia.gov/UQToolkit/
6  https://github.com/sandialabs/UQTk
7 
8  Copyright 2021 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 <uqtk-developers@software.sandia.gov>
26  Sandia National Laboratories, Livermore, CA, USA
27 ===================================================================================== */
28 // -*- C++ -*-
29 
30 #ifndef _util_xml_class_XMLAttributeList_
31 #define _util_xml_class_XMLAttributeList_
32 
33 #include "Object.h"
34 #include <map>
35 
57 class XMLAttributeList : public Object {
58  template <class T> friend class RefPtr;
59  template <class T> friend class ConstRefPtr;
60 public:
62  typedef std::map< std::string, std::string > Map_t;
63 
65  typedef Map_t::iterator iterator;
66  typedef Map_t::const_iterator const_iterator;
67 
70 
71 private:
74 
75 public:
77  virtual ~XMLAttributeList();
78 
79 private:
83 
84 public:
86  int size() const;
87 
89  bool has(const std::string&) const;
90 
93  const std::string& get(const std::string&) const;
94 
97  std::string get(const std::string&, const std::string&) const;
98 
102  int get_int(const std::string&) const;
103 
107  int get_int(const std::string&, int) const;
108 
112  double get_double(const std::string&) const;
113 
117  double get_double(const std::string&, double) const;
118 
124  bool get_bool(const std::string&) const;
125 
129  bool get_bool(const std::string&, bool) const;
130 
132  void set(const std::string&, const std::string&);
133 
135  void set_int(const std::string&, int);
136 
138  void set_double(const std::string&, double);
139 
142  void set_bool(const std::string&, bool);
143 
145  iterator begin();
146 
148  iterator end();
149 
151  const_iterator begin() const;
152 
154  const_iterator end() const;
155 
156 private:
159 
162  void make_lower_case(std::string&) const;
163 
165  iterator get_location(const std::string&);
166 
168  const_iterator get_location(const std::string&) const;
169 
172  bool boolean_value(const std::string&, const char* where) const;
173 };
174 
175 #endif // _util_xml_class_XMLAttributeList_
Definition: Object.h:47
Definition: RefPtr.h:46
Definition: XMLAttributeList.h:57
iterator end()
Get an iterator past the last element.
Definition: XMLAttributeList.cpp:301
void set_double(const std::string &, double)
Assign a numerical value to the given key.
Definition: XMLAttributeList.cpp:266
virtual ~XMLAttributeList()
Destroy this list.
Definition: XMLAttributeList.cpp:92
void set(const std::string &, const std::string &)
Assign a text attribute to the given key.
Definition: XMLAttributeList.cpp:247
XMLAttributeList()
Construct a blank attribute list.
Definition: XMLAttributeList.cpp:77
int size() const
Get the number of attributes in the list.
Definition: XMLAttributeList.cpp:106
Map_t attribute_
The attributes.
Definition: XMLAttributeList.h:158
std::map< std::string, std::string > Map_t
The container type used to hold the attributes.
Definition: XMLAttributeList.h:62
void make_lower_case(std::string &) const
Definition: XMLAttributeList.cpp:322
XMLAttributeList & operator=(const XMLAttributeList &)
Definition: XMLAttributeList.cpp:99
iterator get_location(const std::string &)
Get an iterator pointing to the location of the given string.
Definition: XMLAttributeList.cpp:333
double get_double(const std::string &) const
Definition: XMLAttributeList.cpp:185
bool boolean_value(const std::string &, const char *where) const
Definition: XMLAttributeList.cpp:361
Map_t::iterator iterator
The iterator type returned by this implementation.
Definition: XMLAttributeList.h:65
iterator begin()
Get an iterator to the first element.
Definition: XMLAttributeList.cpp:294
int get_int(const std::string &) const
Definition: XMLAttributeList.cpp:145
void set_int(const std::string &, int)
Assign an integer value to the given key.
Definition: XMLAttributeList.cpp:257
friend class ConstRefPtr
Definition: XMLAttributeList.h:59
bool has(const std::string &) const
Return true if the given key is defined.
Definition: XMLAttributeList.cpp:113
const std::string & get(const std::string &) const
Definition: XMLAttributeList.cpp:120
bool get_bool(const std::string &) const
Definition: XMLAttributeList.cpp:224
void set_bool(const std::string &, bool)
Definition: XMLAttributeList.cpp:282
Map_t::const_iterator const_iterator
Definition: XMLAttributeList.h:66