10#ifndef TEUCHOS_STANDARDVALIDATORXMLCONVERTERS_HPP
11#define TEUCHOS_STANDARDVALIDATORXMLCONVERTERS_HPP
18#include "Teuchos_StandardParameterEntryValidators.hpp"
65template<
class IntegralType>
86 #ifdef HAVE_TEUCHOS_DEBUG
103 static const std::string& getIntegralValueAttributeName() {
109 static const std::string& getStringTagName() {
115 static const std::string& getStringValueAttributeName() {
121 static const std::string& getStringDocAttributeName() {
127 static const std::string& getDefaultParameterAttributeName() {
129 "defaultParameterName";
134 static const std::string& getCaseSensitiveAttributeName() {
150template<
class IntegralType>
159 for (
int i=0;
i<
xmlObj.numChildren(); ++
i) {
163 "Error converting xmlObject to "
164 "StringToIntegralParameterEntryValidator." << std::endl <<
167 if (
currentChild.hasAttribute(getIntegralValueAttributeName())) {
170 getIntegralValueAttributeName()));
172 if (
currentChild.hasAttribute(getStringDocAttributeName())) {
174 currentChild.getRequired<std::string>(getStringDocAttributeName()));
178 xmlObj.getRequired(getDefaultParameterAttributeName());
182 xmlObj.getWithDefault<
bool> (getCaseSensitiveAttributeName (),
true);
197template<
class IntegralType>
219 stringTag.addAttribute(getIntegralValueAttributeName(),
227 xmlObj.addAttribute(getDefaultParameterAttributeName(),
234 xmlObj.addAttribute(getIntegralValueAttributeName(),
261 void convertValidator(
266 #ifdef HAVE_TEUCHOS_DEBUG
311 void convertValidator(
316 #ifdef HAVE_TEUCHOS_DEBUG
329 static const std::string& getAllowIntAttributeName() {
335 static const std::string& getAllowDoubleAttributeName() {
341 static const std::string& getAllowStringAttributeName() {
347 static const std::string& getPrefferedTypeAttributeName() {
391#ifdef HAVE_TEUCHOS_DEBUG
406 static const std::string& getMinAttributeName() {
412 static const std::string& getMaxAttributeName() {
418 static const std::string& getStepAttributeName() {
424 static const std::string& getPrecisionAttributeName() {
442 T step =
xmlObj.getWithDefault(
445 unsigned short int precision =
xmlObj.getWithDefault(
446 getPrecisionAttributeName(),
449 if (
xmlObj.hasAttribute(getMinAttributeName())) {
452 if (
xmlObj.hasAttribute(getMaxAttributeName())) {
474 xmlObj.addAttribute<
short unsigned int>(
507 void convertValidator(
512 #ifdef HAVE_TEUCHOS_DEBUG
525 static const std::string& getFileMustExistAttributeName() {
563 void convertValidator(
568 #ifdef HAVE_TEUCHOS_DEBUG
581 static const std::string& getStringTagName() {
587 static const std::string& getStringValueAttributeName() {
596template<
class Val
idatorType,
class EntryType>
609 void convertValidator(
629template<
class Val
idatorType,
class EntryType>
630RCP<ParameterEntryValidator>
631AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>::convertXML(
632 const XMLObject& xmlObj,
633 const IDtoValidatorMap& validatorIDsMap)
const
635 RCP<ValidatorType> prototypeValidator;
636 if(xmlObj.hasAttribute(
640 validatorIDsMap.find(
642 getPrototypeIdAttributeName()));
643 if (result != validatorIDsMap.end() ) {
645 rcp_dynamic_cast<ValidatorType>(result->second,
true);
649 MissingValidatorDefinitionException,
650 "Could not find prototype validator with id: "
652 getPrototypeIdAttributeName()) << std::endl<< std::endl);
656 prototypeValidator = rcp_dynamic_cast<ValidatorType>(
658 xmlObj.getChild(0), validatorIDsMap),
true);
660 return getConcreteValidator(prototypeValidator);
663template<
class Val
idatorType,
class EntryType>
665AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>::convertValidator(
666 const RCP<const ParameterEntryValidator> validator,
668 const ValidatortoIDMap& validatorIDsMap)
const
670 RCP<const AbstractArrayValidator<ValidatorType, EntryType> > castedValidator =
671 rcp_dynamic_cast<const AbstractArrayValidator<ValidatorType, EntryType> >(
673 if(validatorIDsMap.find(castedValidator->getPrototype())
674 == validatorIDsMap.end())
677 castedValidator->getPrototype(), validatorIDsMap,
false));
681 validatorIDsMap.find(castedValidator->getPrototype())->second;
684 getPrototypeIdAttributeName(), prototypeID);
715template<
class Val
idatorType,
class EntryType>
717 public AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>
728#ifdef HAVE_TEUCHOS_DEBUG
767template<
class Val
idatorType,
class EntryType>
769 public AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>
782#ifdef HAVE_TEUCHOS_DEBUG
A database for ValidatorXMLConverters.
Converts back and forth between XML and ParameterEntryValidators.
Writes an XML object to a parameter list.
Converts AnyNumberParameterEntryValidators to and from XML.
Converts ArrayValidators to and from XML.
Thrown when xml tag is encountered that is either unrecognized or inappropriate for a given context.
Converts BoolParameterEntryValidators to and from XML.
Class for retrieving a dummy object of type T.
Class defining the traits of the number type being used in an EnhancedNumberValidator.
Converts EnhancedNumberValidators to and from XML.
void convertValidator(const RCP< const ParameterEntryValidator > validator, XMLObject &xmlObj, const ValidatortoIDMap &validatorIDsMap) const
RCP< ParameterEntryValidator > convertXML(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
Converts FileNameValidators to and from XML.
Maps Validators to integers.
ValidatorMap::const_iterator const_iterator
Smart reference counting pointer class for automatic garbage collection.
RCP< T2 > rcp_dynamic_cast(const RCP< T1 > &p1, bool throw_on_fail=false)
Dynamic cast of underlying RCP type from T1* to T2*.
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object.
bool is_null() const
Returns true if the underlying pointer is null.
Convert a StringToIntegralParameterEntryValidator to and from XML.
RCP< ParameterEntryValidator > convertXML(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
void convertValidator(const RCP< const ParameterEntryValidator > validator, XMLObject &xmlObj, const ValidatortoIDMap &validatorIDsMap) const
Converts StringValidators to and from XML.
Converts TwoDArrayValidators to and from XML.
Default traits class that just returns typeid(T).name().
static XMLObject convertValidator(RCP< const ParameterEntryValidator > validator, const ValidatortoIDMap &validatorIDsMap, bool assignedID=true)
Given a validator converts the validator to XML.
static RCP< ParameterEntryValidator > convertXML(const XMLObject &xmlObject, const IDtoValidatorMap &validatorIDsMap)
Given an XMLObject converts the XMLObject to a ParameterEntryValidator and inserts the validator into...
An abstract base class for converting ParameterEntryValidators to and from XML.
static const std::string & getPrototypeIdAttributeName()
A class for mapping validators to integers.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.