preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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>>
 
using Attribute
 
using Attributes = typename std::vector<Attribute>
 

Public Member Functions

 XMLTag (Listener &listener, std::string name, Occurrence occurrence, std::string xmlNamespace="")
 Standard constructor.
 
XMLTagsetDocumentation (std::string_view 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)
 Adds a XML attribute by making a copy of the given attribute.
 
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) const
 
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
 
Eigen::VectorXd getEigenVectorXdAttributeValue (const std::string &name) const
 
std::vector< std::stringgetAttributeNames () const
 
const AttributesgetAttributes () const
 
bool isConfigured () const
 
Occurrence getOccurrence () const
 
void readAttributes (const std::map< std::string, std::string > &aAttributes)
 reads all attributes of this tag
 

Static Public Member Functions

static std::string_view 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
 
Attributes _attributes
 
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 28 of file XMLTag.hpp.

Member Typedef Documentation

◆ Attribute

Initial value:
XMLAttribute<double>,
XMLAttribute<int>,
XMLAttribute<std::string>,
XMLAttribute<bool>,
XMLAttribute<Eigen::VectorXd>>

Definition at line 36 of file XMLTag.hpp.

◆ Attributes

Definition at line 43 of file XMLTag.hpp.

◆ Namespaces

Definition at line 32 of file XMLTag.hpp.

◆ Subtags

Definition at line 34 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 70 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 11 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 80 of file XMLTag.cpp.

Here is the call graph for this function:

◆ addAttribute() [2/5]

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

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 89 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 62 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 71 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 98 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 229 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getAttributeNames()

std::vector< std::string > precice::xml::XMLTag::getAttributeNames ( ) const

Definition at line 220 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getAttributes()

const Attributes & precice::xml::XMLTag::getAttributes ( ) const
inline

Definition at line 187 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 159 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getDocumentation()

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

Definition at line 101 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 117 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getEigenVectorXdAttributeValue()

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

Definition at line 173 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.

◆ getIntAttributeValue()

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

Definition at line 131 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 197 of file XMLTag.hpp.

◆ getOccurrenceString()

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

Definition at line 302 of file XMLTag.cpp.

◆ getStringAttributeValue()

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

Definition at line 145 of file XMLTag.cpp.

Here is the call graph for this function:

◆ getSubtags()

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

Definition at line 117 of file XMLTag.hpp.

◆ hasAttribute()

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

Definition at line 112 of file XMLTag.cpp.

◆ isConfigured()

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

Definition at line 192 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 184 of file XMLTag.cpp.

Here is the call graph for this function:

◆ resetAttributes()

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

Definition at line 255 of file XMLTag.cpp.

Here is the call graph for this function:

◆ setDocumentation()

XMLTag & precice::xml::XMLTag::setDocumentation ( std::string_view 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

friend class precice::xml::ConfigParser
friend

Definition at line 29 of file XMLTag.hpp.

Member Data Documentation

◆ _attributeHints

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

Definition at line 233 of file XMLTag.hpp.

◆ _attributes

Attributes precice::xml::XMLTag::_attributes
private

Definition at line 231 of file XMLTag.hpp.

◆ _configured

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

Definition at line 221 of file XMLTag.hpp.

◆ _configuredNamespaces

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

Definition at line 229 of file XMLTag.hpp.

◆ _doc

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

Definition at line 219 of file XMLTag.hpp.

◆ _fullName

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

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

Definition at line 217 of file XMLTag.hpp.

◆ _listener

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

Definition at line 208 of file XMLTag.hpp.

◆ _log

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

Definition at line 206 of file XMLTag.hpp.

◆ _name

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

Name of the tag.

Definition at line 211 of file XMLTag.hpp.

◆ _namespace

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

XML namespace of the tag.

Definition at line 214 of file XMLTag.hpp.

◆ _namespaces

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

Definition at line 225 of file XMLTag.hpp.

◆ _occurrence

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

Definition at line 223 of file XMLTag.hpp.

◆ _subtags

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

Definition at line 227 of file XMLTag.hpp.


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