63 void printDoc(
const std::string& docString, std::ostream& out)
const {}
71 std::string
const& paramName,
72 std::string
const& sublistName
76 return "UNDEFINEDTYPE";
90 missingValidatorList = getParametersFromXmlFile(
"MissingValidator.xml"),
94 missingPrototypeList = getParametersFromXmlFile(
"MissingPrototypeValidator.xml"),
98 conflicitingValiIdsList = getParametersFromXmlFile(
"ConflictingValidatorIDs.xml"),
102 stringValidatorBadTagList = getParametersFromXmlFile(
"StringValidatorBadTag.xml"),
106 stringValidatorBadTagList = getParametersFromXmlFile(
"StringToIntegralValidatorBadTag.xml"),
109 #ifdef HAVE_TEUCHOS_DEBUG
116 anyNumberParameterEntryValidator();
117 writerDummyMap.
insert(anyNumberValidator);
133 std::string defaultParameterName =
"default";
134 std::string nonDefaultParameterName =
"non default";
141 myList.
set(
"default",
"",
"parameter for default validator",
143 myList.
set(
"non default",
"blah.txt",
"parameter for non default validator",
144 nonDefaultValidator);
162 std::string defaultParameterName =
"default";
163 std::string nonDefaultParameterName =
"non default";
166 new StringValidator(tuple<std::string>(
"value1",
"cheese",
"kurtis",
"is",
"awesome")));
168 myList.
set(
"non default",
"kurtis",
"parameter for non default validator",
169 nonDefaultValidator);
183 std::string xmlFileName =
"BoolValidatorList.xml";
184 std::string boolParameterName =
"boolParameterName";
189 myList.
set(boolParameterName,
false,
190 "A parameter with a BoolParameterEntryValidator validator.",
205 std::string xmlFileName =
"AnyNumberValidatorList.xml";
206 std::string defaultParameterName =
"default";
207 std::string nonDefaultParameterName =
"preferred and accepted";
221 myList.
set(defaultParameterName, 10.0,
222 "A parameter with the default AnyNumberValidator on it", defaultValidator);
223 myList.
set(nonDefaultParameterName, 1,
224 "A prameter with an AnyNumberValidator on it that has the preferred and accepted types differnet from the default",
225 nonDefaultValidator);
257 std::string defaultParameterName =
"default";
258 std::string minmaxParameterName =
"min max";
259 std::string stepPrecParameterName =
"step and prec";
267 myList.
set(defaultParameterName, ( T )6,
"parameter with default validator",
269 myList.
set(minmaxParameterName, ( T )10,
"parameter with min and max validator",
271 myList.
set(stepPrecParameterName, ( T )10,
"parameter with min, max, "
272 "step, and prec validator",
273 stepAndPrecValidator);
299 defaultParameterName).
validator(),
true)->getPrecision(),
302 defaultParameterName).
validator(),
true)->getPrecision()
338 minmaxParameterName).
validator(),
true)->getPrecision(),
341 minmaxParameterName).
validator(),
true)->getPrecision()
378 stepPrecParameterName).
validator(),
true)->getPrecision(),
381 stepPrecParameterName).
validator(),
true)->getPrecision());
388 std::string arrayParameterName =
"array";
391 const T arrayValidatorLen = as<T>(11);
395 myList.
set(arrayParameterName,
396 Array< T >(4, 10),
"array parameter", arrayValidator);
403 arrayParameterName).
validator(),
true)->getPrototype();
405 arrayValidator->getPrototype();
408 readInPrototypeValidator->getMin(),
409 actualPrototypeValidator->getMin()
412 readInPrototypeValidator->getMax(),
413 actualPrototypeValidator->getMax()
416 readInPrototypeValidator->getStep(),
417 actualPrototypeValidator->getStep()
420 readInPrototypeValidator->getPrecision(),
421 actualPrototypeValidator->getPrecision()
424 readInPrototypeValidator->hasMin(),
425 actualPrototypeValidator->hasMin()
428 readInPrototypeValidator->hasMax(),
429 actualPrototypeValidator->hasMax()
435 std::string arrayParameterName =
"array";
438 const T arrayValidatorLen = as<T>(11);
442 myList.
set(arrayParameterName,
450 arrayParameterName).
validator(),
true)->getPrototype();
452 arrayValidator->getPrototype();
455 readInPrototypeValidator->getMin(),
456 actualPrototypeValidator->getMin()
459 readInPrototypeValidator->getMax(),
460 actualPrototypeValidator->getMax()
463 readInPrototypeValidator->getStep(),
464 actualPrototypeValidator->getStep()
467 readInPrototypeValidator->getPrecision(),
468 actualPrototypeValidator->getPrecision()
471 readInPrototypeValidator->hasMin(),
472 actualPrototypeValidator->hasMin()
475 readInPrototypeValidator->hasMax(),
476 actualPrototypeValidator->hasMax()
483 std::string defaultStringToIntegralParameterName =
"defaultsti";
484 std::string stringToIntegralParameterName =
"sti";
488 tuple<std::string>(
"value1",
"value2",
"value3"), stringToIntegralParameterName));
491 tuple<std::string>(
"value3",
"value4",
"value5"),
492 tuple<std::string>(
"the third value",
"the fourth value",
"the fifth value"),
494 stringToIntegralParameterName));
495 myList.
set(defaultStringToIntegralParameterName,
496 "value1",
"parameter with default sti validator", defaultStiValidator);
497 myList.
set(stringToIntegralParameterName,
"value3",
"parameter with sti validator",
504 readInDefaultStiValidator =
507 defaultStringToIntegralParameterName).
validator(),
true);
512 stringToIntegralParameterName).
validator(),
true);
515 *(readInDefaultStiValidator->validStringValues());
517 *(defaultStiValidator->validStringValues());
521 TEST_EQUALITY( readInDefaultStiValidator->getDefaultParameterName(),
522 defaultStiValidator->getDefaultParameterName());
523 for(
int i=0; i<defaultValidStrings.
size(); ++i){
524 TEST_EQUALITY(defaultStiValidator->getIntegralValue(defaultValidStrings[i]),
525 readInDefaultStiValidator->getIntegralValue(defaultValidStrings[i]));
533 *(stiValidator->getStringDocs()));
534 TEST_EQUALITY( readInStiValidator->getDefaultParameterName(),
535 stiValidator->getDefaultParameterName());
536 for(
int i=0; i<validStrings.
size(); ++i){
537 TEST_EQUALITY(stiValidator->getIntegralValue(validStrings[i]),
538 readInStiValidator->getIntegralValue(validStrings[i]));
549 pl.
set(
"string param",
"hi",
"a string param", stringVali);
550 pl.
set(
"string array param", strArray,
551 "a string array parameter", arrayStringVali);
558 == inArrayValidator->getPrototype());
562 #define FULL_NUMBER_TYPE_TEST( T ) \
563 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, EnhancedNumberValidatorConverter, T ) \
564 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, NumberArrayValidatorConverterTest, T ) \
565 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, StringToIntegralConverterTest, T )
567 #define NONINTEGRAL_NUMBER_TYPE_TEST( T ) \
568 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, EnhancedNumberValidatorConverter, T ) \
569 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, NumberArrayValidatorConverterTest, T )
571 typedef unsigned int uint;
572 typedef unsigned short ushort;
573 typedef unsigned long ulong;
579 typedef
long long int llint;
#define FULL_NUMBER_TYPE_TEST(T)
A collection of standard ValidatorXMLConverters.
#define TEST_ASSERT(v1)
Assert the given statement is true.
Maps Validators to integers.
#define NONINTEGRAL_NUMBER_TYPE_TEST(T)
Converts StringValidators to and from XML.
Convience class for EnhancedNumberValidators that are to be applied to arrays.
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
ValidStringsList validStringValues() const
Return an array of strings of valid values if applicable.
Converts AnyNumberParameterEntryValidators to and from XML.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Set a parameter whose value has type T.
This object is held as the "value" in the Teuchos::ParameterList std::map.
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
XMLObject fromValidatortoXML(const RCP< const ParameterEntryValidator > validator, const ValidatortoIDMap &validatorIDsMap, bool assignedID=true) const
Converters a given ParameterEntryValidator to XML.
#define TEST_THROW(code, ExceptType)
Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails)...
Standard implementation of a ParameterEntryValidator that maps from a list of strings to an enum or i...
static RCP< const ValidatorXMLConverter > getConverter(const ParameterEntryValidator &validator)
Get an appropriate ValidatorXMLConverter given a Validator.
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
Takes a validator, wraps it, and applies it to a TwoDArray.
ValidStringsList validStringValues() const
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(RCPNodeHandle, basicConstruct_owns_mem, T)
Determines the types that are accepted.
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
EPreferredType getPreferredType() const
Lookup the preferred type.
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
Thrown when the ValidatorXMLConverterDB can't find an appropriate converter.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
void printDoc(const std::string &docString, std::ostream &out) const
Print documentation for this parameter.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
A database for ValidatorXMLConverters.
Writes a ParameterList to an XML object.
Convience class for EnhancedNumberValidators that are to be applied to TwoDArray. ...
Standard implementation of a BoolParameterEntryValidator that accepts bool values (true/false) or str...
Validate a file name entry.
A class for mapping validators to integers.
const std::string getXMLTypeName() const
Get a string that should be used as a value of the type attribute when serializing it to XML...
void insert(RCP< const ParameterEntryValidator > toInsert)
inserts an IDValidatorPair into the map.
Takes a validator, wraps it, and applies it to an array.
A list of parameters of arbitrary type.
A simple validator that only allows certain string values to be choosen or simply enforces that a par...
Abstract interface for an object that can validate a ParameterEntry's value.
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
bool isDoubleAllowed() const
Lookup whether or not doubles are allowed.
A collection of Exceptions that can be potentially thrown when converting a ParameterList to and from...
Class uesd to validate a particular type of number.
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
Validate a parameter entry value and throw std::exception (with a great error message) if validation ...
static void printKnownConverters(std::ostream &out)
prints the xml tags associated with all known converters
Constructs a CantFindParameterEntryConverterException.
AcceptedTypes & allowDouble(bool _allowDouble)
Set allow a double value or not.
Smart reference counting pointer class for automatic garbage collection.
bool fileMustExist() const
Gets the variable describing whether or not this validator wants the file that is specified to alread...
Thrown when xml tag is encountered that is either unrecognized or inappropriate for a given context...
bool isStringAllowed() const
Lookup whether or not strings are allowed.
RCP< ParameterEntryValidator > fromXMLtoValidator(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
Converts a given XMLObject to a ParameterEntryValidator.
Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different ...
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.
bool isIntAllowed() const
Lookup whether or not ints are allowed.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< ParameterList > writeThenReadPL(ParameterList &myList)
Write a parameter list to xml and then read that xml back in via a string. The intent of this functio...
Thrown when a bad validator xml converter is used.
static std::string name()
Thrown when a referenced validator can't be found.
bool is_null() const
Returns true if the underlying pointer is null.