preCICE v3.1.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
precice::xml::XMLTag Class Reference

Represents an XML tag to be configured automatically. More...

#include <XMLTag.hpp>

Collaboration diagram for precice::xml::XMLTag:
[legend]

Classes

struct  Listener
 Callback interface for configuration classes using XMLTag. More...
 

Public Types

enum  Occurrence {
  OCCUR_NOT_OR_ONCE , OCCUR_ONCE , OCCUR_ONCE_OR_MORE , OCCUR_ARBITRARY ,
  OCCUR_ARBITRARY_NESTED
}
 Types of occurrences of an XML tag. More...
 
using Namespaces = typename std::vector<std::string>
 
using Subtags = typename std::vector<std::shared_ptr<XMLTag>>
 
template<typename T >
using AttributeMap = typename std::map<std::string, XMLAttribute<T>>
 

Public Member Functions

 XMLTag (Listener &listener, std::string name, Occurrence occurrence, std::string xmlNamespace="")
 Standard constructor.
 
XMLTagsetDocumentation (const std::string &documentation)
 Adds a description of the purpose of this XML tag.
 
std::string getDocumentation () const
 
XMLTagaddNamespace (const std::string &namespaceName)
 Adds a namespace to the tag.
 
XMLTagaddSubtag (const XMLTag &tag)
 Adds an XML tag as subtag by making a copy of the given tag.
 
const SubtagsgetSubtags () const
 
XMLTagaddAttribute (const XMLAttribute< double > &attribute)
 Removes the XML subtag with given name.
 
XMLTagaddAttribute (const XMLAttribute< int > &attribute)
 
XMLTagaddAttribute (const XMLAttribute< std::string > &attribute)
 Adds a XML attribute by making a copy of the given attribute.
 
XMLTagaddAttribute (const XMLAttribute< bool > &attribute)
 Adds a XML attribute by making a copy of the given attribute.
 
XMLTagaddAttribute (const XMLAttribute< Eigen::VectorXd > &attribute)
 Adds a XML attribute by making a copy of the given attribute.
 
void addAttributeHint (std::string name, std::string message)
 Adds a hint for missing attributes, which will be displayed along the error message.
 
bool hasAttribute (const std::string &attributeName)
 
template<typename Container >
void addSubtags (const Container &subtags)
 
const std::stringgetName () const
 Returns name (without namespace).
 
const std::stringgetNamespace () const
 Returns xml namespace.
 
const NamespacesgetNamespaces () const
 
const std::stringgetFullName () const
 Returns full name consisting of xml namespace + ":" + name.
 
double getDoubleAttributeValue (const std::string &name, std::optional< double > default_value=std::nullopt) const
 
int getIntAttributeValue (const std::string &name, std::optional< int > default_value=std::nullopt) const
 
std::string getStringAttributeValue (const std::string &name, std::optional< std::string > default_value=std::nullopt) const
 
bool getBooleanAttributeValue (const std::string &name, std::optional< bool > default_value=std::nullopt) const
 
const AttributeMap< double > & getDoubleAttributes () const
 
const AttributeMap< int > & getIntAttributes () const
 
const AttributeMap< std::string > & getStringAttributes () const
 
const AttributeMap< bool > & getBooleanAttributes () const
 
const AttributeMap< Eigen::VectorXd > & getEigenVectorXdAttributes () const
 
Eigen::VectorXd getEigenVectorXdAttributeValue (const std::string &name, int dimensions) const
 Returns Eigen vector attribute value with given dimensions.
 
bool isConfigured () const
 
Occurrence getOccurrence () const
 
void clear ()
 Removes all attributes and subtags.
 
void readAttributes (const std::map< std::string, std::string > &aAttributes)
 reads all attributes of this tag
 

Static Public Member Functions

static std::string getOccurrenceString (Occurrence occurrence)
 

Private Member Functions

void areAllSubtagsConfigured () const
 
void resetAttributes ()
 

Private Attributes

logging::Logger _log {"xml::XMLTag"}
 
Listener_listener
 
std::string _name
 Name of the tag.
 
std::string _namespace
 XML namespace of the tag.
 
std::string _fullName
 Combination of name and namespace: _namespace + ":" + _name.
 
std::string _doc
 
bool _configured = false
 
Occurrence _occurrence
 
Namespaces _namespaces
 
Subtags _subtags
 
std::map< std::string, bool_configuredNamespaces
 
std::set< std::string_attributes
 
AttributeMap< double_doubleAttributes
 
AttributeMap< int_intAttributes
 
AttributeMap< std::string_stringAttributes
 
AttributeMap< bool_booleanAttributes
 
AttributeMap< Eigen::VectorXd > _eigenVectorXdAttributes
 
std::map< std::string, std::string_attributeHints
 

Friends

class precice::xml::ConfigParser
 

Detailed Description

Represents an XML tag to be configured automatically.

Definition at line 31 of file XMLTag.hpp.

Member Typedef Documentation

◆ AttributeMap

Definition at line 40 of file XMLTag.hpp.

◆ Namespaces

Definition at line 35 of file XMLTag.hpp.

◆ Subtags

Definition at line 37 of file XMLTag.hpp.

Member Enumeration Documentation

◆ Occurrence

Types of occurrences of an XML tag.

Enumerator
OCCUR_NOT_OR_ONCE 
OCCUR_ONCE 
OCCUR_ONCE_OR_MORE 
OCCUR_ARBITRARY 
OCCUR_ARBITRARY_NESTED 

Definition at line 67 of file XMLTag.hpp.

Constructor & Destructor Documentation

◆ XMLTag()

precice::xml::XMLTag::XMLTag ( Listener & listener,
std::string name,
Occurrence occurrence,
std::string xmlNamespace = "" )

Standard constructor.

Parameters
[in]listenerConfiguration listener receiving callbacks from this tag.
[in]nameName of the XML tag.
[in]occurrenceDefines the occurrences of the tag in the configuration.
[in]xmlNamespaceDefines a prefix/namespace for the tag. Tags with equal namespace or treated as group.

Definition at line 12 of file XMLTag.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addAttribute() [1/5]

XMLTag & precice::xml::XMLTag::addAttribute ( const XMLAttribute< bool > & attribute)

Adds a XML attribute by making a copy of the given attribute.

Definition at line 83 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addAttribute() [2/5]

XMLTag & precice::xml::XMLTag::addAttribute ( const XMLAttribute< double > & attribute)

Removes the XML subtag with given name.

Adds a XML attribute by making a copy of the given attribute.

Definition at line 53 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addAttribute() [3/5]

XMLTag & precice::xml::XMLTag::addAttribute ( const XMLAttribute< Eigen::VectorXd > & attribute)

Adds a XML attribute by making a copy of the given attribute.

Definition at line 93 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addAttribute() [4/5]

XMLTag & precice::xml::XMLTag::addAttribute ( const XMLAttribute< int > & attribute)

Definition at line 63 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addAttribute() [5/5]

XMLTag & precice::xml::XMLTag::addAttribute ( const XMLAttribute< std::string > & attribute)

Adds a XML attribute by making a copy of the given attribute.

Definition at line 73 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addAttributeHint()

void precice::xml::XMLTag::addAttributeHint ( std::string name,
std::string message )

Adds a hint for missing attributes, which will be displayed along the error message.

Definition at line 104 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addNamespace()

XMLTag & precice::xml::XMLTag::addNamespace ( const std::string & namespaceName)

Adds a namespace to the tag.

Only used for outputting correct XML format, such that, e.g., internet browsers display no errors when viewing an XML configuration.

Definition at line 35 of file XMLTag.cpp.

◆ addSubtag()

XMLTag & precice::xml::XMLTag::addSubtag ( const XMLTag & tag)

Adds an XML tag as subtag by making a copy of the given tag.

Definition at line 41 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addSubtags()

template<typename Container >
void precice::xml::XMLTag::addSubtags ( const Container & subtags)
inline

Definition at line 143 of file XMLTag.hpp.

Here is the call graph for this function:

◆ areAllSubtagsConfigured()

void precice::xml::XMLTag::areAllSubtagsConfigured ( ) const
private

Definition at line 314 of file XMLTag.cpp.

Here is the call graph for this function:

◆ clear()

void precice::xml::XMLTag::clear ( )

Removes all attributes and subtags.

Definition at line 374 of file XMLTag.cpp.

◆ getBooleanAttributes()

const AttributeMap< bool > & precice::xml::XMLTag::getBooleanAttributes ( ) const
inline

Definition at line 198 of file XMLTag.hpp.

◆ getBooleanAttributeValue()

bool precice::xml::XMLTag::getBooleanAttributeValue ( const std::string & name,
std::optional< bool > default_value = std::nullopt ) const

Definition at line 155 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getDocumentation()

std::string precice::xml::XMLTag::getDocumentation ( ) const
inline

Definition at line 98 of file XMLTag.hpp.

◆ getDoubleAttributes()

const AttributeMap< double > & precice::xml::XMLTag::getDoubleAttributes ( ) const
inline

Definition at line 183 of file XMLTag.hpp.

◆ getDoubleAttributeValue()

double precice::xml::XMLTag::getDoubleAttributeValue ( const std::string & name,
std::optional< double > default_value = std::nullopt ) const

Definition at line 116 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getEigenVectorXdAttributes()

const AttributeMap< Eigen::VectorXd > & precice::xml::XMLTag::getEigenVectorXdAttributes ( ) const
inline

Definition at line 203 of file XMLTag.hpp.

◆ getEigenVectorXdAttributeValue()

Eigen::VectorXd precice::xml::XMLTag::getEigenVectorXdAttributeValue ( const std::string & name,
int dimensions ) const

Returns Eigen vector attribute value with given dimensions.

If the parsed vector has less dimensions then required, an error message is thrown.

Parameters
[in]nameName of attribute.
[in]dimensionsDimensions of the vector to be returned.

Definition at line 168 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getFullName()

const std::string & precice::xml::XMLTag::getFullName ( ) const
inline

Returns full name consisting of xml namespace + ":" + name.

Definition at line 170 of file XMLTag.hpp.

◆ getIntAttributes()

const AttributeMap< int > & precice::xml::XMLTag::getIntAttributes ( ) const
inline

Definition at line 188 of file XMLTag.hpp.

◆ getIntAttributeValue()

int precice::xml::XMLTag::getIntAttributeValue ( const std::string & name,
std::optional< int > default_value = std::nullopt ) const

Definition at line 129 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getName()

const std::string & precice::xml::XMLTag::getName ( ) const
inline

Returns name (without namespace).

The method getFullName() returns the name with namespace.

Definition at line 153 of file XMLTag.hpp.

◆ getNamespace()

const std::string & precice::xml::XMLTag::getNamespace ( ) const
inline

Returns xml namespace.

Definition at line 159 of file XMLTag.hpp.

◆ getNamespaces()

const Namespaces & precice::xml::XMLTag::getNamespaces ( ) const
inline

Definition at line 164 of file XMLTag.hpp.

◆ getOccurrence()

Occurrence precice::xml::XMLTag::getOccurrence ( ) const
inline

Definition at line 226 of file XMLTag.hpp.

◆ getOccurrenceString()

std::string precice::xml::XMLTag::getOccurrenceString ( XMLTag::Occurrence occurrence)
static

Definition at line 411 of file XMLTag.cpp.

◆ getStringAttributes()

const AttributeMap< std::string > & precice::xml::XMLTag::getStringAttributes ( ) const
inline

Definition at line 193 of file XMLTag.hpp.

◆ getStringAttributeValue()

std::string precice::xml::XMLTag::getStringAttributeValue ( const std::string & name,
std::optional< std::string > default_value = std::nullopt ) const

Definition at line 142 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getSubtags()

const Subtags & precice::xml::XMLTag::getSubtags ( ) const
inline

Definition at line 114 of file XMLTag.hpp.

◆ hasAttribute()

bool precice::xml::XMLTag::hasAttribute ( const std::string & attributeName)

Definition at line 111 of file XMLTag.cpp.

Here is the call graph for this function:

◆ isConfigured()

bool precice::xml::XMLTag::isConfigured ( ) const
inline

Definition at line 221 of file XMLTag.hpp.

◆ readAttributes()

void precice::xml::XMLTag::readAttributes ( const std::map< std::string, std::string > & aAttributes)

reads all attributes of this tag

Definition at line 190 of file XMLTag.cpp.

Here is the call graph for this function:

◆ resetAttributes()

void precice::xml::XMLTag::resetAttributes ( )
private

Definition at line 340 of file XMLTag.cpp.

Here is the call graph for this function:

◆ setDocumentation()

XMLTag & precice::xml::XMLTag::setDocumentation ( const std::string & documentation)

Adds a description of the purpose of this XML tag.

The description and more information is printed with printDocumentation().

Definition at line 29 of file XMLTag.cpp.

Friends And Related Symbol Documentation

◆ precice::xml::ConfigParser

Definition at line 32 of file XMLTag.hpp.

Member Data Documentation

◆ _attributeHints

std::map<std::string, std::string> precice::xml::XMLTag::_attributeHints
private

Definition at line 275 of file XMLTag.hpp.

◆ _attributes

std::set<std::string> precice::xml::XMLTag::_attributes
private

Definition at line 263 of file XMLTag.hpp.

◆ _booleanAttributes

AttributeMap<bool> precice::xml::XMLTag::_booleanAttributes
private

Definition at line 271 of file XMLTag.hpp.

◆ _configured

bool precice::xml::XMLTag::_configured = false
private

Definition at line 253 of file XMLTag.hpp.

◆ _configuredNamespaces

std::map<std::string, bool> precice::xml::XMLTag::_configuredNamespaces
private

Definition at line 261 of file XMLTag.hpp.

◆ _doc

std::string precice::xml::XMLTag::_doc
private

Definition at line 251 of file XMLTag.hpp.

◆ _doubleAttributes

AttributeMap<double> precice::xml::XMLTag::_doubleAttributes
private

Definition at line 265 of file XMLTag.hpp.

◆ _eigenVectorXdAttributes

AttributeMap<Eigen::VectorXd> precice::xml::XMLTag::_eigenVectorXdAttributes
private

Definition at line 273 of file XMLTag.hpp.

◆ _fullName

std::string precice::xml::XMLTag::_fullName
private

Combination of name and namespace: _namespace + ":" + _name.

Definition at line 249 of file XMLTag.hpp.

◆ _intAttributes

AttributeMap<int> precice::xml::XMLTag::_intAttributes
private

Definition at line 267 of file XMLTag.hpp.

◆ _listener

Listener& precice::xml::XMLTag::_listener
private

Definition at line 240 of file XMLTag.hpp.

◆ _log

logging::Logger precice::xml::XMLTag::_log {"xml::XMLTag"}
mutableprivate

Definition at line 238 of file XMLTag.hpp.

◆ _name

std::string precice::xml::XMLTag::_name
private

Name of the tag.

Definition at line 243 of file XMLTag.hpp.

◆ _namespace

std::string precice::xml::XMLTag::_namespace
private

XML namespace of the tag.

Definition at line 246 of file XMLTag.hpp.

◆ _namespaces

Namespaces precice::xml::XMLTag::_namespaces
private

Definition at line 257 of file XMLTag.hpp.

◆ _occurrence

Occurrence precice::xml::XMLTag::_occurrence
private

Definition at line 255 of file XMLTag.hpp.

◆ _stringAttributes

AttributeMap<std::string> precice::xml::XMLTag::_stringAttributes
private

Definition at line 269 of file XMLTag.hpp.

◆ _subtags

Subtags precice::xml::XMLTag::_subtags
private

Definition at line 259 of file XMLTag.hpp.


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