10#ifndef Teuchos_XMLOBJECT_H
11#define Teuchos_XMLOBJECT_H
23class EmptyXMLError :
public std::runtime_error
24{
public: EmptyXMLError(
const std::string& what_arg) : std::runtime_error(what_arg) {}};
61 const std::string& getTag()
const;
64 bool hasAttribute(
const std::string& name)
const;
67 const std::string& getAttribute(
const std::string& name)
const;
70 const std::string& getRequired(
const std::string& name)
const;
90 bool getRequiredBool(
const std::string& name)
const ;
105 int numChildren()
const;
113 int findFirstChild(std::string tagName)
const;
116 int numContentLines()
const;
119 const std::string& getContentLine(
int i)
const;
122 std::string toString()
const;
125 void print(std::ostream& os,
int indent)
const;
128 std::string header()
const;
131 std::string terminatedHeader()
const;
134 std::string footer()
const;
140 void checkTag(
const std::string& expected)
const ;
151 void addInt(
const std::string& name,
int val)
155 void addBool(
const std::string& name,
bool val)
163 "XMLObject::addAttribute: XMLObject is empty");
164 ptr_->addAttribute(name, Teuchos::toString(value));
172 void addContent(
const std::string& contentLine);
175 void appendContentLine(
const size_t& i,
const std::string &str) {
176 ptr_->appendContentLine(i, str);
179 void removeContentLine(
const size_t& i) {
180 ptr_->removeContentLine(i);
188#pragma warning(disable:4251)
190 RCP<XMLObjectImplem> ptr_;
A utilities class for Teuchos.
Low level implementation of XMLObject.
Thrown when attempting to parse an empty XML std::string.
Ptr< T > ptr(T *p)
Create a pointer to an object from a raw pointer.
The XMLObjectImplem class takes care of the low-level implementation details of XMLObject.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
double getRequiredDouble(const std::string &name) const
Get a required attribute, returning it as a double.
void addBool(const std::string &name, bool val)
Add a bool as an attribute.
void addDouble(const std::string &name, double val)
Add a double as an attribute.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
std::string toString() const
Represent this node and its children as a std::string.
int getRequiredInt(const std::string &name) const
Get a required attribute, returning it as an int.
void addInt(const std::string &name, int val)
Add an int as an attribute.
T getWithDefault(const std::string &name, const T &defaultValue) const
Get an attribute, assigning a default value if the requested attribute does not exist.
void addAttribute(const std::string &name, T value)
Lookup whether or not Doubles are allowed.
bool hasAttribute(const std::string &name) const
Find out if the current node has an attribute of the specified name.
T getRequired(const std::string &name) const
Get a required attribute, returning it as T.
XMLObject()
Empty constructor.
void print(std::ostream &os, int indent) const
Print this node and its children to stream with the given indentation.
std::string toString(const XMLObject &xml)
Write XMLObject to std::string.
bool isEmpty() const
Find out if a node is empty.
std::ostream & operator<<(std::ostream &os, const XMLObject &xml)
Write XMLObject to os stream.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...