32 void printDoc(
const std::string& docString, std::ostream& out)
const {}
40 std::string
const& paramName,
41 std::string
const& sublistName
45 return "UNDEFINEDTYPE";
59 missingValidatorList = getParametersFromXmlFile(
"MissingValidator.xml"),
63 missingPrototypeList = getParametersFromXmlFile(
"MissingPrototypeValidator.xml"),
67 conflicitingValiIdsList = getParametersFromXmlFile(
"ConflictingValidatorIDs.xml"),
71 stringValidatorBadTagList = getParametersFromXmlFile(
"StringValidatorBadTag.xml"),
75 stringValidatorBadTagList = getParametersFromXmlFile(
"StringToIntegralValidatorBadTag.xml"),
78 #ifdef HAVE_TEUCHOS_DEBUG
85 anyNumberParameterEntryValidator();
86 writerDummyMap.
insert(anyNumberValidator);
102 std::string defaultParameterName =
"default";
103 std::string nonDefaultParameterName =
"non default";
110 myList.
set(
"default",
"",
"parameter for default validator",
112 myList.
set(
"non default",
"blah.txt",
"parameter for non default validator",
113 nonDefaultValidator);
131 std::string defaultParameterName =
"default";
132 std::string nonDefaultParameterName =
"non default";
135 new StringValidator(tuple<std::string>(
"value1",
"cheese",
"kurtis",
"is",
"awesome")));
137 myList.
set(
"non default",
"kurtis",
"parameter for non default validator",
138 nonDefaultValidator);
152 std::string xmlFileName =
"BoolValidatorList.xml";
153 std::string boolParameterName =
"boolParameterName";
158 myList.
set(boolParameterName,
false,
159 "A parameter with a BoolParameterEntryValidator validator.",
174 std::string xmlFileName =
"AnyNumberValidatorList.xml";
175 std::string defaultParameterName =
"default";
176 std::string nonDefaultParameterName =
"preferred and accepted";
190 myList.
set(defaultParameterName, 10.0,
191 "A parameter with the default AnyNumberValidator on it", defaultValidator);
192 myList.
set(nonDefaultParameterName, 1,
193 "A prameter with an AnyNumberValidator on it that has the preferred and accepted types differnet from the default",
194 nonDefaultValidator);
226 std::string defaultParameterName =
"default";
227 std::string minmaxParameterName =
"min max";
228 std::string stepPrecParameterName =
"step and prec";
236 myList.
set(defaultParameterName, ( T )6,
"parameter with default validator",
238 myList.
set(minmaxParameterName, ( T )10,
"parameter with min and max validator",
240 myList.
set(stepPrecParameterName, ( T )10,
"parameter with min, max, "
241 "step, and prec validator",
242 stepAndPrecValidator);
268 defaultParameterName).
validator(),
true)->getPrecision(),
271 defaultParameterName).
validator(),
true)->getPrecision()
307 minmaxParameterName).
validator(),
true)->getPrecision(),
310 minmaxParameterName).
validator(),
true)->getPrecision()
347 stepPrecParameterName).
validator(),
true)->getPrecision(),
350 stepPrecParameterName).
validator(),
true)->getPrecision());
357 std::string arrayParameterName =
"array";
360 const T arrayValidatorLen = as<T>(11);
364 myList.
set(arrayParameterName,
365 Array< T >(4, 10),
"array parameter", arrayValidator);
372 arrayParameterName).
validator(),
true)->getPrototype();
374 arrayValidator->getPrototype();
377 readInPrototypeValidator->getMin(),
378 actualPrototypeValidator->getMin()
381 readInPrototypeValidator->getMax(),
382 actualPrototypeValidator->getMax()
385 readInPrototypeValidator->getStep(),
386 actualPrototypeValidator->getStep()
389 readInPrototypeValidator->getPrecision(),
390 actualPrototypeValidator->getPrecision()
393 readInPrototypeValidator->hasMin(),
394 actualPrototypeValidator->hasMin()
397 readInPrototypeValidator->hasMax(),
398 actualPrototypeValidator->hasMax()
404 std::string arrayParameterName =
"array";
407 const T arrayValidatorLen = as<T>(11);
411 myList.
set(arrayParameterName,
419 arrayParameterName).
validator(),
true)->getPrototype();
421 arrayValidator->getPrototype();
424 readInPrototypeValidator->getMin(),
425 actualPrototypeValidator->getMin()
428 readInPrototypeValidator->getMax(),
429 actualPrototypeValidator->getMax()
432 readInPrototypeValidator->getStep(),
433 actualPrototypeValidator->getStep()
436 readInPrototypeValidator->getPrecision(),
437 actualPrototypeValidator->getPrecision()
440 readInPrototypeValidator->hasMin(),
441 actualPrototypeValidator->hasMin()
444 readInPrototypeValidator->hasMax(),
445 actualPrototypeValidator->hasMax()
452 std::string defaultStringToIntegralParameterName =
"defaultsti";
453 std::string stringToIntegralParameterName =
"sti";
457 tuple<std::string>(
"value1",
"value2",
"value3"), stringToIntegralParameterName));
460 tuple<std::string>(
"value3",
"value4",
"value5"),
461 tuple<std::string>(
"the third value",
"the fourth value",
"the fifth value"),
463 stringToIntegralParameterName));
464 myList.
set(defaultStringToIntegralParameterName,
465 "value1",
"parameter with default sti validator", defaultStiValidator);
466 myList.
set(stringToIntegralParameterName,
"value3",
"parameter with sti validator",
473 readInDefaultStiValidator =
476 defaultStringToIntegralParameterName).
validator(),
true);
481 stringToIntegralParameterName).
validator(),
true);
484 *(readInDefaultStiValidator->validStringValues());
486 *(defaultStiValidator->validStringValues());
490 TEST_EQUALITY( readInDefaultStiValidator->getDefaultParameterName(),
491 defaultStiValidator->getDefaultParameterName());
492 for(
int i=0; i<defaultValidStrings.
size(); ++i){
493 TEST_EQUALITY(defaultStiValidator->getIntegralValue(defaultValidStrings[i]),
494 readInDefaultStiValidator->getIntegralValue(defaultValidStrings[i]));
502 *(stiValidator->getStringDocs()));
503 TEST_EQUALITY( readInStiValidator->getDefaultParameterName(),
504 stiValidator->getDefaultParameterName());
505 for(
int i=0; i<validStrings.
size(); ++i){
506 TEST_EQUALITY(stiValidator->getIntegralValue(validStrings[i]),
507 readInStiValidator->getIntegralValue(validStrings[i]));
518 pl.
set(
"string param",
"hi",
"a string param", stringVali);
519 pl.
set(
"string array param", strArray,
520 "a string array parameter", arrayStringVali);
527 == inArrayValidator->getPrototype());
531 #define FULL_NUMBER_TYPE_TEST( T ) \
532 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, EnhancedNumberValidatorConverter, T ) \
533 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, NumberArrayValidatorConverterTest, T ) \
534 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, StringToIntegralConverterTest, T )
536 #define NONINTEGRAL_NUMBER_TYPE_TEST( T ) \
537 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, EnhancedNumberValidatorConverter, T ) \
538 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, NumberArrayValidatorConverterTest, T )
540 typedef unsigned int uint;
541 typedef unsigned short ushort;
542 typedef unsigned long ulong;
548 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.
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.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method.
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.