42#ifndef TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H
43#define TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H
55#ifdef HAVE_TEUCHOSCORE_QUADMATH
91template<
class IntegralType>
115 const std::string& defaultParameterName,
116 const bool caseSensitive =
true);
143 std::string
const& defaultParameterName,
144 const bool caseSensitive =
true);
178 const std::string& defaultParameterName,
179 const bool caseSensitive =
true);
195 const std::string &str,
const std::string ¶mName =
"",
196 const std::string &sublistName =
""
216 const std::string ¶mName =
"",
217 const std::string &sublistName =
"",
218 const bool activeQuery =
true)
const;
237 const std::string ¶mName =
"",
238 const std::string &sublistName =
"",
239 const bool activeQuery =
true)
const;
249 const std::string& paramName,
250 const std::string& defaultValue)
const;
257 const std::string &defaultValue
285 const std::string &str,
const std::string ¶mName =
"",
286 const std::string &sublistName =
""
306 std::string
const& docString,
317 std::string
const& paramName,
318 std::string
const& sublistName
329 typedef std::map<std::string,IntegralType>
map_t;
344 std::string s_upper = s;
345 std::transform (s_upper.begin (), s_upper.end (), s_upper.begin (), ::toupper);
355template<
class IntegralType>
359 std::string
const& defaultParameterName
367template<
class IntegralType>
371 std::string
const& defaultParameterName,
372 const bool caseSensitive
380template<
class IntegralType>
385 std::string
const& defaultParameterName
393template<
class IntegralType>
398 std::string
const& defaultParameterName,
399 const bool caseSensitive
407template<
class IntegralType>
413 std::string
const& defaultParameterName
421template<
class IntegralType>
427 std::string
const& defaultParameterName,
428 const bool caseSensitive
442template<
class IntegralType>
444 std::string
const& paramName,
445 std::string
const& defaultValue,
446 std::string
const& docString,
463template<
class IntegralType>
465 std::string
const& paramName,
466 std::string
const& defaultValue,
467 std::string
const& docString,
485template<
class IntegralType>
487 std::string
const& paramName,
488 std::string
const& defaultValue,
489 std::string
const& docString,
507template<
class IntegralType>
524template<
class IntegralType>
535template<
class IntegralType>
539 std::string
const& paramName
548std::string getVerbosityLevelParameterValueName(
558verbosityLevelParameterEntryValidator(std::string
const& defaultParameterName);
565template<
class IntegralType>
582template<
class IntegralType>
621 const std::string &sublistName =
"",
const bool activeQuery =
true
629 const int defaultValue
642 std::string
const& docString,
653 std::string
const& paramName,
654 std::string
const& sublistName
659 std::string
const& paramName,
660 std::string
const& sublistName,
680 std::string
const& paramName,
681 std::string
const& sublistName
795 const std::string &sublistName =
"",
const bool activeQuery =
true
805 const std::string &sublistName =
"",
const bool activeQuery =
true
813 const std::string &sublistName =
"",
const bool activeQuery =
true
819 const std::string &sublistName =
"",
const bool activeQuery =
true
827 const int defaultValue
835 const long long defaultValue
843 const double defaultValue
851 const std::string &defaultValue
887 const std::string typeString (
toString (enumValue));
888 throw std::runtime_error(
"Cannot convert enumValue: " + typeString +
" to a string");
908 throw std::runtime_error (
"Cannot convert enumString: " + enumString +
" to an enum");
918 const std::string getXMLTypeName()
const;
922 std::string
const& docString,
928 validStringValues()
const;
933 std::string
const& paramName,
934 std::string
const& sublistName
938 void validateAndModify(
939 std::string
const& paramName,
940 std::string
const& sublistName,
958#pragma warning(disable:4251)
971 return intEnumString_;
977 return longLongEnumString_;
983 return doubleEnumString_;
989 return stringEnumString_;
993 void finishInitialization();
997 std::string
const& paramName,
998 std::string
const& sublistName
1031 std::string
const& paramName,
1032 int const value, std::string
const& docString,
1045 std::string
const& paramName,
1046 long long const value, std::string
const& docString,
1058 std::string
const& paramName,
1059 double const& value, std::string
const& docString,
1072 std::string
const& paramName,
1073 std::string
const& value, std::string
const& docString,
1095 ParameterList const& paramList, std::string
const& paramName
1114 ParameterList const& paramList, std::string
const& paramName
1133 std::string
const& paramName
1154 std::string
const& paramName
1188 return T::this_type_is_missing_a_specialization();
1241 static inline short int min() {
return std::numeric_limits<short int>::min(); }
1242 static inline short int max() {
return std::numeric_limits<short int>::max(); }
1251 static inline short unsigned int min() {
return std::numeric_limits<short unsigned int>::min(); }
1252 static inline short unsigned int max() {
return std::numeric_limits<short unsigned int>::max(); }
1261 static inline int min() {
return std::numeric_limits<int>::min(); }
1262 static inline int max() {
return std::numeric_limits<int>::max(); }
1271 static inline unsigned int min() {
return std::numeric_limits<unsigned int>::min(); }
1272 static inline unsigned int max() {
return std::numeric_limits<unsigned int>::max(); }
1281 static inline long int min() {
return std::numeric_limits<long int>::min(); }
1282 static inline long int max() {
return std::numeric_limits<long int>::max(); }
1291 static inline long unsigned int min() {
return std::numeric_limits<long unsigned int>::min(); }
1292 static inline long unsigned int max() {
return std::numeric_limits<long unsigned int>::max(); }
1301 static inline long long int min() {
return std::numeric_limits<long long int>::min(); }
1302 static inline long long int max() {
return std::numeric_limits<long long int>::max(); }
1311 static inline long long unsigned int min() {
return std::numeric_limits<long long unsigned int>::min(); }
1312 static inline long long unsigned int max() {
return std::numeric_limits<long long unsigned int>::max(); }
1318#ifdef HAVE_TEUCHOSCORE_QUADMATH
1320class EnhancedNumberTraits<__float128>{
1322 static inline __float128
min() {
return -std::numeric_limits<__float128>::max(); }
1323 static inline __float128
max() {
return std::numeric_limits<__float128>::max(); }
1324 static inline __float128
defaultStep() {
return 1; }
1332 static inline double min() {
return -std::numeric_limits<double>::max(); }
1333 static inline double max() {
return std::numeric_limits<double>::max(); }
1338#ifdef HAVE_TEUCHOS_LONG_DOUBLE
1340class EnhancedNumberTraits<long double>{
1342 static inline long double min() {
return -std::numeric_limits<long double>::max(); }
1343 static inline long double max() {
return std::numeric_limits<long double>::max(); }
1344 static inline long double defaultStep() {
return 1; }
1352 static inline float min() {
return -std::numeric_limits<float>::max(); }
1353 static inline float max() {
return std::numeric_limits<float>::max(); }
1515 std::string
const &sublistName)
const;
1523 const bool activeQuery)
const;
1531 void printDoc(std::string
const &docString, std::ostream &out)
const{
1533 out <<
"#\tValidator Used: " << std::endl;
1534 out <<
"#\t\tNumber Validator" << std::endl;
1537 out <<
"#\t\tMin (inclusive): " <<
minVal << std::endl;
1538 out <<
"#\t\tMax (inclusive): " <<
maxVal << std::endl;
1589 std::string
const& paramName,
1590 std::string
const& sublistName,
1598 if( anyValue.
type() ==
typeid(std::string) ) {
1608 paramName, sublistName, entry);
1620 if(
typeid(T) ==
typeid(
char))
return true;
1621 if(
typeid(T) ==
typeid(
unsigned char))
return true;
1622 if(
typeid(T) ==
typeid(
int))
return true;
1623 if(
typeid(T) ==
typeid(
unsigned int))
return true;
1624 if(
typeid(T) ==
typeid(
short))
return true;
1625 if(
typeid(T) ==
typeid(
unsigned short))
return true;
1626 if(
typeid(T) ==
typeid(
long))
return true;
1627 if(
typeid(T) ==
typeid(
unsigned long))
return true;
1628 if(
typeid(T) ==
typeid(
long long))
return true;
1629 if(
typeid(T) ==
typeid(
unsigned long long))
return true;
1646 const any &anyValue = entry.
getAny(activeQuery);
1657 std::string
const &sublistName)
const
1665 if( anyValue.
type() ==
typeid(std::string) ) {
1673 "The \"" << paramName <<
"\"" <<
1674 " parameter in the \"" << sublistName <<
1675 "\" sublist is has an error." << std::endl << std::endl <<
1676 "Error: The value that you entered was the wrong type." << std::endl <<
1677 "Parameter: " << paramName << std::endl <<
1678 "Type specified: " << entryName << std::endl <<
1681 bool isValueInRange;
1683 ? isValueInRange = true : isValueInRange=
false;
1686 "The \"" << paramName <<
"\"" <<
1687 " parameter in the \"" << sublistName <<
1688 "\" sublist is has an error." << std::endl << std::endl <<
1689 "Error: The value that was entered doesn't fall with in " <<
1690 "the range set by the validator" << std::endl <<
1691 "Parameter: " << paramName << std::endl <<
1692 "Min: " <<
minVal << std::endl <<
1693 "Max: " <<
maxVal << std::endl <<
1694 "Value entered: " <<
1695 (
any_cast<T>(anyValue)) << std::endl << std::endl);
1767 bool fileMustExist()
const;
1782 bool fileEmptyNameOK()
const;
1797 bool setFileMustExist(
bool shouldFileExist);
1807 bool setFileEmptyNameOK(
bool isEmptyNameOK);
1815 ValidStringsList validStringValues()
const;
1820 std::string
const ¶mName,
1821 std::string
const &sublistName)
const;
1824 const std::string getXMLTypeName()
const;
1827 void printDoc(std::string
const &docString, std::ostream &out)
const;
1917 std::string
const &sublistName)
const;
1923 void printDoc(std::string
const &docString, std::ostream &out)
const;
1966template<
class Val
idatorType,
class EntryType>
2034template<
class Val
idatorType,
class EntryType>
2056 std::string
const &sublistName)
const;
2060 return "TwoDArrayValidator(" +
2066 virtual void printDoc(std::string
const &docString, std::ostream &out)
const
2069 std::string toPrint;
2070 toPrint +=
"TwoDArrayValidator:\n";
2071 toPrint +=
"Prototype Validator:\n";
2079template<
class Val
idatorType,
class EntryType>
2081 std::string
const &sublistName)
const
2087 "The \"" << paramName <<
"\"" <<
2088 " parameter in the \"" << sublistName <<
2089 "\" sublist is has an error." << std::endl << std::endl <<
2090 "Error: The value you entered was the wrong type." << std::endl <<
2091 "Parameter: " << paramName << std::endl <<
2092 "Type specified: " << entryName << std::endl <<
2094 std::endl << std::endl);
2099 for(
int i = 0; i<extracted.
getNumRows(); ++i){
2100 for(
int j = 0; j<extracted.
getNumCols(); ++j){
2102 dummyParameter.
setValue(extracted(i,j));
2104 prototype->validate(
2105 dummyParameter, paramName, sublistName);
2108 std::stringstream oss;
2109 oss <<
"TwoDArray Validator Exception:" << std::endl <<
2110 "Bad Index: (" << i <<
"," << j <<
")" << std::endl << e.what();
2123template<
class Val
idatorType,
class EntryType>
2140template<
class Val
idatorType,
class EntryType>
2219template<
class Val
idatorType,
class EntryType>
2242 std::string
const &sublistName)
const;
2246 return "ArrayValidator(" +
2252 virtual void printDoc(std::string
const &docString, std::ostream &out)
const
2255 std::string toPrint;
2256 toPrint +=
"ArrayValidator:\n";
2257 toPrint +=
"Prototype Validator:\n";
2265template<
class Val
idatorType,
class EntryType>
2267 std::string
const &sublistName)
const
2273 "The \"" << paramName <<
"\"" <<
2274 " parameter in the \"" << sublistName <<
2275 "\" sublist is has an error." << std::endl << std::endl <<
2276 "Error: The value you entered was the wrong type." << std::endl <<
2277 "Parameter: " << paramName << std::endl <<
2278 "Type specified: " << entryName << std::endl <<
2280 std::endl << std::endl);
2285 for(
int i = 0; i<extracted.
size(); ++i){
2287 dummyParameter.
setValue(extracted[i]);
2289 prototype->validate(
2290 dummyParameter, paramName, sublistName);
2293 std::stringstream oss;
2294 oss <<
"Array Validator Exception:" << std::endl <<
2295 "Bad Index: " << i << std::endl << e.what();
2306template<
class Val
idatorType,
class EntryType>
2323template<
class Val
idatorType,
class EntryType>
2417template<
class IntegralType>
2420 std::string
const& defaultParameterName,
2421 const bool caseSensitive) :
2426 typedef typename map_t::value_type val_t;
2427 for (
int i = 0; i < static_cast<int> (strings.
size ()); ++i) {
2429 map_.insert (val_t (strings[i],
static_cast<IntegralType
> (i))).second :
2430 map_.insert (val_t (
upperCase (strings[i]),
static_cast<IntegralType
> (i))).second;
2432 ! unique, std::logic_error,
2434 "strings[" << i <<
"] = \"" << strings[i] <<
"\" is a duplicate.");
2440template<
class IntegralType>
2444 std::string
const& defaultParameterName,
2445 const bool caseSensitive) :
2454 strings.
size() != integralValues.
size(),
2456 "The input arrays strings and integralValues must have the same length.");
2458 typedef typename map_t::value_type val_t;
2459 for (
int i = 0; i < static_cast<int> (strings.
size ()); ++i) {
2461 map_.insert (val_t (strings[i], integralValues[i])).second :
2462 map_.insert (val_t (
upperCase (strings[i]), integralValues[i])).second;
2465 ! unique, std::logic_error,
2467 "strings[" << i <<
"] = \"" << strings[i] <<
"\" is a duplicate.");
2472template<
class IntegralType>
2477 std::string
const& defaultParameterName,
2478 const bool caseSensitive) :
2489 strings.
size() != integralValues.
size(),
2491 "The input arrays strings and integralValues must have the same length.");
2494 strings.
size() != stringsDocs.
size(),
2496 "The input arrays strings and stringsDocs must have the same length.");
2498 typedef typename map_t::value_type val_t;
2499 for (
int i = 0; i < static_cast<int> (strings.
size ()); ++i) {
2501 map_.insert (val_t (strings[i], integralValues[i])).second :
2502 map_.insert (val_t (
upperCase (strings[i]), integralValues[i])).second;
2504 ! unique, std::logic_error,
2506 "strings[" << i <<
"] = \"" << strings[i] <<
"\" is a duplicate.");
2514template<
class IntegralType>
2517 const std::string &str,
const std::string ¶mName
2518 ,
const std::string &sublistName
2524 ,
"Error, the value \"" << str <<
"\" is not recognized for the parameter \""
2526 <<
"\nin the sublist \"" << sublistName <<
"\"."
2527 <<
"\n\nValid values include:"
2532 return (*itr).second;
2536template<
class IntegralType>
2540 ,
const std::string &sublistName,
const bool activeQuery
2543 const bool validType = ( entry.
getAny(activeQuery).type() ==
typeid(std::string) );
2548 <<
"\nin the sublist \"" << sublistName <<
"\""
2549 <<
"\nhas the wrong type."
2550 <<
"\n\nThe correct type is \"string\"!"
2558template<
class IntegralType>
2562 ,
const std::string &sublistName,
const bool activeQuery
2572template<
class IntegralType>
2576 ,
const std::string &defaultValue
2579 const std::string& strValue =
2580 paramList.
get (paramName,
2586template<
class IntegralType>
2590 ,
const std::string &defaultValue
2593 const std::string& strValue =
2594 paramList.
get (paramName,
2600template<
class IntegralType>
2607template<
class IntegralType>
2614template<
class IntegralType>
2617 const std::string &str,
const std::string ¶mName
2618 ,
const std::string &sublistName
2630template<
class IntegralType>
2636template<
class IntegralType>
2638 std::string
const& docString
2643 out <<
"# Valid std::string values:\n";
2647 out <<
"# \"" << (*validStringValues_)[i] <<
"\"\n";
2660template<
class IntegralType>
2668template<
class IntegralType>
2671 ,std::string
const& paramName
2672 ,std::string
const& sublistName
2681template<
class IntegralType>
2702 std::ostringstream oss;
2703 for (
int i = 0; i < static_cast<int> (strings.
size()); ++i) {
2704 oss <<
" \"" << strings[i] <<
"\"\n";
2719template<
class IntegralType>
2723 ArrayView<const std::string>
const& strings,
2724 std::string
const& defaultParameterName
2728 new StringToIntegralParameterEntryValidator<IntegralType>(
2729 strings, defaultParameterName
2735template<
class IntegralType>
2739 ArrayView<const std::string>
const& strings,
2740 std::string
const& defaultParameterName,
2741 const bool caseSensitive
2744 typedef StringToIntegralParameterEntryValidator<IntegralType> ret_type;
2745 return rcp (
new ret_type (strings, defaultParameterName, caseSensitive));
2750template<
class IntegralType>
2754 ArrayView<const std::string>
const& strings,
2755 ArrayView<const IntegralType>
const& integralValues,
2756 std::string
const& defaultParameterName
2760 new StringToIntegralParameterEntryValidator<IntegralType>(
2761 strings, integralValues, defaultParameterName
2767template<
class IntegralType>
2771 ArrayView<const std::string>
const& strings,
2772 ArrayView<const IntegralType>
const& integralValues,
2773 std::string
const& defaultParameterName,
2774 const bool caseSensitive)
2776 typedef StringToIntegralParameterEntryValidator<IntegralType> ret_type;
2777 return rcp (
new ret_type (strings, integralValues,
2778 defaultParameterName, caseSensitive));
2782template<
class IntegralType>
2786 ArrayView<const std::string>
const& strings,
2787 ArrayView<const std::string>
const& stringsDocs,
2788 ArrayView<const IntegralType>
const& integralValues,
2789 std::string
const& defaultParameterName
2793 new StringToIntegralParameterEntryValidator<IntegralType>(
2794 strings, stringsDocs, integralValues, defaultParameterName
2800template<
class IntegralType>
2804 ArrayView<const std::string>
const& strings,
2805 ArrayView<const std::string>
const& stringsDocs,
2806 ArrayView<const IntegralType>
const& integralValues,
2807 std::string
const& defaultParameterName,
2808 const bool caseSensitive)
2810 typedef StringToIntegralParameterEntryValidator<IntegralType> ret_type;
2811 return rcp (
new ret_type (strings, stringsDocs, integralValues,
2812 defaultParameterName, caseSensitive));
2816template<
class IntegralType>
2818 std::string
const& paramName,
2819 std::string
const& defaultValue,
2820 std::string
const& docString,
2828 paramName, defaultValue, docString,
2838template<
class IntegralType>
2840 std::string
const& paramName,
2841 std::string
const& defaultValue,
2842 std::string
const& docString,
2851 paramName, defaultValue, docString,
2854 strings, integralValues, paramName
2861template<
class IntegralType>
2863 std::string
const& paramName,
2864 std::string
const& defaultValue,
2865 std::string
const& docString,
2876 paramName, defaultValue, docString,
2879 strings, stringsDocs, integralValues, paramName
2886template<
class IntegralType>
2888 ParameterList const& paramList, std::string
const& paramName
2894 entry, paramList, paramName
2896 return integralValidator->getIntegralValue(
2897 entry, paramName, paramList.
name(),
true );
2901template<
class IntegralType>
2903 ParameterList const& paramList, std::string
const& paramName
2909 entry, paramList, paramName
2911 return integralValidator->getStringValue(
2912 entry, paramName, paramList.
name(),
true
2917template<
class IntegralType>
2921 std::string
const& paramName
2927 "Error! The parameter \""<<paramName<<
"\" exists\n"
2928 "in the parameter (sub)list \""<<paramList.
name()<<
"\"\n"
2929 "but it does not contain any validator needed to extract\n"
2938 "Error! The parameter \""<<paramName<<
"\" exists\n"
2939 "in the parameter (sub)list \""<<paramList.
name()<<
"\"\n"
2940 "but it contains the wrong type of validator. The expected validator type\n"
2942 "but the contained validator type is \""<<
typeName(*validator)<<
"\"!"
2944 return integralValidator;
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
Templated Parameter List class.
A std::string utilities class for Teuchos.
A thin wrapper around the Teuchos Array class that allows for 2 dimensional arrays.
Defines basic traits returning the name of a type in a portable and readable way.
Smart reference counting pointer class for automatic garbage collection.
RCP< const ValidatorType > getPrototype() const
Returns the prototype validator for this Array Validator.
RCP< const ValidatorType > prototypeValidator_
The prototype validator to be applied to each entry in the Array.
AbstractArrayValidator(RCP< const ValidatorType > prototypeValidator)
Constructs an AbstractArrayValidator.
AbstractArrayValidator()
Hidden default constructor.
ValidStringsList validStringValues() const
Determines the types that are accepted.
AcceptedTypes & allowInt(bool _allowInt)
Set allow an int value or not.
bool allowString() const
Allow an std::string value?
bool allowInt() const
Allow an int value?
AcceptedTypes & allowDouble(bool _allowDouble)
Set allow a double value or not.
AcceptedTypes & allowLongLong(bool _allowLongLong)
Set allow an long long value or not.
bool allowDouble() const
Allow an double value?
bool allowLongLong() const
Allow an long long value?
AcceptedTypes & allowString(bool _allowString)
Set allow an std::string value or not.
AcceptedTypes(bool allowAllTypesByDefault=true)
Allow all types or not on construction.
Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different ...
static EPreferredType getPrefferedTypeStringEnum(const std::string &enumString)
Gets the preferred type enum associated with a give string.
static const std::string & getPrefferedTypeString(EPreferredType enumValue)
Gets the string representation of a given preferred type enum.
const AcceptedTypes acceptedTypes_
double getDouble(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get a double value from a parameter entry. will call std::stod.
static const std::string & getIntEnumString()
long long getLongLong(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get a long long value from a parameter entry. will call std::stoll Note that std::stoll throws on bad...
std::string getString(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get a std::string value from a parameter entry.
AnyNumberParameterEntryValidator()
Construct with a preferrded type of double and accept all types.
int getInt(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get an integer value from a parameter entry. will call std::stoi Note that std::stoi throws on badly ...
std::string acceptedTypesString_
static const std::string & getLongLongEnumString()
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< AnyNumberParameterEntryValidator > anyNumberParameterEntryValidator()
Nonmember constructor AnyNumberParameterEntryValidator.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< AnyNumberParameterEntryValidator > anyNumberParameterEntryValidator(AnyNumberParameterEntryValidator::EPreferredType const preferredType, AnyNumberParameterEntryValidator::AcceptedTypes const &acceptedTypes)
Nonmember constructor AnyNumberParameterEntryValidator.
bool isLongLongAllowed() const
Lookup whether or not long longs are allowed.
bool isStringAllowed() const
Lookup whether or not strings are allowed.
static const std::string & getStringEnumString()
bool isDoubleAllowed() const
Lookup whether or not doubles are allowed.
EPreferredType
Determines what type is the preferred type.
EPreferredType getPreferredType() const
Lookup the preferred type.
EPreferredType preferredType_
bool isIntAllowed() const
Lookup whether or not ints are allowed.
static const std::string & getDoubleEnumString()
ArrayFileNameValidator(RCP< const FileNameValidator > prototypeValidator)
ArrayNumberValidator(RCP< const EnhancedNumberValidator< T > > prototypeValidator)
ArrayStringValidator(RCP< const StringValidator > prototypeValidator)
Takes a validator, wraps it, and applies it to an array.
ArrayValidator(RCP< const ValidatorType > prototypeValidator)
Constructs a ArrayValidator.
const std::string getXMLTypeName() const
virtual void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
virtual void printDoc(std::string const &docString, std::ostream &out) const
size_type size() const
The total number of items in the managed array.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
Ordinal size_type
The type of Array sizes and capacities.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< BoolParameterEntryValidator > boolParameterEntryValidator()
Nonmember constructor BoolParameterEntryValidator.
void throwTypeError(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
std::string acceptedTypesString_
const std::string getXMLTypeName() const
BoolParameterEntryValidator()
ValidStringsList validStringValues() const
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
bool getBool(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get bool value from a parameter entry.
void finishInitialization()
void printDoc(std::string const &docString, std::ostream &out) const
static RCP< AnyNumberParameterEntryValidator > getDummyObject()
Retrieves a dummy object of type AnyNumberParameterEntryValidator.
static RCP< ArrayValidator< ValidatorType, EntryType > > getDummyObject()
Retrieves a dummy object of type ArrayValidator<ValidatorType, EntryType>.
static RCP< EnhancedNumberValidator< T > > getDummyObject()
Retrieves a dummy object of type EnhancedNumberValidator<T>.
static RCP< FileNameValidator > getDummyObject()
Retrieves a dummy object of type FileNameValidator.
static RCP< StringToIntegralParameterEntryValidator< IntegralType > > getDummyObject()
Retrieves a dummy object of type StringToIntegralParameterEntryValidator<IntegralType>.
static RCP< StringValidator > getDummyObject()
Retrieves a dummy object of type StringValidator.
static RCP< TwoDArrayValidator< ValidatorType, EntryType > > getDummyObject()
Retrieves a dummy object of type TwoDArrayValidator<ValidatorType, EntryType>.
Class for retrieving a dummy object of type T.
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
static double defaultStep()
static unsigned short defaultPrecision()
static float defaultStep()
static unsigned short defaultPrecision()
static unsigned short defaultPrecision()
static long int defaultStep()
static unsigned short defaultPrecision()
static long long int max()
static unsigned short defaultPrecision()
static long long int defaultStep()
static long long int min()
static long long unsigned int min()
static unsigned short defaultPrecision()
static long long unsigned int max()
static long long unsigned int defaultStep()
static long unsigned int defaultStep()
static long unsigned int max()
static unsigned short defaultPrecision()
static long unsigned int min()
static unsigned short defaultPrecision()
static short int defaultStep()
static short unsigned int min()
static short unsigned int max()
static unsigned short defaultPrecision()
static short unsigned int defaultStep()
static unsigned int min()
static unsigned short defaultPrecision()
static unsigned int max()
static unsigned int defaultStep()
Class defining the traits of the number type being used in an EnhancedNumberValidator.
static T max()
Gets the maximum possible value the number type can take on.
static unsigned short defaultPrecision()
Gets the default precision with which the number type should be displayed.
static T defaultStep()
gets default amount a value of the number type should be incremented by when being utilizied in a UI.
static T min()
Gets the minimum possible value the number type can take on.
Class uesd to validate a particular type of number.
T getMax() const
Gets the maximum acceptable value for the validator.
Teuchos::any getNumberFromString(const ParameterEntry &entry, const bool activeQuery) const
void setMin(T min)
Sets the minimum acceptable value for the validator.
EnhancedNumberValidator(T min, T max, T step=EnhancedNumberTraits< T >::defaultStep(), unsigned short precision=EnhancedNumberTraits< T >::defaultPrecision())
Constructs a EnhancedNumberValidator.
bool containsMax
Whetehr or not a maximum value has been specified for this validator.
T maxVal
The maximum value accepted by the validator.
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
void setMax(T max)
Sets the maximum acceptable value for the validator.
T step_
The increment to use when increaseing or decreaseing the value the validator is validating.
void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
T getStep() const
Gets the step being used for the validator.
bool useIntConversions() const
unsigned short getPrecision() const
Gets the precision specified for the validator.
ValidStringsList validStringValues() const
void setStep(T step)
Sets the step being used for the validator.
T minVal
The minimum value accepted by the validator.
unsigned short precision_
The number of decimal places with which the nubmer will be displayed in a UI. This value is meaningle...
bool hasMax() const
Determines whether or not the validator has a maximum value.
T getMin() const
Gets the minimum acceptable value for the validator.
void setPrecision(unsigned short precision)
Sets the precision specified for the validator.
const std::string getXMLTypeName() const
void printDoc(std::string const &docString, std::ostream &out) const
EnhancedNumberValidator()
Constructs a EnhancedNumberValidator without an explicit minimum or maximum.
bool hasMin() const
Determines whether or not the validator has a minimum value.
bool containsMin
Whether or not a minimum value has been specified for this validator.
Validate a file name entry.
bool mustAlreadyExist_
Whether or not the file specified in the parameter should already exist.
static bool mustAlreadyExistDefault()
The default value of the mustAlreadyExist parameter in the constructor.
FileNameValidator(bool mustAlreadyExist=mustAlreadyExistDefault())
Constructs a FileNameValidator.
Abstract interface for an object that can validate a ParameterEntry's value.
int convertStringToInt(std::string str) const
virtual void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
Validate and perhaps modify a parameter entry's value.
RCP< const Array< std::string > > ValidStringsList
double convertStringToDouble(std::string str) const
ParameterEntryValidator()
Default Constructor.
This object is held as the "value" in the Teuchos::ParameterList std::map.
any & getAny(bool activeQry=true)
Direct access to the Teuchos::any data value underlying this object. The bool argument activeQry (def...
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
void setValue(T value, bool isDefault=false, const std::string &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method that uses the input value type to determine the type of parameter.
T & getValue(const ParameterEntry &entry)
A templated helper function for returning the value of type T held in the ParameterEntry object,...
A list of parameters of arbitrary type.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT std::string getNumericStringParameter(ParameterList const ¶mList, std::string const ¶mName)
Get std::string numeric parameter.
std::string getStringValue(ParameterList const ¶mList, std::string const ¶mName)
Get a std::string value for a parameter that is assumed to already be set.
const ParameterEntry & entry(ConstIterator i) const
Access to ParameterEntry (i.e., returns i->second).
IntegralType getIntegralValue(ParameterList const ¶mList, std::string const ¶mName)
Get an integral value for a parameter that is assumed to already be set.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void setDoubleParameter(std::string const ¶mName, double const &value, std::string const &docString, ParameterList *paramList, AnyNumberParameterEntryValidator::AcceptedTypes const &acceptedTypes=AnyNumberParameterEntryValidator::AcceptedTypes())
Set an double parameter that allows for (nearly) any input parameter type that is convertible to a do...
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void setLongLongParameter(std::string const ¶mName, long long const value, std::string const &docString, ParameterList *paramList, AnyNumberParameterEntryValidator::AcceptedTypes const &acceptedTypes=AnyNumberParameterEntryValidator::AcceptedTypes())
Set an integer parameter that allows for (nearly) any input parameter type that is convertible to an ...
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.
const std::string & name() const
The name of this ParameterList.
ParameterList()=default
Constructor.
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT double getDoubleParameter(ParameterList const ¶mList, std::string const ¶mName)
Get double integer parameter.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void setIntParameter(std::string const ¶mName, int const value, std::string const &docString, ParameterList *paramList, AnyNumberParameterEntryValidator::AcceptedTypes const &acceptedTypes=AnyNumberParameterEntryValidator::AcceptedTypes())
Set an integer parameter that allows for (nearly) any input parameter type that is convertible to an ...
T & get(const std::string &name, T def_value)
Return the parameter's value, or the default value if it is not there.
void setStringToIntegralParameter(std::string const ¶mName, std::string const &defaultValue, std::string const &docString, ArrayView< const std::string > const &strings, ParameterList *paramList)
Set up a std::string parameter that will use an embedded validator to allow the extraction of an inte...
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void setNumericStringParameter(std::string const ¶mName, std::string const &value, std::string const &docString, ParameterList *paramList, AnyNumberParameterEntryValidator::AcceptedTypes const &acceptedTypes=AnyNumberParameterEntryValidator::AcceptedTypes())
Set an numeric parameter preferred as a std::string that allows for (nearly) any input parameter type...
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT long long getLongLongParameter(ParameterList const ¶mList, std::string const ¶mName)
Get a long long parameter.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT int getIntParameter(ParameterList const ¶mList, std::string const ¶mName)
Get an integer parameter.
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< T2 > rcp_implicit_cast(const RCP< T1 > &p1)
Implicit cast of underlying RCP type from T1* to T2*.
RCP< T2 > rcp_const_cast(const RCP< T1 > &p1)
Constant cast of underlying RCP type from T1* to T2*.
static std::ostream & printLines(std::ostream &os, const std::string &linePrefix, const std::string &lines)
Print lines with prefix first.
Standard implementation of a ParameterEntryValidator that maps from a list of strings to an enum or i...
StringToIntegralParameterEntryValidator(const ArrayView< const std::string > &strings, const std::string &defaultParameterName, const bool caseSensitive=true)
Construct with a mapping from strings to the enum or integer values .
const bool caseSensitive_
ValidStringsList validStringValuesDocs_
IntegralType getIntegralValue(const std::string &str, const std::string ¶mName="", const std::string &sublistName="") const
For a string value, find its corresponding enum or integer value.
ValidStringsList getStringDocs() const
Get a pointer to the array containing all the documentation strings.
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator(ArrayView< const std::string > const &strings, std::string const &defaultParameterName, const bool caseSensitive)
Nonmember constructor (see implementation).
std::string defaultParameterName_
std::string validateString(const std::string &str, const std::string ¶mName="", const std::string &sublistName="") const
Validate the std::string and pass it on.
std::string getStringValue(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Find the string value for the given ParameterEntry.
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator(ArrayView< const std::string > const &strings, std::string const &defaultParameterName)
Nonmember constructor (see implementation).
ValidStringsList validStringValues_
bool isCaseSensitive() const
Whether this validator is case sensitive.
static std::string upperCase(const std::string s)
Return an upper-case copy of the string s.
void printDoc(std::string const &docString, std::ostream &out) const
Print documentation to the given output string.
std::map< std::string, IntegralType > map_t
void setValidValues(ArrayView< const std::string > const &strings, ArrayView< const std::string > const *stringsDocs=NULL)
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator(ArrayView< const std::string > const &strings, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName)
Nonmember constructor (see implementation).
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator(ArrayView< const std::string > const &strings, ArrayView< const std::string > const &stringsDocs, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName, const bool caseSensitive)
Nonmember constructor (see implementation).
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator(ArrayView< const std::string > const &strings, ArrayView< const std::string > const &stringsDocs, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName)
Nonmember constructor (see implementation).
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator(ArrayView< const std::string > const &strings, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName, const bool caseSensitive)
Nonmember constructor (see implementation).
StringToIntegralParameterEntryValidator()
ValidStringsList validStringValues() const
const std::string & getDefaultParameterName() const
Get the name of the default parameter for the validator.
const std::string getXMLTypeName() const
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
Validate the given ParameterEntry.
A simple validator that only allows certain string values to be choosen or simply enforces that a par...
ValidStringsList validStrings_
An array containing a list of all the valid string values.
const std::string getXMLTypeName() const
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
StringValidator()
Constructs a StringValidator.
void printDoc(std::string const &docString, std::ostream &out) const
ValidStringsList validStringValues() const
ValidStringsList setValidStrings(const Teuchos::Array< std::string > &validStrings)
Sets the Array of valid strings and returns what the current array of valid string now is.
Tuple< T, 1 > tuple(const T &a)
Create a Tuple<T,1>.
TwoDArrayFileNameValidator(RCP< const FileNameValidator > prototypeValidator)
TwoDArrayNumberValidator(RCP< const EnhancedNumberValidator< T > > prototypeValidator)
TwoDArrayStringValidator(RCP< const StringValidator > prototypeValidator)
Takes a validator, wraps it, and applies it to a TwoDArray.
virtual void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
const std::string getXMLTypeName() const
TwoDArrayValidator(RCP< const ValidatorType > prototypeValidator)
Constructs a ArrayValidator.
virtual void printDoc(std::string const &docString, std::ostream &out) const
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
size_type getNumCols() const
returns the number of columns in the TwoDArray.
size_type getNumRows() const
returns the number of rows in the TwoDArray.
Default traits class that just returns typeid(T).name().
static std::string name()
Modified boost::any class, which is a container for a templated value.
ValueType & any_cast(any &operand)
Used to extract the templated value held in Teuchos::any to a given value type.
std::string typeName() const
Return the name of the type.
const std::type_info & type() const
Return the type of value being stored.
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
This macro is checks that to numbers are equal and if not then throws an exception with a good error ...
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
RCP< const StringToIntegralParameterEntryValidator< IntegralType > > getStringToIntegralParameterEntryValidator(ParameterEntry const &entry, ParameterList const ¶mList, std::string const ¶mName)
Get a StringToIntegralParameterEntryValidator<IntegralType> object out of a ParameterEntry object.
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
std::string toString(const HashSet< Key > &h)
EVerbosityLevel
Verbosity level.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Default structure used by EnhancedNumberTraits<T> to produce a compile time error when the specializa...
static T notDefined()
This function should not compile if there is an attempt to instantiate!