55 const auto &name = attribute.
getName();
64 const auto &name = attribute.
getName();
73 const auto &name = attribute.
getName();
82 const auto &name = attribute.
getName();
91 const auto &name = attribute.
getName();
108 return std::find_if(attributes.begin(), attributes.end(), [&name](
const auto &attribute) { return getName(attribute) == name; });
123 return std::get<XMLAttribute<double>>(*iter).getValue();
126 return default_value.
value();
137 return std::get<XMLAttribute<int>>(*iter).getValue();
140 return default_value.
value();
151 return std::get<XMLAttribute<std::string>>(*iter).getValue();
154 return default_value.
value();
165 return std::get<XMLAttribute<bool>>(*iter).getValue();
168 return default_value.
value();
179 return std::get<XMLAttribute<Eigen::VectorXd>>(*iter).getValue();
189 for (
const auto &element : aAttributes) {
190 const auto &name = element.first;
198 PRECICE_ERROR(
"The tag <{}> in the configuration contains the attribute \"{}\". {}",
_fullName, name, pos->second);
203 if (!matches.empty() && matches.front().distance < 3) {
204 matches.erase(
std::remove_if(matches.begin(), matches.end(), [](
auto &m) { return m.distance > 2; }), matches.end());
207 PRECICE_ERROR(
"The tag <{}> in the configuration contains an unknown attribute \"{}\". Did you mean \"{}\"?",
_fullName, name, fmt::join(stringMatches,
", "));
209 PRECICE_ERROR(
"The tag <{}> in the configuration contains an unknown attribute \"{}\". Expected attributes are {}.",
_fullName, name, fmt::join(expected,
", "));
215 [&aAttributes](
auto &attribute) { attribute.readValue(aAttributes); },
233 bool configured = tag->isConfigured();
235 bool occurOnce = tag->getOccurrence() ==
OCCUR_ONCE;
238 if (not ns.
empty()) {
241 configured |= nsIter->second;
244 if ((not configured) && (occurOnce || occurOnceOrMore)) {
246 if (tag->getNamespace().empty()) {
247 PRECICE_ERROR(
"Tag <{}> was not found but is required to occur at least once.", tag->getName());
249 PRECICE_ERROR(
"Tag <{}:... > was not found but is required to occur at least once.", tag->getNamespace());
264 [](
auto &attribute) { attribute.setRead(
false); },
268 tag->_configured =
false;
269 tag->resetAttributes();
275 return std::visit([](
auto &attribute) {
return attribute.getName(); }, attribute);
#define PRECICE_ERROR(...)
#define PRECICE_TRACE(...)
#define PRECICE_ASSERT(...)
#define PRECICE_UNREACHABLE(...)
T back_inserter(T... args)
This class provides a lightweight logger.
std::string hash() const
returns the hash of the processed XML file
const std::string & getName() const
Represents an XML tag to be configured automatically.
Eigen::VectorXd getEigenVectorXdAttributeValue(const std::string &name) const
std::string _fullName
Combination of name and namespace: _namespace + ":" + _name.
std::map< std::string, bool > _configuredNamespaces
bool hasAttribute(const std::string &attributeName) 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
void readAttributes(const std::map< std::string, std::string > &aAttributes)
reads all attributes of this tag
std::string _namespace
XML namespace of the tag.
XMLTag & setDocumentation(std::string_view documentation)
Adds a description of the purpose of this XML tag.
static std::string_view getOccurrenceString(Occurrence occurrence)
typename std::vector< Attribute > Attributes
const std::string & getFullName() const
Returns full name consisting of xml namespace + ":" + name.
Occurrence
Types of occurrences of an XML tag.
void addAttributeHint(std::string name, std::string message)
Adds a hint for missing attributes, which will be displayed along the error message.
XMLTag(Listener &listener, std::string name, Occurrence occurrence, std::string xmlNamespace="")
Standard constructor.
std::map< std::string, std::string > _attributeHints
std::string _name
Name of the tag.
int getIntAttributeValue(const std::string &name, std::optional< int > default_value=std::nullopt) const
XMLTag & addNamespace(const std::string &namespaceName)
Adds a namespace to the tag.
std::vector< std::string > getAttributeNames() const
double getDoubleAttributeValue(const std::string &name, std::optional< double > default_value=std::nullopt) const
XMLTag & addAttribute(const XMLAttribute< double > &attribute)
Adds a XML attribute by making a copy of the given attribute.
XMLTag & addSubtag(const XMLTag &tag)
Adds an XML tag as subtag by making a copy of the given tag.
void areAllSubtagsConfigured() const
std::variant< XMLAttribute< double >, XMLAttribute< int >, XMLAttribute< std::string >, XMLAttribute< bool >, XMLAttribute< Eigen::VectorXd > > Attribute
T holds_alternative(T... args)
bool isKebabStyle(std::string_view sv)
std::vector< StringMatch > computeMatches(std::string_view given, const Container &expected)
contains the XML configuration parser.
XMLTag getRootTag()
Returns an empty root tag with name "configuration".
std::string getName(const XMLTag::Attribute &attribute)
Returns the name of an Attribute.
std::string configure(XMLTag &tag, const precice::xml::ConfigurationContext &context, std::string_view configurationFilename)
Configures the given configuration from file configurationFilename.
static precice::logging::Logger _log("precicec")
Tightly coupled to the parameters of Participant()
No operation listener for tests.
Callback interface for configuration classes using XMLTag.