16 #ifndef OHMMS_OHMMSPARAMETER_H 17 #define OHMMS_OHMMSPARAMETER_H 61 std::ostringstream msg;
62 msg <<
"Input tag \"" << tagname <<
"\" has been deleted. Please remove it from the input file!" << std::endl;
63 throw std::runtime_error(msg.str());
67 std::ostringstream msg;
68 msg <<
"Input tag \"" << tagname <<
"\" is not supported. Please remove it from the input file!" << std::endl;
69 throw std::runtime_error(msg.str());
73 <<
"\" has been deprecated and will be deleted in the next release!" << std::endl;
97 std::ostringstream msg;
98 msg <<
"Input tag \"" <<
myName <<
"\" value \"" <<
ref_ <<
"\" is not valid. Candidate values are : ";
100 msg <<
" \"" << value <<
"\"";
102 throw std::runtime_error(msg.str());
114 const std::string& aname,
115 std::vector<T>&& candidate_values = {},
129 inline bool get(std::ostream& os)
const override 131 os <<
"<parameter name=\"" <<
myName <<
"\">" <<
ref_ <<
"</parameter>" << std::endl;
138 inline bool put(xmlNodePtr cur)
override 149 inline bool put(std::istream& is)
override 163 bool add(xmlNodePtr parent)
override 167 node_ = xmlNewChild(parent, parent->ns, (
const xmlChar*)
"parameter", NULL);
168 xmlNewProp(
node_, (
const xmlChar*)
"name", (
const xmlChar*)(
myName.c_str()));
204 const std::string& aname,
205 std::vector<bool>&& candidate_values = {},
219 inline bool get(std::ostream& os)
const override 221 os <<
"<parameter name=\"" <<
myName <<
"\"> " << (
ref_ ?
"yes" :
"no") <<
" </parameter>" << std::endl;
231 inline bool put(xmlNodePtr cur)
override 236 std::istringstream stream(ac);
243 inline bool put(std::istream& is)
override 246 std::string input_value;
250 if (input_value_lower_case ==
"yes" || input_value_lower_case ==
"true")
252 else if (input_value_lower_case ==
"no" || input_value_lower_case ==
"false")
254 else if (input_value.empty())
255 throw std::runtime_error(
myName +
" requires a single value input.");
257 throw std::runtime_error(
myName +
" only accepts 'yes'/'no'/'true'/'false' but the input value is '" +
263 throw std::runtime_error(
myName +
" only accepts a single value input.");
273 bool add(xmlNodePtr parent)
override 277 node_ = xmlNewChild(parent, parent->ns, (
const xmlChar*)
"parameter", NULL);
278 xmlNewProp(
node_, (
const xmlChar*)
"name", (
const xmlChar*)(
myName.c_str()));
OhmmsParameter(bool &a, const std::string &aname, std::vector< bool > &&candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
bool put(std::istream &is) override
read from std::istream, used by OhmmsAttributeSet
std::ostream & app_warning()
std::vector< bool > candidate_values_
valid candidate values, if not empty, the first one is the default.
std::string myName
the name of the node, corresponds to the xml tag
Declaration of OutputManager class.
bool put(xmlNodePtr cur) override
bool put(xmlNodePtr cur) override
If the content is empty, the negation of the current value is taken. Example is <parameter name="forc...
std::vector< T > candidate_values_
valid candidate values, if not empty, the first one is the default.
void reset() override
reset member data
T & ref_
reference to a value of type T
void checkTagStatus(const std::string &tagname, TagStatus status)
Declaration of OhmmsElementBase and define xml-related macros.
void reset() override
reset member data
bool add(xmlNodePtr parent) override
This function is used by the users to add a xmlNode, when the input file does not contain the corresp...
Abstract class to provide xml-compatible I/O interfaces for the derived classes.
std::string lowerCase(const std::string_view s)
++17
bool & ref_
reference to a value of type T
bool add(xmlNodePtr parent) override
This function is used by the users to add a xmlNode, when the input file does not contain the corresp...
xmlNodePtr node_
pointer to the corresponding xmlNode
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
OhmmsParameter(T &a, const std::string &aname, std::vector< T > &&candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
convert xmlNode contents into a std::string
bool getContent(const T &a, xmlNodePtr cur)
write a value to a node.
OhmmsElementBase(const char *aname="none")
constructor with a name
TagStatus tag_staus_
The status of the tag.
xmlNodePtr node_
pointer to the corresponding xmlNode
bool put(std::istream &is) override
read from std::istream
TagStatus tag_staus_
The status of the tag.
TagStatus
generic class for parameter xmlNode