5#include <initializer_list>
19template <
typename ATTRIBUTE_T>
21 static_assert(std::is_default_constructible<ATTRIBUTE_T>::value,
"The value type of XMLAttributes need to be default-constructible.");
55 static_assert(std::is_convertible<T, ATTRIBUTE_T>::value,
"Type of initializer_list must be converible to ATTRIBUTE_T!");
56 return setOptions(std::vector<ATTRIBUTE_T>(options.begin(), options.end()));
81 void readValue(std::string_view tagName,
const std::map<std::string, std::string> &aAttributes);
123 template <
typename VALUE_T>
124 typename std::enable_if<
125 std::is_same<VALUE_T, ATTRIBUTE_T>::value && not std::is_same<VALUE_T, Eigen::VectorXd>::value,
void>::type
126 set(ATTRIBUTE_T &toSet,
const VALUE_T &setter);
129 template <
typename VALUE_T>
130 typename std::enable_if<
131 std::is_same<VALUE_T, ATTRIBUTE_T>::value && std::is_same<VALUE_T, Eigen::VectorXd>::value,
void>::type
132 set(ATTRIBUTE_T &toSet,
const VALUE_T &setter);
135template <
typename ATTRIBUTE_T>
138 _doc = documentation;
142template <
typename ATTRIBUTE_T>
145 const auto iter = std::unique(options.begin(), options.end());
146 _options = std::vector<ATTRIBUTE_T>(options.begin(), iter);
151template <
typename ATTRIBUTE_T>
160template <
typename ATTRIBUTE_T>
166 const auto position = aAttributes.find(
getName());
167 if (position == aAttributes.end()) {
173 }
catch (
const std::exception &e) {
178 std::ostringstream stream;
179 stream <<
"Invalid value \"" <<
_value <<
"\" of attribute \""
183 stream <<
"value must be \"" << *first <<
'"';
186 for (; first !=
_options.end(); ++first) {
187 stream <<
" or value must be \"" << *first <<
'"';
197template <
typename ATTRIBUTE_T>
198template <
typename VALUE_T>
199typename std::enable_if<
200 std::is_same<VALUE_T, ATTRIBUTE_T>::value && not std::is_same<VALUE_T, Eigen::VectorXd>::value,
void>::type
203 const VALUE_T &setter)
208template <
typename ATTRIBUTE_T>
209template <
typename VALUE_T>
210typename std::enable_if<
211 std::is_same<VALUE_T, ATTRIBUTE_T>::value && std::is_same<VALUE_T, Eigen::VectorXd>::value,
void>::type
214 const VALUE_T &setter)
#define PRECICE_ERROR(...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
This class provides a lightweight logger.
std::enable_if< std::is_same< VALUE_T, ATTRIBUTE_T >::value &¬std::is_same< VALUE_T, Eigen::VectorXd >::value, void >::type set(ATTRIBUTE_T &toSet, const VALUE_T &setter)
Sets non Eigen::VectorXd type values.
XMLAttribute & setOptions(std::initializer_list< T > &&options)
bool hasValidation() const
const ATTRIBUTE_T & getDefaultValue() const
const std::string & getUserDocumentation() const
const ATTRIBUTE_T & getValue() const
bool hasDefaultValue() const
XMLAttribute(std::string name)
XMLAttribute & setOptions(std::vector< ATTRIBUTE_T > options)
const std::vector< ATTRIBUTE_T > & getOptions() const
XMLAttribute(const XMLAttribute< ATTRIBUTE_T > &other)=default
XMLAttribute & setDefaultValue(const ATTRIBUTE_T &defaultValue)
const std::string & getName() const
std::vector< ATTRIBUTE_T > _options
ATTRIBUTE_T _defaultValue
void readValue(std::string_view tagName, const std::map< std::string, std::string > &aAttributes)
XMLAttribute(std::string name, ATTRIBUTE_T defaultValue)
XMLAttribute & setDocumentation(std::string_view documentation)
Sets a documentation string for the attribute.
XMLAttribute & operator=(const XMLAttribute< ATTRIBUTE_T > &other)=default
bool isKebabStyle(std::string_view sv)
contains the XML configuration parser.
XMLAttribute< std::string > makeXMLAttribute(std::string name, const char *defaultValue)
std::string getName(const XMLTag::Attribute &attribute)
Returns the name of an Attribute.
void readValueSpecific(const std::string &rawValue, double &value)