10#ifndef TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H
11#define TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H
13#include "Teuchos_ParameterEntryValidator.hpp"
15#include "Teuchos_ParameterListExceptions.hpp"
18#include "Teuchos_Assert.hpp"
23#ifdef HAVE_TEUCHOSCORE_QUADMATH
59template<
class IntegralType>
163 const std::string &
str,
const std::string &
paramName =
"",
253 const std::string &
str,
const std::string &
paramName =
"",
262 return caseSensitive_;
274 std::string
const& docString,
289#if defined(HAVE_TEUCHOS_MODIFY_DEFAULTS_DURING_VALIDATION)
300 std::string defaultParameterName_;
301 std::string validValues_;
305 typedef std::map<std::string,IntegralType> map_t;
307 typedef std::map<IntegralType,std::string> inv_map_t;
310 const bool caseSensitive_;
335 static std::string upperCase (
const std::string
s) {
347template<
class IntegralType>
348RCP<StringToIntegralParameterEntryValidator<IntegralType> >
359template<
class IntegralType>
372template<
class IntegralType>
385template<
class IntegralType>
399template<
class IntegralType>
413template<
class IntegralType>
434template<
class IntegralType>
438 std::string
const& docString,
455template<
class IntegralType>
459 std::string
const& docString,
477template<
class IntegralType>
481 std::string
const& docString,
499template<
class IntegralType>
516template<
class IntegralType>
527template<
class IntegralType>
557template<
class IntegralType>
574template<
class IntegralType>
630 const std::string getXMLTypeName()
const;
634 std::string
const& docString,
640 validStringValues()
const;
650 void validateAndModify(
663 std::string acceptedTypesString_;
668 void finishInitialization();
710 enum EPreferredType { PREFER_INT, PREFER_LONG_LONG, PREFER_DOUBLE, PREFER_STRING };
795 long long getLongLong(
809 std::string getString(
825 long long getLongLong(
841 std::string getString(
848 bool isIntAllowed()
const;
852 bool isLongLongAllowed()
const;
856 bool isDoubleAllowed()
const;
860 bool isStringAllowed()
const;
864 EPreferredType getPreferredType()
const;
871 return getIntEnumString ();
872 case PREFER_LONG_LONG:
873 return getLongLongEnumString ();
875 return getDoubleEnumString ();
877 return getStringEnumString ();
880 throw std::runtime_error(
"Cannot convert enumValue: " +
typeString +
" to a string");
890 else if (
enumString == getLongLongEnumString ()) {
891 return PREFER_LONG_LONG;
893 else if (
enumString == getDoubleEnumString ()) {
894 return PREFER_DOUBLE;
896 else if (
enumString == getStringEnumString ()) {
897 return PREFER_STRING;
900 throw std::runtime_error (
"Cannot convert enumString: " +
enumString +
" to an enum");
910 const std::string getXMLTypeName()
const;
914 std::string
const& docString,
920 validStringValues()
const;
930 void validateAndModify(
944 EPreferredType preferredType_;
945 std::string acceptedTypesString_;
950#pragma warning(disable:4251)
952 const AcceptedTypes acceptedTypes_;
961 static const std::string& getIntEnumString(){
967 static const std::string& getLongLongEnumString(){
968 static const std::string longLongEnumString_ = TypeNameTraits<long long>::name();
969 return longLongEnumString_;
973 static const std::string& getDoubleEnumString(){
974 static const std::string doubleEnumString_ = TypeNameTraits<double>::name();
975 return doubleEnumString_;
979 static const std::string& getStringEnumString(){
980 static const std::string stringEnumString_ = TypeNameTraits<std::string>::name();
981 return stringEnumString_;
985 void finishInitialization();
988 ParameterEntry
const& entry,
989 std::string
const& paramName,
990 std::string
const& sublistName
1003TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP<AnyNumberParameterEntryValidator>
1024 int const value, std::string
const& docString,
1038 long long const value, std::string
const& docString,
1051 double const& value, std::string
const& docString,
1065 std::string
const& value, std::string
const& docString,
1180 return T::this_type_is_missing_a_specialization();
1231class EnhancedNumberTraits<short int>{
1233 static inline short int min() {
return std::numeric_limits<short int>::min(); }
1234 static inline short int max() {
return std::numeric_limits<short int>::max(); }
1235 static inline short int defaultStep() {
return 1; }
1241class EnhancedNumberTraits<short unsigned int>{
1243 static inline short unsigned int min() {
return std::numeric_limits<short unsigned int>::min(); }
1244 static inline short unsigned int max() {
return std::numeric_limits<short unsigned int>::max(); }
1245 static inline short unsigned int defaultStep() {
return 1; }
1251class EnhancedNumberTraits<int>{
1253 static inline int min() {
return std::numeric_limits<int>::min(); }
1254 static inline int max() {
return std::numeric_limits<int>::max(); }
1261class EnhancedNumberTraits<unsigned int>{
1263 static inline unsigned int min() {
return std::numeric_limits<unsigned int>::min(); }
1264 static inline unsigned int max() {
return std::numeric_limits<unsigned int>::max(); }
1265 static inline unsigned int defaultStep() {
return 1; }
1271class EnhancedNumberTraits<long int>{
1273 static inline long int min() {
return std::numeric_limits<long int>::min(); }
1274 static inline long int max() {
return std::numeric_limits<long int>::max(); }
1275 static inline long int defaultStep() {
return 1; }
1281class EnhancedNumberTraits<long unsigned int>{
1283 static inline long unsigned int min() {
return std::numeric_limits<long unsigned int>::min(); }
1284 static inline long unsigned int max() {
return std::numeric_limits<long unsigned int>::max(); }
1285 static inline long unsigned int defaultStep() {
return 1; }
1291class EnhancedNumberTraits<long long int>{
1293 static inline long long int min() {
return std::numeric_limits<long long int>::min(); }
1294 static inline long long int max() {
return std::numeric_limits<long long int>::max(); }
1295 static inline long long int defaultStep() {
return 1; }
1301class EnhancedNumberTraits<long long unsigned int>{
1303 static inline long long unsigned int min() {
return std::numeric_limits<long long unsigned int>::min(); }
1304 static inline long long unsigned int max() {
return std::numeric_limits<long long unsigned int>::max(); }
1305 static inline long long unsigned int defaultStep() {
return 1; }
1310#ifdef HAVE_TEUCHOSCORE_QUADMATH
1312class EnhancedNumberTraits<__float128>{
1314 static inline __float128
min() {
return -std::numeric_limits<__float128>::max(); }
1315 static inline __float128
max() {
return std::numeric_limits<__float128>::max(); }
1316 static inline __float128
defaultStep() {
return 1; }
1322class EnhancedNumberTraits<double>{
1324 static inline double min() {
return -std::numeric_limits<double>::max(); }
1325 static inline double max() {
return std::numeric_limits<double>::max(); }
1330#ifdef HAVE_TEUCHOS_LONG_DOUBLE
1332class EnhancedNumberTraits<long double>{
1334 static inline long double min() {
return -std::numeric_limits<long double>::max(); }
1335 static inline long double max() {
return std::numeric_limits<long double>::max(); }
1336 static inline long double defaultStep() {
return 1; }
1342class EnhancedNumberTraits<float>{
1344 static inline float min() {
return -std::numeric_limits<float>::max(); }
1345 static inline float max() {
return std::numeric_limits<float>::max(); }
1383 minVal(min), maxVal(max), step_(step), precision_(precision),
1384 containsMin(
true), containsMax(
true){}
1396 containsMax(
false){}
1434 precision_ = precision;
1523 void printDoc(std::string
const &docString, std::ostream &out)
const{
1525 out <<
"#\tValidator Used: " << std::endl;
1526 out <<
"#\t\tNumber Validator" << std::endl;
1529 out <<
"#\t\tMin (inclusive): " << minVal << std::endl;
1530 out <<
"#\t\tMax (inclusive): " << maxVal << std::endl;
1543 bool useIntConversions()
const;
1565 unsigned short precision_;
1590 if(
anyValue.type() ==
typeid(std::string) ) {
1591 anyValue = getNumberFromString(*entry,
false);
1612 if(
typeid(
T) ==
typeid(
char))
return true;
1613 if(
typeid(
T) ==
typeid(
unsigned char))
return true;
1614 if(
typeid(
T) ==
typeid(
int))
return true;
1615 if(
typeid(
T) ==
typeid(
unsigned int))
return true;
1616 if(
typeid(
T) ==
typeid(
short))
return true;
1617 if(
typeid(
T) ==
typeid(
unsigned short))
return true;
1618 if(
typeid(
T) ==
typeid(
long))
return true;
1619 if(
typeid(
T) ==
typeid(
unsigned long))
return true;
1620 if(
typeid(
T) ==
typeid(
long long))
return true;
1621 if(
typeid(
T) ==
typeid(
unsigned long long))
return true;
1639 if(useIntConversions()) {
1657 if(
anyValue.type() ==
typeid(std::string) ) {
1659 anyValue = getNumberFromString(entry,
false);
1667 "\" sublist is has an error." << std::endl << std::endl <<
1668 "Error: The value that you entered was the wrong type." << std::endl <<
1669 "Parameter: " <<
paramName << std::endl <<
1670 "Type specified: " <<
entryName << std::endl <<
1680 "\" sublist is has an error." << std::endl << std::endl <<
1681 "Error: The value that was entered doesn't fall with in " <<
1682 "the range set by the validator" << std::endl <<
1683 "Parameter: " <<
paramName << std::endl <<
1684 "Min: " << minVal << std::endl <<
1685 "Max: " << maxVal << std::endl <<
1686 "Value entered: " <<
1759 bool fileMustExist()
const;
1774 bool fileEmptyNameOK()
const;
1807 ValidStringsList validStringValues()
const;
1816 const std::string getXMLTypeName()
const;
1819 void printDoc(std::string
const &docString, std::ostream &out)
const;
1831 bool mustAlreadyExist_;
1904 return caseSensitive_;
1913 ValidStringsList validStringValues()
const;
1920 const std::string getXMLTypeName()
const;
1923 void printDoc(std::string
const &docString, std::ostream &out)
const;
1934 ValidStringsList validStrings_;
1936 bool caseSensitive_;
1939 static std::string upperCase (
const std::string
s) {
1975template<
class Val
idatorType,
class EntryType>
2000 return prototypeValidator_;
2010 return prototypeValidator_->validStringValues();
2043template<
class Val
idatorType,
class EntryType>
2069 return "TwoDArrayValidator(" +
2075 virtual void printDoc(std::string
const &docString, std::ostream &out)
const
2079 toPrint +=
"TwoDArrayValidator:\n";
2080 toPrint +=
"Prototype Validator:\n";
2088template<
class Val
idatorType,
class EntryType>
2098 "\" sublist is has an error." << std::endl << std::endl <<
2099 "Error: The value you entered was the wrong type." << std::endl <<
2100 "Parameter: " <<
paramName << std::endl <<
2101 "Type specified: " <<
entryName << std::endl <<
2103 std::endl << std::endl);
2117 std::stringstream
oss;
2118 oss <<
"TwoDArray Validator Exception:" << std::endl <<
2119 "Bad Index: (" <<
i <<
"," <<
j <<
")" << std::endl <<
e.what();
2132template<
class Val
idatorType,
class EntryType>
2149template<
class Val
idatorType,
class EntryType>
2228template<
class Val
idatorType,
class EntryType>
2255 return "ArrayValidator(" +
2261 virtual void printDoc(std::string
const &docString, std::ostream &out)
const
2265 toPrint +=
"ArrayValidator:\n";
2266 toPrint +=
"Prototype Validator:\n";
2274template<
class Val
idatorType,
class EntryType>
2284 "\" sublist is has an error." << std::endl << std::endl <<
2285 "Error: The value you entered was the wrong type." << std::endl <<
2286 "Parameter: " <<
paramName << std::endl <<
2287 "Type specified: " <<
entryName << std::endl <<
2289 std::endl << std::endl);
2302 std::stringstream
oss;
2303 oss <<
"Array Validator Exception:" << std::endl <<
2304 "Bad Index: " <<
i << std::endl <<
e.what();
2315template<
class Val
idatorType,
class EntryType>
2332template<
class Val
idatorType,
class EntryType>
2426template<
class IntegralType>
2435 const int length =
static_cast<int>(
strings.size());
2443template<
class IntegralType>
2460template<
class IntegralType>
2478 "The input arrays strings and stringsDocs must have the same length.");
2484template <
class IntegralType>
2495 "The input arrays strings and integralValues must have the same length.");
2497 typedef typename map_t::value_type
val_t;
2498 typedef typename inv_map_t::value_type
inv_val_t;
2500 const std::string name =
2504 "For parameter \"" << defaultParameterName_
2508 <<
"\" is a duplicate.");
2516template<
class IntegralType>
2523 typename map_t::const_iterator
itr = map_.find (caseSensitive_ ?
str : upperCase (
str));
2526 ,
"Error, the value \"" <<
str <<
"\" is not recognized for the parameter \""
2529 <<
"\n\nValid values include:"
2534 return (*itr).second;
2538template<
class IntegralType>
2551 ,
"Error, the parameter {paramName=\""<<(
paramName.length()?
paramName:defaultParameterName_)
2554 <<
"\nhas the wrong type."
2555 <<
"\n\nThe correct type is \"string\"!"
2564template<
class IntegralType>
2573 typename inv_map_t::const_iterator
itr = inv_map_.find(
intVal);
2576 return (*itr).second;
2586template<
class IntegralType>
2600template<
class IntegralType>
2614template<
class IntegralType>
2618 return validStringValuesDocs_;
2621template<
class IntegralType>
2625 return defaultParameterName_;
2628template<
class IntegralType>
2635 getIntegralValue (caseSensitive_ ?
str : upperCase (
str),
2644template<
class IntegralType>
2650template<
class IntegralType>
2652 std::string
const& docString
2657 out <<
"# Valid std::string values:\n";
2659 if(validStringValuesDocs_.get()) {
2661 out <<
"# \"" << (*validStringValues_)[
i] <<
"\"\n";
2674template<
class IntegralType>
2678 return validStringValues_;
2682template<
class IntegralType>
2693#if defined(HAVE_TEUCHOS_MODIFY_DEFAULTS_DURING_VALIDATION)
2694template<
class IntegralType>
2708template<
class IntegralType>
2709void StringToIntegralParameterEntryValidator<IntegralType>::setValidValues(
2710 ArrayView<const std::string>
const& strings
2711 ,ArrayView<const std::string>
const* stringsDocs
2714 if (caseSensitive_) {
2715 validStringValues_ =
rcp (
new Array<std::string> (strings));
2718 RCP<Array<std::string> > vals (
new Array<std::string> (strings.size ()));
2719 for (Array<std::string>::size_type i = 0; i < strings.size (); ++i) {
2720 (*vals)[i] = upperCase (strings[i]);
2722 validStringValues_ = rcp_const_cast<const Array<std::string> > (vals);
2726 validStringValuesDocs_ =
rcp (
new Array<std::string> (*stringsDocs));
2729 std::ostringstream oss;
2730 for (
int i = 0; i < static_cast<int> (strings.size()); ++i) {
2731 oss <<
" \"" << strings[i] <<
"\"\n";
2734 validValues_ = oss.str();
2746template<
class IntegralType>
2749Teuchos::stringToIntegralParameterEntryValidator(
2750 ArrayView<const std::string>
const& strings,
2751 std::string
const& defaultParameterName
2755 new StringToIntegralParameterEntryValidator<IntegralType>(
2756 strings, defaultParameterName
2762template<
class IntegralType>
2765Teuchos::stringToIntegralParameterEntryValidator(
2766 ArrayView<const std::string>
const& strings,
2767 std::string
const& defaultParameterName,
2768 const bool caseSensitive
2771 typedef StringToIntegralParameterEntryValidator<IntegralType> ret_type;
2772 return rcp (
new ret_type (strings, defaultParameterName, caseSensitive));
2777template<
class IntegralType>
2780Teuchos::stringToIntegralParameterEntryValidator(
2781 ArrayView<const std::string>
const& strings,
2782 ArrayView<const IntegralType>
const& integralValues,
2783 std::string
const& defaultParameterName
2787 new StringToIntegralParameterEntryValidator<IntegralType>(
2788 strings, integralValues, defaultParameterName
2794template<
class IntegralType>
2797Teuchos::stringToIntegralParameterEntryValidator(
2798 ArrayView<const std::string>
const& strings,
2799 ArrayView<const IntegralType>
const& integralValues,
2800 std::string
const& defaultParameterName,
2801 const bool caseSensitive)
2803 typedef StringToIntegralParameterEntryValidator<IntegralType> ret_type;
2804 return rcp (
new ret_type (strings, integralValues,
2805 defaultParameterName, caseSensitive));
2809template<
class IntegralType>
2812Teuchos::stringToIntegralParameterEntryValidator(
2813 ArrayView<const std::string>
const& strings,
2814 ArrayView<const std::string>
const& stringsDocs,
2815 ArrayView<const IntegralType>
const& integralValues,
2816 std::string
const& defaultParameterName
2820 new StringToIntegralParameterEntryValidator<IntegralType>(
2821 strings, stringsDocs, integralValues, defaultParameterName
2827template<
class IntegralType>
2830Teuchos::stringToIntegralParameterEntryValidator(
2831 ArrayView<const std::string>
const& strings,
2832 ArrayView<const std::string>
const& stringsDocs,
2833 ArrayView<const IntegralType>
const& integralValues,
2834 std::string
const& defaultParameterName,
2835 const bool caseSensitive)
2837 typedef StringToIntegralParameterEntryValidator<IntegralType> ret_type;
2838 return rcp (
new ret_type (strings, stringsDocs, integralValues,
2839 defaultParameterName, caseSensitive));
2843template<
class IntegralType>
2844void Teuchos::setStringToIntegralParameter(
2845 std::string
const& paramName,
2846 std::string
const& defaultValue,
2847 std::string
const& docString,
2848 ArrayView<const std::string>
const& strings,
2849 ParameterList * paramList
2852 typedef ParameterEntryValidator PEV;
2855 paramName, defaultValue, docString,
2856 rcp_implicit_cast<const PEV>(
2857 stringToIntegralParameterEntryValidator<IntegralType>(
2865template<
class IntegralType>
2866void Teuchos::setStringToIntegralParameter(
2867 std::string
const& paramName,
2868 std::string
const& defaultValue,
2869 std::string
const& docString,
2870 ArrayView<const std::string>
const& strings,
2871 ArrayView<const IntegralType>
const& integralValues,
2872 ParameterList * paramList
2875 typedef ParameterEntryValidator PEV;
2878 paramName, defaultValue, docString,
2879 rcp_implicit_cast<const PEV>(
2880 stringToIntegralParameterEntryValidator<IntegralType>(
2881 strings, integralValues, paramName
2888template<
class IntegralType>
2889void Teuchos::setStringToIntegralParameter(
2890 std::string
const& paramName,
2891 std::string
const& defaultValue,
2892 std::string
const& docString,
2893 ArrayView<const std::string>
const& strings,
2894 ArrayView<const std::string>
const& stringsDocs,
2895 ArrayView<const IntegralType>
const& integralValues,
2896 ParameterList * paramList
2900 typedef ParameterEntryValidator PEV;
2903 paramName, defaultValue, docString,
2904 rcp_implicit_cast<const PEV>(
2905 stringToIntegralParameterEntryValidator<IntegralType>(
2906 strings, stringsDocs, integralValues, paramName
2913template<
class IntegralType>
2914IntegralType Teuchos::getIntegralValue(
2915 ParameterList
const& paramList, std::string
const& paramName
2918 const ParameterEntry &entry = paramList.getEntry(paramName);
2919 if (entry.isType<IntegralType>()){
2920 return getValue<IntegralType>(entry);
2922 RCP<const StringToIntegralParameterEntryValidator<IntegralType> >
2923 integralValidator = getStringToIntegralParameterEntryValidator<IntegralType>(
2924 entry, paramList, paramName
2926 return integralValidator->getIntegralValue(
2927 entry, paramName, paramList.name(),
true );
2932template<
class IntegralType>
2933std::string Teuchos::getStringValue(
2934 ParameterList
const& paramList, std::string
const& paramName
2937 const ParameterEntry &entry = paramList.getEntry(paramName);
2938 RCP<const StringToIntegralParameterEntryValidator<IntegralType> >
2939 integralValidator = getStringToIntegralParameterEntryValidator<IntegralType>(
2940 entry, paramList, paramName
2942 return integralValidator->getStringValue(
2943 entry, paramName, paramList.name(),
true
2948template<
class IntegralType>
2951 ParameterEntry
const& entry, ParameterList
const& paramList,
2952 std::string
const& paramName
2955 const RCP<const ParameterEntryValidator> validator = entry.validator();
2957 is_null(validator), Exceptions::InvalidParameterType,
2958 "Error! The parameter \""<<paramName<<
"\" exists\n"
2959 "in the parameter (sub)list \""<<paramList.name()<<
"\"\n"
2960 "but it does not contain any validator needed to extract\n"
2961 "an integral value of type \""<<TypeNameTraits<IntegralType>::name()<<
"\"!"
2963 const RCP<const StringToIntegralParameterEntryValidator<IntegralType> > integralValidator =
2964 rcp_dynamic_cast<const StringToIntegralParameterEntryValidator<IntegralType> >(
2968 is_null(integralValidator), Exceptions::InvalidParameterType,
2969 "Error! The parameter \""<<paramName<<
"\" exists\n"
2970 "in the parameter (sub)list \""<<paramList.name()<<
"\"\n"
2971 "but it contains the wrong type of validator. The expected validator type\n"
2972 "is \""<<TypeNameTraits<StringToIntegralParameterEntryValidator<IntegralType> >::name()<<
"\"\n"
2973 "but the contained validator type is \""<<
typeName(*validator)<<
"\"!"
2975 return integralValidator;
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.
An abstract base class for all ArrayValidators.
RCP< const ValidatorType > getPrototype() const
Returns the prototype validator for this Array Validator.
AbstractArrayValidator(RCP< const ValidatorType > prototypeValidator)
Constructs an AbstractArrayValidator.
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.
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.
EPreferredType
Determines what type is the preferred type.
Convience class for FileNameValidators that are to be applied to arrays.
ArrayFileNameValidator(RCP< const FileNameValidator > prototypeValidator)
Convience class for EnhancedNumberValidators that are to be applied to arrays.
ArrayNumberValidator(RCP< const EnhancedNumberValidator< T > > prototypeValidator)
Convience class for StringValidators that are to be applied to arrays.
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
Standard implementation of a BoolParameterEntryValidator that accepts bool values (true/false) or str...
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< BoolParameterEntryValidator > boolParameterEntryValidator()
Nonmember constructor BoolParameterEntryValidator.
Class for retrieving a dummy object of type T.
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
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.
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.
void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
T getStep() const
Gets the step being used for the validator.
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.
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.
Validate a file name entry.
static bool mustAlreadyExistDefault()
The default value of the mustAlreadyExist parameter in the constructor.
Abstract interface for an object that can validate a ParameterEntry's value.
virtual void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
Validate and perhaps modify a parameter entry's value.
This object is held as the "value" in the Teuchos::ParameterList std::map.
bool isType() const
Test the type of the data being contained.
any & getAny(bool activeQry=true)
Direct access to the Teuchos::any data value underlying this object. The bool argument activeQry (def...
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.
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.
void setStringToIntegralParameter(std::string const ¶mName, std::string const &defaultValue, std::string const &docString, ArrayView< const std::string > const &strings, ArrayView< const std::string > const &stringsDocs, ArrayView< const IntegralType > const &integralValues, ParameterList *paramList)
Set up a std::string parameter with documentation strings for each valid value that will use an embed...
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 ...
void setStringToIntegralParameter(std::string const ¶mName, std::string const &defaultValue, std::string const &docString, ArrayView< const std::string > const &strings, ArrayView< const IntegralType > const &integralValues, ParameterList *paramList)
Set up a std::string parameter that will use an embedded validator to allow the extraction of an inte...
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 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 ...
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.
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< 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.
T * get() const
Get the raw C++ pointer to the underlying object.
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...
IntegralType getIntegralValue(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Find the enum or integer value for the given ParameterEntry.
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 .
StringToIntegralParameterEntryValidator(const ArrayView< const std::string > &strings, const ArrayView< const std::string > &stringsDocs, const ArrayView< const IntegralType > &integralValues, const std::string &defaultParameterName, const bool caseSensitive=true)
Construct with a mapping from strings (with documentation) to specified enum or integer values,...
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).
IntegralType getIntegralValue(ParameterList ¶mList, const std::string ¶mName, const std::string &defaultValue) const
Get the integer enum value for the given parameter.
StringToIntegralParameterEntryValidator(const ArrayView< const std::string > &strings, const ArrayView< const IntegralType > &integralValues, std::string const &defaultParameterName, const bool caseSensitive=true)
Construct with a mapping from strings to specified enum or integer values.
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).
bool isCaseSensitive() const
Whether this validator is case sensitive.
std::string getStringValue(ParameterList ¶mList, const std::string ¶mName, const std::string &defaultValue) const
Lookup a parameter from a parameter list, validate the std::string value, and return the std::string ...
void printDoc(std::string const &docString, std::ostream &out) const
Print documentation to the given output string.
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).
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...
bool isCaseSensitive() const
Whether this validator is case sensitive.
Convience class for FileNameValidators that are to be applied to TwoDArrays.
TwoDArrayFileNameValidator(RCP< const FileNameValidator > prototypeValidator)
Convience class for EnhancedNumberValidators that are to be applied to TwoDArray.
TwoDArrayNumberValidator(RCP< const EnhancedNumberValidator< T > > prototypeValidator)
Convience class for StringValidators that are to be applied to TwoDArrays.
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
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.
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 ...
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
EVerbosityLevel
Verbosity level.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
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.
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!