Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Public Member Functions | Related Functions | List of all members
Teuchos::XMLObject Class Reference

Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object, allowing storage by reference. More...

#include <Teuchos_XMLObject.hpp>

Inheritance diagram for Teuchos::XMLObject:
Inheritance graph
[legend]

Public Member Functions

template<>
bool getRequired (const std::string &name) const
 
template<>
int getRequired (const std::string &name) const
 
template<>
double getRequired (const std::string &name) const
 
template<>
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT bool getRequired (const std::string &name) const
 
template<>
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT int getRequired (const std::string &name) const
 
template<>
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT double getRequired (const std::string &name) const
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const XMLObject &xml)
 Write XMLObject to os stream.
 
std::string toString (const XMLObject &xml)
 Write XMLObject to std::string.
 

Tree-Assembly methods

RCP< XMLObjectImplemptr_
 
void addDouble (const std::string &name, double val)
 Add a double as an attribute.
 
void addInt (const std::string &name, int val)
 Add an int as an attribute.
 
void addBool (const std::string &name, bool val)
 Add a bool as an attribute.
 
template<class T >
void addAttribute (const std::string &name, T value)
 Lookup whether or not Doubles are allowed.
 
void addChild (const XMLObject &child)
 Add a child node to the node.
 
void addContent (const std::string &contentLine)
 Add a line of character content.
 
void appendContentLine (const size_t &i, const std::string &str)
 
void removeContentLine (const size_t &i)
 

Constructors

 XMLObject ()
 Empty constructor.
 
 XMLObject (const std::string &tag)
 Construct using a node labeled by tag.
 
 XMLObject (XMLObjectImplem *ptr)
 Construct with a pointer to the low-level representation.
 

Copy methods

XMLObject deepCopy () const
 Make a deep copy of this object.
 

Data Access methods

const std::string & getTag () const
 Return the tag of the current node.
 
bool hasAttribute (const std::string &name) const
 Find out if the current node has an attribute of the specified name.
 
const std::string & getAttribute (const std::string &name) const
 Return the value of the attribute with the specified name.
 
const std::string & getRequired (const std::string &name) const
 Get an attribute, throwing an std::exception if it is not found.
 
double getRequiredDouble (const std::string &name) const
 Get a required attribute, returning it as a double.
 
int getRequiredInt (const std::string &name) const
 Get a required attribute, returning it as an int.
 
template<class T >
getRequired (const std::string &name) const
 Get a required attribute, returning it as T.
 
bool getRequiredBool (const std::string &name) const
 Get a required attribute, returning it as a bool.
 
template<class T >
getWithDefault (const std::string &name, const T &defaultValue) const
 Get an attribute, assigning a default value if the requested attribute does not exist.
 
int numChildren () const
 Return the number of child nodes owned by this node.
 
const XMLObjectgetChild (int i) const
 Return the i-th child node.
 
int findFirstChild (std::string tagName) const
 Returns the index of the first child found with the given tag name. Returns -1 if no child is found.
 
int numContentLines () const
 Return the number of lines of character content stored in this node.
 
const std::string & getContentLine (int i) const
 Return the i-th line of character content stored in this node.
 
std::string toString () const
 Represent this node and its children as a std::string.
 
void print (std::ostream &os, int indent) const
 Print this node and its children to stream with the given indentation.
 
std::string header () const
 Write the header for this object to a std::string.
 
std::string terminatedHeader () const
 Write the header for this object to a std::string.
 
std::string footer () const
 Write the footer for this object to a std::string.
 
bool isEmpty () const
 Find out if a node is empty.
 
void checkTag (const std::string &expected) const
 Check that a tag is equal to an expected std::string.
 

Detailed Description

Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object, allowing storage by reference.

Definition at line 62 of file Teuchos_XMLObject.hpp.

Constructor & Destructor Documentation

◆ XMLObject() [1/3]

Teuchos::XMLObject::XMLObject ( )
inline

Empty constructor.

Definition at line 69 of file Teuchos_XMLObject.hpp.

◆ XMLObject() [2/3]

Teuchos::XMLObject::XMLObject ( const std::string &  tag)

Construct using a node labeled by tag.

Definition at line 49 of file Teuchos_XMLObject.cpp.

◆ XMLObject() [3/3]

Teuchos::XMLObject::XMLObject ( XMLObjectImplem ptr)

Construct with a pointer to the low-level representation.

This is used to allow construction of an XMLObject from the XMLObjectImplem* return value of ExceptionBase::toXML().

Definition at line 54 of file Teuchos_XMLObject.cpp.

Member Function Documentation

◆ deepCopy()

XMLObject Teuchos::XMLObject::deepCopy ( ) const

Make a deep copy of this object.

Definition at line 59 of file Teuchos_XMLObject.cpp.

◆ getTag()

const std::string & Teuchos::XMLObject::getTag ( ) const

Return the tag of the current node.

Definition at line 69 of file Teuchos_XMLObject.cpp.

◆ hasAttribute()

bool Teuchos::XMLObject::hasAttribute ( const std::string &  name) const

Find out if the current node has an attribute of the specified name.

Definition at line 77 of file Teuchos_XMLObject.cpp.

◆ getAttribute()

const std::string & Teuchos::XMLObject::getAttribute ( const std::string &  name) const

Return the value of the attribute with the specified name.

Definition at line 85 of file Teuchos_XMLObject.cpp.

◆ getRequired() [1/8]

const std::string & Teuchos::XMLObject::getRequired ( const std::string &  name) const

Get an attribute, throwing an std::exception if it is not found.

Definition at line 93 of file Teuchos_XMLObject.cpp.

◆ getRequiredDouble()

double Teuchos::XMLObject::getRequiredDouble ( const std::string &  name) const
inline

Get a required attribute, returning it as a double.

Definition at line 105 of file Teuchos_XMLObject.hpp.

◆ getRequiredInt()

int Teuchos::XMLObject::getRequiredInt ( const std::string &  name) const
inline

Get a required attribute, returning it as an int.

Definition at line 109 of file Teuchos_XMLObject.hpp.

◆ getRequired() [2/8]

template<class T >
T Teuchos::XMLObject::getRequired ( const std::string &  name) const
inline

Get a required attribute, returning it as T.

Definition at line 114 of file Teuchos_XMLObject.hpp.

◆ getRequiredBool()

bool Teuchos::XMLObject::getRequiredBool ( const std::string &  name) const

Get a required attribute, returning it as a bool.

Definition at line 130 of file Teuchos_XMLObject.cpp.

◆ getWithDefault()

template<class T >
T Teuchos::XMLObject::getWithDefault ( const std::string &  name,
const T &  defaultValue 
) const
inline

Get an attribute, assigning a default value if the requested attribute does not exist.

Definition at line 127 of file Teuchos_XMLObject.hpp.

◆ numChildren()

int Teuchos::XMLObject::numChildren ( ) const

Return the number of child nodes owned by this node.

Definition at line 164 of file Teuchos_XMLObject.cpp.

◆ getChild()

const XMLObject & Teuchos::XMLObject::getChild ( int  i) const

Return the i-th child node.

Definition at line 172 of file Teuchos_XMLObject.cpp.

◆ findFirstChild()

int Teuchos::XMLObject::findFirstChild ( std::string  tagName) const

Returns the index of the first child found with the given tag name. Returns -1 if no child is found.

Definition at line 179 of file Teuchos_XMLObject.cpp.

◆ numContentLines()

int Teuchos::XMLObject::numContentLines ( ) const

Return the number of lines of character content stored in this node.

Definition at line 190 of file Teuchos_XMLObject.cpp.

◆ getContentLine()

const std::string & Teuchos::XMLObject::getContentLine ( int  i) const

Return the i-th line of character content stored in this node.

Definition at line 198 of file Teuchos_XMLObject.cpp.

◆ toString()

std::string Teuchos::XMLObject::toString ( ) const

Represent this node and its children as a std::string.

Definition at line 206 of file Teuchos_XMLObject.cpp.

◆ print()

void Teuchos::XMLObject::print ( std::ostream &  os,
int  indent 
) const

Print this node and its children to stream with the given indentation.

Definition at line 214 of file Teuchos_XMLObject.cpp.

◆ header()

std::string Teuchos::XMLObject::header ( ) const

Write the header for this object to a std::string.

Definition at line 222 of file Teuchos_XMLObject.cpp.

◆ terminatedHeader()

std::string Teuchos::XMLObject::terminatedHeader ( ) const

Write the header for this object to a std::string.

Definition at line 230 of file Teuchos_XMLObject.cpp.

◆ footer()

std::string Teuchos::XMLObject::footer ( ) const

Write the footer for this object to a std::string.

Definition at line 238 of file Teuchos_XMLObject.cpp.

◆ isEmpty()

bool Teuchos::XMLObject::isEmpty ( ) const
inline

Find out if a node is empty.

Definition at line 169 of file Teuchos_XMLObject.hpp.

◆ checkTag()

void Teuchos::XMLObject::checkTag ( const std::string &  expected) const

Check that a tag is equal to an expected std::string.

Definition at line 246 of file Teuchos_XMLObject.cpp.

◆ addDouble()

void Teuchos::XMLObject::addDouble ( const std::string &  name,
double  val 
)
inline

Add a double as an attribute.

Definition at line 179 of file Teuchos_XMLObject.hpp.

◆ addInt()

void Teuchos::XMLObject::addInt ( const std::string &  name,
int  val 
)
inline

Add an int as an attribute.

Definition at line 183 of file Teuchos_XMLObject.hpp.

◆ addBool()

void Teuchos::XMLObject::addBool ( const std::string &  name,
bool  val 
)
inline

Add a bool as an attribute.

Definition at line 187 of file Teuchos_XMLObject.hpp.

◆ addAttribute()

template<class T >
void Teuchos::XMLObject::addAttribute ( const std::string &  name,
value 
)
inline

Lookup whether or not Doubles are allowed.

Definition at line 193 of file Teuchos_XMLObject.hpp.

◆ addChild()

void Teuchos::XMLObject::addChild ( const XMLObject child)

Add a child node to the node.

Definition at line 255 of file Teuchos_XMLObject.cpp.

◆ addContent()

void Teuchos::XMLObject::addContent ( const std::string &  contentLine)

Add a line of character content.

Definition at line 263 of file Teuchos_XMLObject.cpp.

◆ appendContentLine()

void Teuchos::XMLObject::appendContentLine ( const size_t &  i,
const std::string &  str 
)
inline

Definition at line 207 of file Teuchos_XMLObject.hpp.

◆ removeContentLine()

void Teuchos::XMLObject::removeContentLine ( const size_t &  i)
inline

Definition at line 211 of file Teuchos_XMLObject.hpp.

◆ getRequired() [3/8]

template<>
bool Teuchos::XMLObject::getRequired ( const std::string &  name) const

Definition at line 103 of file Teuchos_XMLObject.cpp.

◆ getRequired() [4/8]

template<>
int Teuchos::XMLObject::getRequired ( const std::string &  name) const

Definition at line 110 of file Teuchos_XMLObject.cpp.

◆ getRequired() [5/8]

template<>
double Teuchos::XMLObject::getRequired ( const std::string &  name) const

Definition at line 117 of file Teuchos_XMLObject.cpp.

◆ getRequired() [6/8]

template<>
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT bool Teuchos::XMLObject::getRequired ( const std::string &  name) const

◆ getRequired() [7/8]

template<>
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT int Teuchos::XMLObject::getRequired ( const std::string &  name) const

◆ getRequired() [8/8]

template<>
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT double Teuchos::XMLObject::getRequired ( const std::string &  name) const

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const XMLObject xml 
)
related

Write XMLObject to os stream.

Definition at line 250 of file Teuchos_XMLObject.hpp.

◆ toString()

std::string toString ( const XMLObject xml)
related

Write XMLObject to std::string.

Definition at line 261 of file Teuchos_XMLObject.hpp.

Member Data Documentation

◆ ptr_

RCP<XMLObjectImplem> Teuchos::XMLObject::ptr_
protected

Definition at line 222 of file Teuchos_XMLObject.hpp.


The documentation for this class was generated from the following files: