42 #ifndef TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H 43 #define TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H 45 #include "Teuchos_ParameterEntryValidator.hpp" 47 #include "Teuchos_ParameterListExceptions.hpp" 50 #include "Teuchos_Assert.hpp" 70 template<
class IntegralType>
86 std::string
const& defaultParameterName
107 std::string
const& defaultParameterName
133 std::string
const& defaultParameterName
153 const std::string &str,
const std::string ¶mName =
"",
154 const std::string &sublistName =
"" 172 const std::string &sublistName =
"",
const bool activeQuery =
true 191 const std::string &sublistName =
"",
const bool activeQuery =
true 202 const std::string &defaultValue
210 const std::string &defaultValue
238 const std::string &str,
const std::string ¶mName =
"",
239 const std::string &sublistName =
"" 252 std::string
const& docString,
263 std::string
const& paramName,
264 std::string
const& sublistName
271 typedef std::map<std::string,IntegralType> map_t;
272 std::string defaultParameterName_;
273 std::string validValues_;
293 template<
class IntegralType>
297 std::string
const& defaultParameterName
305 template<
class IntegralType>
310 std::string
const& defaultParameterName
318 template<
class IntegralType>
324 std::string
const& defaultParameterName
337 template<
class IntegralType>
338 void setStringToIntegralParameter(
339 std::string
const& paramName,
340 std::string
const& defaultValue,
341 std::string
const& docString,
358 template<
class IntegralType>
359 void setStringToIntegralParameter(
360 std::string
const& paramName,
361 std::string
const& defaultValue,
362 std::string
const& docString,
380 template<
class IntegralType>
381 void setStringToIntegralParameter(
382 std::string
const& paramName,
383 std::string
const& defaultValue,
384 std::string
const& docString,
402 template<
class IntegralType>
419 template<
class IntegralType>
430 template<
class IntegralType>
434 std::string
const& paramName
443 std::string getVerbosityLevelParameterValueName(
453 verbosityLevelParameterEntryValidator(std::string
const& defaultParameterName);
460 template<
class IntegralType>
477 template<
class IntegralType>
481 return stringToIntegralParameterEntryValidator<IntegralType>(
482 tuple<std::string>(
""), tuple<std::string>(
""),
483 tuple<IntegralType>((IntegralType)1),
"");
518 :allowInt_(allowAllTypesByDefault),allowDouble_(allowAllTypesByDefault),
519 allowString_(allowAllTypesByDefault)
523 { allowInt_ = _allowInt;
return *
this; }
526 { allowDouble_ = _allowDouble;
return *
this; }
529 { allowString_ = _allowString;
return *
this; }
575 const std::string &sublistName =
"",
const bool activeQuery =
true 581 const std::string &sublistName =
"",
const bool activeQuery =
true 585 std::string getString(
587 const std::string &sublistName =
"",
const bool activeQuery =
true 595 const int defaultValue
603 const double defaultValue
609 std::string getString(
611 const std::string &defaultValue
616 bool isDoubleAllowed()
const;
620 bool isIntAllowed()
const;
624 bool isStringAllowed()
const;
631 static const std::string&
636 return getIntEnumString();
639 return getDoubleEnumString();
642 return getStringEnumString();
645 static const std::string typeString(toString(enumValue));
646 throw std::runtime_error(
"Cannot convert enumValue: " + typeString +
" to a string");
655 if(enumString == getIntEnumString()){
658 else if(enumString == getDoubleEnumString()){
659 return PREFER_DOUBLE;
661 else if(enumString == getStringEnumString()){
662 return PREFER_STRING;
665 throw std::runtime_error(
"Cannot convert enumString: " + enumString +
" to an enum");
681 std::string
const& docString,
692 std::string
const& paramName,
693 std::string
const& sublistName
698 std::string
const& paramName,
699 std::string
const& sublistName,
712 std::string acceptedTypesString_;
716 #pragma warning(push) 717 #pragma warning(disable:4251) 728 static const std::string& getIntEnumString(){
730 return intEnumString_;
734 static const std::string& getDoubleEnumString(){
736 return doubleEnumString_;
740 static const std::string& getStringEnumString(){
742 return stringEnumString_;
746 void finishInitialization();
750 std::string
const& paramName,
751 std::string
const& sublistName
765 anyNumberParameterEntryValidator();
773 anyNumberParameterEntryValidator(
783 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
void setIntParameter(
784 std::string
const& paramName,
785 int const value, std::string
const& docString,
797 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
void setDoubleParameter(
798 std::string
const& paramName,
799 double const& value, std::string
const& docString,
811 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
void setNumericStringParameter(
812 std::string
const& paramName,
813 std::string
const& value, std::string
const& docString,
834 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
int getIntParameter(
853 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
double getDoubleParameter(
855 std::string
const& paramName
874 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT std::string getNumericStringParameter(
876 std::string
const& paramName
910 return T::this_type_is_missing_a_specialization();
963 static inline short int min() {
return std::numeric_limits<short int>::min(); }
964 static inline short int max() {
return std::numeric_limits<short int>::max(); }
965 static inline short int defaultStep() {
return 1; }
966 static inline unsigned short defaultPrecision() {
return 0; }
973 static inline short unsigned int min() {
return std::numeric_limits<short unsigned int>::min(); }
974 static inline short unsigned int max() {
return std::numeric_limits<short unsigned int>::max(); }
975 static inline short unsigned int defaultStep() {
return 1; }
976 static inline unsigned short defaultPrecision() {
return 0; }
983 static inline int min() {
return std::numeric_limits<int>::min(); }
984 static inline int max() {
return std::numeric_limits<int>::max(); }
985 static inline int defaultStep() {
return 1; }
986 static inline unsigned short defaultPrecision() {
return 0; }
993 static inline unsigned int min() {
return std::numeric_limits<unsigned int>::min(); }
994 static inline unsigned int max() {
return std::numeric_limits<unsigned int>::max(); }
995 static inline unsigned int defaultStep() {
return 1; }
996 static inline unsigned short defaultPrecision() {
return 0; }
1003 static inline long int min() {
return std::numeric_limits<long int>::min(); }
1004 static inline long int max() {
return std::numeric_limits<long int>::max(); }
1005 static inline long int defaultStep() {
return 1; }
1006 static inline unsigned short defaultPrecision() {
return 0; }
1013 static inline long unsigned int min() {
return std::numeric_limits<long unsigned int>::min(); }
1014 static inline long unsigned int max() {
return std::numeric_limits<long unsigned int>::max(); }
1015 static inline long unsigned int defaultStep() {
return 1; }
1016 static inline unsigned short defaultPrecision() {
return 0; }
1020 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 1026 static inline long long int min() {
return std::numeric_limits<long long int>::min(); }
1027 static inline long long int max() {
return std::numeric_limits<long long int>::max(); }
1028 static inline long long int defaultStep() {
return 1; }
1029 static inline unsigned short defaultPrecision() {
return 0; }
1036 static inline long long unsigned int min() {
return std::numeric_limits<long long unsigned int>::min(); }
1037 static inline long long unsigned int max() {
return std::numeric_limits<long long unsigned int>::max(); }
1038 static inline long long unsigned int defaultStep() {
return 1; }
1039 static inline unsigned short defaultPrecision() {
return 0; }
1043 #endif // HAVE_TEUCHOS_LONG_LONG_INT 1049 static inline double min() {
return -std::numeric_limits<double>::max(); }
1050 static inline double max() {
return std::numeric_limits<double>::max(); }
1051 static inline double defaultStep() {
return 1; }
1052 static inline unsigned short defaultPrecision() {
return 100; }
1059 static inline float min() {
return -std::numeric_limits<float>::max(); }
1060 static inline float max() {
return std::numeric_limits<float>::max(); }
1061 static inline float defaultStep() {
return 1; }
1062 static inline unsigned short defaultPrecision() {
return 100; }
1099 minVal(min), maxVal(max), step_(step), precision_(precision),
1100 containsMin(true), containsMax(true){}
1112 containsMax(false){}
1150 precision_ = precision;
1223 std::string
const &sublistName)
const;
1231 void printDoc(std::string
const &docString, std::ostream &out)
const{
1233 out <<
"#\tValidator Used: " << std::endl;
1234 out <<
"#\t\tNumber Validator" << std::endl;
1237 out <<
"#\t\tMin (inclusive): " << minVal << std::endl;
1238 out <<
"#\t\tMax (inclusive): " << maxVal << std::endl;
1263 unsigned short precision_;
1279 std::string
const &sublistName)
const 1286 "The \"" << paramName <<
"\"" <<
1287 " parameter in the \"" << sublistName <<
1288 "\" sublist is has an error." << std::endl << std::endl <<
1289 "Error: The value that you entered was the wrong type." << std::endl <<
1290 "Parameter: " << paramName << std::endl <<
1291 "Type specified: " << entryName << std::endl <<
1294 bool isValueInRange;
1295 any_cast<T>(anyValue) >= minVal && any_cast<T>(anyValue) <= maxVal
1296 ? isValueInRange =
true : isValueInRange=
false;
1299 "The \"" << paramName <<
"\"" <<
1300 " parameter in the \"" << sublistName <<
1301 "\" sublist is has an error." << std::endl << std::endl <<
1302 "Error: The value that was entered doesn't fall with in " <<
1303 "the range set by the validator" << std::endl <<
1304 "Parameter: " << paramName << std::endl <<
1305 "Min: " << minVal << std::endl <<
1306 "Max: " << maxVal << std::endl <<
1307 "Value entered: " <<
1308 (any_cast<T>(anyValue)) << std::endl << std::endl);
1380 bool fileMustExist()
const;
1395 bool setFileMustExist(
bool shouldFileExist);
1408 std::string
const ¶mName,
1409 std::string
const &sublistName)
const;
1415 void printDoc(std::string
const &docString, std::ostream &out)
const;
1427 bool mustAlreadyExist_;
1504 std::string
const &sublistName)
const;
1510 void printDoc(std::string
const &docString, std::ostream &out)
const;
1553 template<
class Val
idatorType,
class EntryType>
1569 prototypeValidator_(prototypeValidator){}
1578 return prototypeValidator_;
1588 return prototypeValidator_->validStringValues();
1621 template<
class Val
idatorType,
class EntryType>
1643 std::string
const &sublistName)
const;
1647 return "TwoDArrayValidator(" +
1648 this->getPrototype()->getXMLTypeName() +
", " +
1653 virtual void printDoc(std::string
const &docString, std::ostream &out)
const 1656 std::string toPrint;
1657 toPrint +=
"TwoDArrayValidator:\n";
1658 toPrint +=
"Prototype Validator:\n";
1659 this->getPrototype()->printDoc(toPrint, out);
1666 template<
class Val
idatorType,
class EntryType>
1668 std::string
const &sublistName)
const 1674 "The \"" << paramName <<
"\"" <<
1675 " parameter in the \"" << sublistName <<
1676 "\" sublist is has an error." << std::endl << std::endl <<
1677 "Error: The value you entered was the wrong type." << std::endl <<
1678 "Parameter: " << paramName << std::endl <<
1679 "Type specified: " << entryName << std::endl <<
1681 std::endl << std::endl);
1684 getValue<Teuchos::TwoDArray<EntryType> >(entry);
1686 for(
int i = 0; i<extracted.getNumRows(); ++i){
1687 for(
int j = 0; j<extracted.getNumCols(); ++j){
1689 dummyParameter.
setValue(extracted(i,j));
1691 prototype->validate(
1692 dummyParameter, paramName, sublistName);
1695 std::stringstream oss;
1696 oss <<
"TwoDArray Validator Exception:" << std::endl <<
1697 "Bad Index: (" << i <<
"," << j <<
")" << std::endl << e.what();
1710 template<
class Val
idatorType,
class EntryType>
1727 template<
class Val
idatorType,
class EntryType>
1806 template<
class Val
idatorType,
class EntryType>
1829 std::string
const &sublistName)
const;
1833 return "ArrayValidator(" +
1834 this->getPrototype()->getXMLTypeName() +
", " +
1839 virtual void printDoc(std::string
const &docString, std::ostream &out)
const 1842 std::string toPrint;
1843 toPrint +=
"ArrayValidator:\n";
1844 toPrint +=
"Prototype Validator:\n";
1845 this->getPrototype()->printDoc(toPrint, out);
1852 template<
class Val
idatorType,
class EntryType>
1854 std::string
const &sublistName)
const 1860 "The \"" << paramName <<
"\"" <<
1861 " parameter in the \"" << sublistName <<
1862 "\" sublist is has an error." << std::endl << std::endl <<
1863 "Error: The value you entered was the wrong type." << std::endl <<
1864 "Parameter: " << paramName << std::endl <<
1865 "Type specified: " << entryName << std::endl <<
1867 std::endl << std::endl);
1870 getValue<Teuchos::Array<EntryType> >(entry);
1872 for(
int i = 0; i<extracted.size(); ++i){
1874 dummyParameter.
setValue(extracted[i]);
1876 prototype->validate(
1877 dummyParameter, paramName, sublistName);
1880 std::stringstream oss;
1881 oss <<
"Array Validator Exception:" << std::endl <<
1882 "Bad Index: " << i << std::endl << e.what();
1893 template<
class Val
idatorType,
class EntryType>
1910 template<
class Val
idatorType,
class EntryType>
2004 template<
class IntegralType>
2009 defaultParameterName_(defaultParameterName)
2011 typedef typename map_t::value_type val_t;
2012 for(
int i = 0; i < static_cast<int>(strings.
size()); ++i ) {
2013 const bool unique = map_.insert( val_t( strings[i], (IntegralType)i ) ).second;
2015 !unique, std::logic_error
2016 ,
"Error, the std::string \"" << strings[i] <<
"\" is a duplicate for parameter \"" 2017 << defaultParameterName_ <<
"\"." 2020 setValidValues(strings);
2024 template<
class IntegralType>
2027 ,std::string
const& defaultParameterName
2030 defaultParameterName_(defaultParameterName)
2032 #ifdef TEUCHOS_DEBUG 2036 strings.
size() != integralValues.
size(),
2038 "Error, strings and integraValues must be of the same length." 2040 typedef typename map_t::value_type val_t;
2041 for(
int i = 0; i < static_cast<int>(strings.
size()); ++i ) {
2042 const bool unique = map_.insert( val_t( strings[i], integralValues[i] ) ).second;
2044 !unique, std::logic_error
2045 ,
"Error, the std::string \"" << strings[i] <<
"\" is a duplicate for parameter \"" 2046 << defaultParameterName_ <<
"\"" 2049 setValidValues(strings);
2052 template<
class IntegralType>
2057 ,std::string
const& defaultParameterName
2060 defaultParameterName_(defaultParameterName)
2062 #ifdef TEUCHOS_DEBUG 2067 strings.
size() != integralValues.
size(),
2069 "Error, strings and integraValues must be of the same length." 2072 strings.
size() != stringsDocs.
size(),
2074 "Error, strings and stringsDocs must be of the same length." 2076 typedef typename map_t::value_type val_t;
2077 for(
int i = 0; i < static_cast<int>(strings.
size()); ++i ) {
2078 const bool unique = map_.insert( val_t( strings[i], integralValues[i] ) ).second;
2080 !unique, std::logic_error
2081 ,
"Error, the std::string \"" << strings[i] <<
"\" is a duplicate for parameter \"" 2082 << defaultParameterName_ <<
"\"" 2085 setValidValues(strings,&stringsDocs);
2091 template<
class IntegralType>
2094 const std::string &str,
const std::string ¶mName
2095 ,
const std::string &sublistName
2098 typename map_t::const_iterator itr = map_.find(str);
2101 ,
"Error, the value \"" << str <<
"\" is not recognized for the parameter \"" 2102 << ( paramName.length() ? paramName : defaultParameterName_ ) <<
"\"" 2103 <<
"\nin the sublist \"" << sublistName <<
"\"." 2104 <<
"\n\nValid values include:" 2109 return (*itr).second;
2113 template<
class IntegralType>
2117 ,
const std::string &sublistName,
const bool activeQuery
2120 const bool validType = ( entry.
getAny(activeQuery).
type() ==
typeid(std::string) );
2123 ,
"Error, the parameter {paramName=\""<<(paramName.length()?paramName:defaultParameterName_)
2125 <<
"\nin the sublist \"" << sublistName <<
"\"" 2126 <<
"\nhas the wrong type." 2127 <<
"\n\nThe correct type is \"string\"!" 2130 &strValue = any_cast<std::string>(entry.
getAny(activeQuery));
2135 template<
class IntegralType>
2139 ,
const std::string &sublistName,
const bool activeQuery
2145 return any_cast<std::string>(entry.
getAny(activeQuery));
2149 template<
class IntegralType>
2153 ,
const std::string &defaultValue
2157 &strValue = paramList.
get(paramName,defaultValue);
2162 template<
class IntegralType>
2166 ,
const std::string &defaultValue
2170 &strValue = paramList.
get(paramName,defaultValue);
2175 template<
class IntegralType>
2179 return validStringValuesDocs_;
2182 template<
class IntegralType>
2186 return defaultParameterName_;
2189 template<
class IntegralType>
2192 const std::string &str,
const std::string ¶mName
2193 ,
const std::string &sublistName
2203 template<
class IntegralType>
2206 return "StringIntegralValidator(" +
2211 template<
class IntegralType>
2213 std::string
const& docString
2218 out <<
"# Valid std::string values:\n";
2220 if(validStringValuesDocs_.
get()) {
2221 for(
int i = 0; i < static_cast<int>(validStringValues_->size()); ++i ) {
2222 out <<
"# \"" << (*validStringValues_)[i] <<
"\"\n";
2235 template<
class IntegralType>
2239 return validStringValues_;
2243 template<
class IntegralType>
2246 ,std::string
const& paramName
2247 ,std::string
const& sublistName
2256 template<
class IntegralType>
2267 std::ostringstream oss;
2268 for(
int i = 0; i < static_cast<int>(strings.
size()); ++i ) {
2269 oss <<
" \""<<strings[i]<<
"\"\n";
2272 validValues_ = oss.str();
2284 template<
class IntegralType>
2287 Teuchos::stringToIntegralParameterEntryValidator(
2289 std::string
const& defaultParameterName
2294 strings, defaultParameterName
2300 template<
class IntegralType>
2303 Teuchos::stringToIntegralParameterEntryValidator(
2306 std::string
const& defaultParameterName
2311 strings, integralValues, defaultParameterName
2317 template<
class IntegralType>
2320 Teuchos::stringToIntegralParameterEntryValidator(
2324 std::string
const& defaultParameterName
2329 strings, stringsDocs, integralValues, defaultParameterName
2334 template<
class IntegralType>
2335 void Teuchos::setStringToIntegralParameter(
2336 std::string
const& paramName,
2337 std::string
const& defaultValue,
2338 std::string
const& docString,
2346 paramName, defaultValue, docString,
2347 rcp_implicit_cast<const PEV>(
2348 stringToIntegralParameterEntryValidator<IntegralType>(
2356 template<
class IntegralType>
2357 void Teuchos::setStringToIntegralParameter(
2358 std::string
const& paramName,
2359 std::string
const& defaultValue,
2360 std::string
const& docString,
2369 paramName, defaultValue, docString,
2370 rcp_implicit_cast<const PEV>(
2371 stringToIntegralParameterEntryValidator<IntegralType>(
2372 strings, integralValues, paramName
2379 template<
class IntegralType>
2380 void Teuchos::setStringToIntegralParameter(
2381 std::string
const& paramName,
2382 std::string
const& defaultValue,
2383 std::string
const& docString,
2394 paramName, defaultValue, docString,
2395 rcp_implicit_cast<const PEV>(
2396 stringToIntegralParameterEntryValidator<IntegralType>(
2397 strings, stringsDocs, integralValues, paramName
2404 template<
class IntegralType>
2405 IntegralType Teuchos::getIntegralValue(
2406 ParameterList const& paramList, std::string
const& paramName
2411 integralValidator = getStringToIntegralParameterEntryValidator<IntegralType>(
2412 entry, paramList, paramName
2414 return integralValidator->getIntegralValue(
2415 entry, paramName, paramList.name(), true );
2419 template<
class IntegralType>
2420 std::string Teuchos::getStringValue(
2421 ParameterList const& paramList, std::string
const& paramName
2426 integralValidator = getStringToIntegralParameterEntryValidator<IntegralType>(
2427 entry, paramList, paramName
2429 return integralValidator->getStringValue(
2430 entry, paramName, paramList.name(), true
2435 template<
class IntegralType>
2439 std::string
const& paramName
2445 "Error! The parameter \""<<paramName<<
"\" exists\n" 2446 "in the parameter (sub)list \""<<paramList.
name()<<
"\"\n" 2447 "but it does not contain any validator needed to extract\n" 2456 "Error! The parameter \""<<paramName<<
"\" exists\n" 2457 "in the parameter (sub)list \""<<paramList.
name()<<
"\"\n" 2458 "but it contains the wrong type of validator. The expected validator type\n" 2460 "but the contained validator type is \""<<
typeName(*validator)<<
"\"!" 2462 return integralValidator;
2466 #endif // TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H static bool mustAlreadyExistDefault()
The default value of the mustAlreadyExist parameter in the constructor.
A thin wrapper around the Teuchos Array class that allows for 2 dimensional arrays.
std::string validateString(const std::string &str, const std::string ¶mName="", const std::string &sublistName="") const
Validate the std::string and pass it on.
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator(ArrayView< const std::string > const &strings, std::string const &defaultParameterName)
Nonmember constructor (see implementation).
const std::string & name() const
The name of this ParameterList.
T getMax() const
Gets the maximum acceptable value for the validator.
EnhancedNumberValidator()
Constructs a EnhancedNumberValidator without an explicit minimum or maximum.
Convience class for StringValidators that are to be applied to TwoDArrays.
void printDoc(std::string const &docString, std::ostream &out) const
bool is_null(const boost::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...
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.
ValidStringsList validStringValues() const
bool allowInt() const
Allow an int value?
Convience class for EnhancedNumberValidators that are to be applied to arrays.
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
EPreferredType
Determines what type is the preferred type.
T & get(const std::string &name, T def_value)
Return the parameter's value, or the default value if it is not there.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Set a parameter whose value has type T.
This object is held as the "value" in the Teuchos::ParameterList std::map.
virtual void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool allowString() const
Allow an std::string value?
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
Default structure used by EnhancedNumberTraits<T> to produce a compile time error when the specializa...
void setMax(T max)
Sets the maximum acceptable value for the validator.
size_type size() const
The total number of items in the managed array.
Standard implementation of a ParameterEntryValidator that maps from a list of strings to some integra...
AcceptedTypes & allowString(bool _allowString)
Set allow an std::string value or not.
T * get() const
Get the raw C++ pointer to the underlying object.
bool hasMax() const
Determines whether or not the validator has a maximum value.
T getMin() const
Gets the minimum acceptable value for the validator.
static std::ostream & printLines(std::ostream &os, const std::string &linePrefix, const std::string &lines)
Print lines with prefix first.
EVerbosityLevel
Verbosity level.
Modified boost::any class, which is a container for a templated value.
static EPreferredType getPrefferedTypeStringEnum(const std::string &enumString)
Gets the preferred type enum associated with a give string.
AcceptedTypes & allowInt(bool _allowInt)
Set allow an int value or not.
AbstractArrayValidator(RCP< const ValidatorType > prototypeValidator)
Constructs an AbstractArrayValidator.
Takes a validator, wraps it, and applies it to a TwoDArray.
bool hasMin() const
Determines whether or not the validator has a minimum value.
unsigned short getPrecision() const
Gets the precision specified for the validator.
virtual void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
Validate and perhaps modify a parameter entry's value.
A std::string utilities class for Teuchos.
Determines the types that are accepted.
ValidStringsList validStringValues() const
A thin wrapper around the Array class which causes it to be interpurted as a 2D Array.
RCP< const ValidatorType > getPrototype() const
Returns the prototype validator for this Array Validator.
void printDoc(std::string const &docString, std::ostream &out) const
Convience class for StringValidators that are to be applied to arrays.
static T notDefined()
This function should not compile if there is an attempt to instantiate!
ValidStringsList validStringValues() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
const std::string getXMLTypeName() const
static unsigned short defaultPrecision()
Gets the default precision with which the number type should be displayed.
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
const std::string getXMLTypeName() const
std::string getStringValue(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get and validate a std::string value embedded in a ParameterEntry object.
ArrayStringValidator(RCP< const StringValidator > prototypeValidator)
Convience class for EnhancedNumberValidators that are to be applied to TwoDArray. ...
An abstract base class for all ArrayValidators.
ArrayValidator(RCP< const ValidatorType > prototypeValidator)
Constructs a ArrayValidator.
Convience class for FileNameValidators that are to be applied to TwoDArrays.
Validate a file name entry.
const std::string getXMLTypeName() const
AcceptedTypes(bool allowAllTypesByDefault=true)
Allow all types or not on construction.
void setStep(T step)
Sets the step being used for the validator.
Takes a validator, wraps it, and applies it to an array.
A list of parameters of arbitrary type.
bool allowDouble() const
Allow an double value?
A simple validator that only allows certain string values to be choosen or simply enforces that a par...
static T min()
Gets the minimum possible value the number type can take on.
TwoDArrayValidator(RCP< const ValidatorType > prototypeValidator)
Constructs a ArrayValidator.
Abstract interface for an object that can validate a ParameterEntry's value.
any & getAny(bool activeQry=true)
Direct access to the Teuchos::any data value underlying this object. The bool argument activeQry (def...
void setPrecision(unsigned short precision)
Sets the precision specified for the validator.
IntegralType getIntegralValue(const std::string &str, const std::string ¶mName="", const std::string &sublistName="") const
Perform a mapping from a std::string value to its integral value.
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.
virtual void printDoc(std::string const &docString, std::ostream &out) const
RCP< const Array< std::string > > ValidStringsList
Default traits class that just returns typeid(T).name().
Class for retrieving a dummy object of type T.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
static const std::string & getPrefferedTypeString(EPreferredType enumValue)
Gets the string representation of a given preferred type enum.
ArrayFileNameValidator(RCP< const FileNameValidator > prototypeValidator)
static T defaultStep()
gets default amount a value of the number type should be incremented by when being utilizied in a UI...
static T max()
Gets the maximum possible value the number type can take on.
Class uesd to validate a particular type of number.
Convience class for FileNameValidators that are to be applied to arrays.
Class defining the traits of the number type being used in an EnhancedNumberValidator.
virtual void printDoc(std::string const &docString, std::ostream &out) const
std::string typeName() const
Return the name of the type.
TwoDArrayNumberValidator(RCP< const EnhancedNumberValidator< T > > prototypeValidator)
AcceptedTypes & allowDouble(bool _allowDouble)
Set allow a double value or not.
ValidStringsList getStringDocs() const
Get a pointer to the array containing all the documentation strings.
Smart reference counting pointer class for automatic garbage collection.
TwoDArrayStringValidator(RCP< const StringValidator > prototypeValidator)
const std::type_info & type() const
Return the type of value being stored.
TwoDArrayFileNameValidator(RCP< const FileNameValidator > prototypeValidator)
virtual void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
#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 ...
const std::string & getDefaultParameterName() const
Get the name of the default parameter for the validator.
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.
T getStep() const
Gets the step being used for the validator.
Defines basic traits returning the name of a type in a portable and readable way. ...
#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...
const std::string getXMLTypeName() const
static std::string name()
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
ArrayNumberValidator(RCP< const EnhancedNumberValidator< T > > prototypeValidator)