preCICE v3.2.0
|
Represents an XML tag to be configured automatically. More...
#include <XMLTag.hpp>
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. | |
XMLTag & | setDocumentation (std::string_view documentation) |
Adds a description of the purpose of this XML tag. | |
std::string | getDocumentation () const |
XMLTag & | addNamespace (const std::string &namespaceName) |
Adds a namespace to the tag. | |
XMLTag & | addSubtag (const XMLTag &tag) |
Adds an XML tag as subtag by making a copy of the given tag. | |
const Subtags & | getSubtags () const |
XMLTag & | addAttribute (const XMLAttribute< double > &attribute) |
Adds a XML attribute by making a copy of the given attribute. | |
XMLTag & | addAttribute (const XMLAttribute< int > &attribute) |
XMLTag & | addAttribute (const XMLAttribute< std::string > &attribute) |
Adds a XML attribute by making a copy of the given attribute. | |
XMLTag & | addAttribute (const XMLAttribute< bool > &attribute) |
Adds a XML attribute by making a copy of the given attribute. | |
XMLTag & | addAttribute (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::string & | getName () const |
Returns name (without namespace). | |
const std::string & | getNamespace () const |
Returns xml namespace. | |
const Namespaces & | getNamespaces () const |
const std::string & | getFullName () 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::string > | getAttributeNames () const |
const Attributes & | getAttributes () 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 |
Represents an XML tag to be configured automatically.
Definition at line 28 of file XMLTag.hpp.
Definition at line 36 of file XMLTag.hpp.
using precice::xml::XMLTag::Attributes = typename std::vector<Attribute> |
Definition at line 43 of file XMLTag.hpp.
using precice::xml::XMLTag::Namespaces = typename std::vector<std::string> |
Definition at line 32 of file XMLTag.hpp.
using precice::xml::XMLTag::Subtags = typename std::vector<std::shared_ptr<XMLTag>> |
Definition at line 34 of file XMLTag.hpp.
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.
precice::xml::XMLTag::XMLTag | ( | Listener & | listener, |
std::string | name, | ||
Occurrence | occurrence, | ||
std::string | xmlNamespace = "" ) |
Standard constructor.
[in] | listener | Configuration listener receiving callbacks from this tag. |
[in] | name | Name of the XML tag. |
[in] | occurrence | Defines the occurrences of the tag in the configuration. |
[in] | xmlNamespace | Defines a prefix/namespace for the tag. Tags with equal namespace or treated as group. |
Definition at line 11 of file XMLTag.cpp.
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.
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.
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.
XMLTag & precice::xml::XMLTag::addAttribute | ( | const XMLAttribute< int > & | attribute | ) |
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.
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.
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.
Adds an XML tag as subtag by making a copy of the given tag.
Definition at line 41 of file XMLTag.cpp.
|
inline |
|
private |
std::vector< std::string > precice::xml::XMLTag::getAttributeNames | ( | ) | const |
|
inline |
Definition at line 187 of file XMLTag.hpp.
bool precice::xml::XMLTag::getBooleanAttributeValue | ( | const std::string & | name, |
std::optional< bool > | default_value = std::nullopt ) const |
|
inline |
Definition at line 101 of file XMLTag.hpp.
double precice::xml::XMLTag::getDoubleAttributeValue | ( | const std::string & | name, |
std::optional< double > | default_value = std::nullopt ) const |
Eigen::VectorXd precice::xml::XMLTag::getEigenVectorXdAttributeValue | ( | const std::string & | name | ) | const |
|
inline |
Returns full name consisting of xml namespace + ":" + name.
Definition at line 170 of file XMLTag.hpp.
int precice::xml::XMLTag::getIntAttributeValue | ( | const std::string & | name, |
std::optional< int > | default_value = std::nullopt ) const |
|
inline |
Returns name (without namespace).
The method getFullName() returns the name with namespace.
Definition at line 153 of file XMLTag.hpp.
|
inline |
Returns xml namespace.
Definition at line 159 of file XMLTag.hpp.
|
inline |
Definition at line 164 of file XMLTag.hpp.
|
inline |
Definition at line 197 of file XMLTag.hpp.
|
static |
Definition at line 302 of file XMLTag.cpp.
std::string precice::xml::XMLTag::getStringAttributeValue | ( | const std::string & | name, |
std::optional< std::string > | default_value = std::nullopt ) const |
|
inline |
Definition at line 117 of file XMLTag.hpp.
bool precice::xml::XMLTag::hasAttribute | ( | const std::string & | attributeName | ) | const |
Definition at line 112 of file XMLTag.cpp.
|
inline |
Definition at line 192 of file XMLTag.hpp.
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.
|
private |
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.
|
friend |
Definition at line 29 of file XMLTag.hpp.
|
private |
Definition at line 233 of file XMLTag.hpp.
|
private |
Definition at line 231 of file XMLTag.hpp.
|
private |
Definition at line 221 of file XMLTag.hpp.
|
private |
Definition at line 229 of file XMLTag.hpp.
|
private |
Definition at line 219 of file XMLTag.hpp.
|
private |
Combination of name and namespace: _namespace + ":" + _name.
Definition at line 217 of file XMLTag.hpp.
|
private |
Definition at line 208 of file XMLTag.hpp.
|
mutableprivate |
Definition at line 206 of file XMLTag.hpp.
|
private |
Name of the tag.
Definition at line 211 of file XMLTag.hpp.
|
private |
XML namespace of the tag.
Definition at line 214 of file XMLTag.hpp.
|
private |
Definition at line 225 of file XMLTag.hpp.
|
private |
Definition at line 223 of file XMLTag.hpp.
|
private |
Definition at line 227 of file XMLTag.hpp.