10#include "Teuchos_ParameterEntryXMLConverter.hpp"
14#include "Teuchos_ParameterEntryXMLConverterDB.hpp"
23 #ifdef HAVE_TEUCHOS_DEBUG
27 "Error: this Parameter Entry XML tag has a type different than "
28 "the XMLConverter being used to convert it." <<std::endl <<
29 "Parameter name: " <<
xmlObj.getRequired(
31 "XML Parameter Entry type: " <<
34 std::endl <<std::endl);
44 std::endl << std::endl);
47 bool isDefault =
false;
49 std::string docString =
"";
52 if(
xmlObj.hasAttribute(getDefaultAttributeName())){
53 isDefault =
xmlObj.getRequiredBool(getDefaultAttributeName());
56 if(
xmlObj.hasAttribute(getUsedAttributeName())){
57 isUsed =
xmlObj.getRequiredBool(getUsedAttributeName());
60 if(
xmlObj.hasAttribute(getDocStringAttributeName())){
61 docString =
xmlObj.getRequired(getDocStringAttributeName());
78 const std::string &name,
82 #ifdef HAVE_TEUCHOS_DEBUG
91 "Error: This converter can't convert the given ParameterEntry to XML "
92 "because their types don't match." << std::endl <<
93 "Parameter name: " << name << std::endl <<
94 "Parameter type: " << entry->getAny().typeName() << std::endl <<
102 toReturn.addAttribute(getDocStringAttributeName(), entry->docString());
106 toReturn.addBool(getDefaultAttributeName(), entry->isDefault());
107 toReturn.addBool(getUsedAttributeName(), entry->isUsed());
108 if(
nonnull(entry->validator())){
112 "Could not find validator in given ValidatorIDsMap! " <<
113 std::endl << std::endl);
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.
This object is held as the "value" in the Teuchos::ParameterList std::map.
unsigned int ParameterEntryID
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...
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()
Smart reference counting pointer class for automatic garbage collection.
static const std::string & getIdAttributeName()
A class for mapping validators to integers.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
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,...