42#include "Teuchos_ParameterEntryXMLConverter.hpp"
46#include "Teuchos_ParameterEntryXMLConverterDB.hpp"
55 #ifdef HAVE_TEUCHOS_DEBUG
59 "Error: this Parameter Entry XML tag has a type different than "
60 "the XMLConverter being used to convert it." <<std::endl <<
63 "XML Parameter Entry type: " <<
66 std::endl <<std::endl);
76 std::endl << std::endl);
79 bool isDefault =
false;
81 std::string docString =
"";
93 docString = xmlObj.
getRequired(getDocStringAttributeName());
110 const std::string &name,
114 #ifdef HAVE_TEUCHOS_DEBUG
123 "Error: This converter can't convert the given ParameterEntry to XML "
124 "because their types don't match." << std::endl <<
125 "Parameter name: " << name << std::endl <<
126 "Parameter type: " << entry->getAny().typeName() << std::endl <<
134 toReturn.
addAttribute(getDocStringAttributeName(), entry->docString());
138 toReturn.
addBool(getDefaultAttributeName(), entry->isDefault());
139 toReturn.
addBool(getUsedAttributeName(), entry->isUsed());
140 if(
nonnull(entry->validator())){
142 validatorIDsMap.
find(entry->validator()) == validatorIDsMap.
end(),
144 "Could not find validator in given ValidatorIDsMap! " <<
145 std::endl << std::endl);
148 validatorIDsMap.
find(entry->validator())->second);
Converts back and forth between XML and ParameterEntryValidators.
A collection of Exceptions that can be potentially thrown when converting a ParameterList to and from...
Writes a ParameterList to an XML object.
Thrown when a converter is being used to convert either and XML tag or ParameterEntry with an innappr...
Thrown when a referenced validator can't be found.
Thrown when a parameter entry tag is missing it's value attribute.
static RCP< const ParameterEntryXMLConverter > getDefaultConverter()
Gets the default converter to be used on Parameter Entries.
static const std::string & getIdAttributeName()
static const std::string & getTypeAttributeName()
virtual const std::string getTypeAttributeValue() const =0
Gets a string representing the value that should be assigned to the "type" attribute when converting ...
ParameterEntry fromXMLtoParameterEntry(const XMLObject &xmlObj) const
Converts the given xml into a parameter entry.
XMLObject fromParameterEntrytoXML(RCP< const ParameterEntry > entry, const std::string &name, const ParameterEntry::ParameterEntryID &id, const ValidatortoIDMap &validatorIDsMap) const
Converts the given parameter entry to xml.
virtual const std::string getValueAttributeValue(RCP< const ParameterEntry > entry) const =0
Gets the value to be assigned to the "value" attribute when converting the paramter entry to xml.
static const std::string & getValueAttributeName()
This object is held as the "value" in the Teuchos::ParameterList std::map.
unsigned int ParameterEntryID
any & getAny(bool activeQry=true)
Direct access to the Teuchos::any data value underlying this object. The bool argument activeQry (def...
void setDocString(const std::string &docString)
Set the documentation std::string.
void setAnyValue(const any &value, bool isDefault=false)
Set the value as an any object.
static const std::string & getTagName()
Get the string that should be used as the tag name for all parameters when they are serialized to xml...
Smart reference counting pointer class for automatic garbage collection.
static const std::string & getIdAttributeName()
A class for mapping validators to integers.
const_iterator end() const
Returns a const_reference to the end of the map.
const_iterator find(const RCP< const ParameterEntryValidator > validator) const
Returns an iterator to the validator and id specified by the validator.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
void addBool(const std::string &name, bool val)
Add a bool as an attribute.
bool getRequiredBool(const std::string &name) const
Get a required attribute, returning it as a bool.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
const std::string & getAttribute(const std::string &name) const
Return the value of the attribute with the specified name.
void addAttribute(const std::string &name, T value)
Lookup whether or not Doubles are allowed.
bool hasAttribute(const std::string &name) const
Find out if the current node has an attribute of the specified name.
static const std::string & getNameAttributeName()
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...