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" 55 #ifdef HAVE_TEUCHOSCORE_QUADMATH 56 # include <quadmath.h> 57 #endif // HAVE_TEUCHOSCORE_QUADMATH 91 template<
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 =
"" 294 return caseSensitive_;
306 std::string
const& docString,
317 std::string
const& paramName,
318 std::string
const& sublistName
324 std::string defaultParameterName_;
325 std::string validValues_;
329 typedef std::map<std::string,IntegralType> map_t;
332 const bool caseSensitive_;
343 static std::string upperCase (
const std::string s) {
344 std::string s_upper = s;
345 std::transform (s_upper.begin (), s_upper.end (), s_upper.begin (), ::toupper);
355 template<
class IntegralType>
359 std::string
const& defaultParameterName
367 template<
class IntegralType>
371 std::string
const& defaultParameterName,
372 const bool caseSensitive
380 template<
class IntegralType>
385 std::string
const& defaultParameterName
393 template<
class IntegralType>
398 std::string
const& defaultParameterName,
399 const bool caseSensitive
407 template<
class IntegralType>
413 std::string
const& defaultParameterName
421 template<
class IntegralType>
427 std::string
const& defaultParameterName,
428 const bool caseSensitive
442 template<
class IntegralType>
443 void setStringToIntegralParameter(
444 std::string
const& paramName,
445 std::string
const& defaultValue,
446 std::string
const& docString,
463 template<
class IntegralType>
464 void setStringToIntegralParameter(
465 std::string
const& paramName,
466 std::string
const& defaultValue,
467 std::string
const& docString,
485 template<
class IntegralType>
486 void setStringToIntegralParameter(
487 std::string
const& paramName,
488 std::string
const& defaultValue,
489 std::string
const& docString,
507 template<
class IntegralType>
524 template<
class IntegralType>
535 template<
class IntegralType>
539 std::string
const& paramName
548 std::string getVerbosityLevelParameterValueName(
558 verbosityLevelParameterEntryValidator(std::string
const& defaultParameterName);
565 template<
class IntegralType>
582 template<
class IntegralType>
586 return stringToIntegralParameterEntryValidator<IntegralType>(
587 tuple<std::string>(
""), tuple<std::string>(
""),
588 tuple<IntegralType>((IntegralType)1),
"");
623 :allowInt_(allowAllTypesByDefault),allowDouble_(allowAllTypesByDefault),
624 allowString_(allowAllTypesByDefault)
628 { allowInt_ = _allowInt;
return *
this; }
631 { allowDouble_ = _allowDouble;
return *
this; }
634 { allowString_ = _allowString;
return *
this; }
680 const std::string &sublistName =
"",
const bool activeQuery =
true 686 const std::string &sublistName =
"",
const bool activeQuery =
true 690 std::string getString(
692 const std::string &sublistName =
"",
const bool activeQuery =
true 700 const int defaultValue
708 const double defaultValue
714 std::string getString(
716 const std::string &defaultValue
721 bool isDoubleAllowed()
const;
725 bool isIntAllowed()
const;
729 bool isStringAllowed()
const;
740 return getIntEnumString ();
742 return getDoubleEnumString ();
744 return getStringEnumString ();
746 const std::string typeString (toString (enumValue));
747 throw std::runtime_error(
"Cannot convert enumValue: " + typeString +
" to a string");
754 if (enumString == getIntEnumString ()) {
757 else if (enumString == getDoubleEnumString ()) {
758 return PREFER_DOUBLE;
760 else if (enumString == getStringEnumString ()) {
761 return PREFER_STRING;
764 throw std::runtime_error (
"Cannot convert enumString: " + enumString +
" to an enum");
778 std::string
const& docString,
789 std::string
const& paramName,
790 std::string
const& sublistName
795 std::string
const& paramName,
796 std::string
const& sublistName,
809 std::string acceptedTypesString_;
813 #pragma warning(push) 814 #pragma warning(disable:4251) 825 static const std::string& getIntEnumString(){
827 return intEnumString_;
831 static const std::string& getDoubleEnumString(){
833 return doubleEnumString_;
837 static const std::string& getStringEnumString(){
839 return stringEnumString_;
843 void finishInitialization();
847 std::string
const& paramName,
848 std::string
const& sublistName
862 anyNumberParameterEntryValidator();
870 anyNumberParameterEntryValidator(
880 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
void setIntParameter(
881 std::string
const& paramName,
882 int const value, std::string
const& docString,
894 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
void setDoubleParameter(
895 std::string
const& paramName,
896 double const& value, std::string
const& docString,
908 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
void setNumericStringParameter(
909 std::string
const& paramName,
910 std::string
const& value, std::string
const& docString,
931 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
int getIntParameter(
950 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
double getDoubleParameter(
952 std::string
const& paramName
971 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT std::string getNumericStringParameter(
973 std::string
const& paramName
1007 return T::this_type_is_missing_a_specialization();
1060 static inline short int min() {
return std::numeric_limits<short int>::min(); }
1061 static inline short int max() {
return std::numeric_limits<short int>::max(); }
1062 static inline short int defaultStep() {
return 1; }
1063 static inline unsigned short defaultPrecision() {
return 0; }
1070 static inline short unsigned int min() {
return std::numeric_limits<short unsigned int>::min(); }
1071 static inline short unsigned int max() {
return std::numeric_limits<short unsigned int>::max(); }
1072 static inline short unsigned int defaultStep() {
return 1; }
1073 static inline unsigned short defaultPrecision() {
return 0; }
1080 static inline int min() {
return std::numeric_limits<int>::min(); }
1081 static inline int max() {
return std::numeric_limits<int>::max(); }
1082 static inline int defaultStep() {
return 1; }
1083 static inline unsigned short defaultPrecision() {
return 0; }
1090 static inline unsigned int min() {
return std::numeric_limits<unsigned int>::min(); }
1091 static inline unsigned int max() {
return std::numeric_limits<unsigned int>::max(); }
1092 static inline unsigned int defaultStep() {
return 1; }
1093 static inline unsigned short defaultPrecision() {
return 0; }
1100 static inline long int min() {
return std::numeric_limits<long int>::min(); }
1101 static inline long int max() {
return std::numeric_limits<long int>::max(); }
1102 static inline long int defaultStep() {
return 1; }
1103 static inline unsigned short defaultPrecision() {
return 0; }
1110 static inline long unsigned int min() {
return std::numeric_limits<long unsigned int>::min(); }
1111 static inline long unsigned int max() {
return std::numeric_limits<long unsigned int>::max(); }
1112 static inline long unsigned int defaultStep() {
return 1; }
1113 static inline unsigned short defaultPrecision() {
return 0; }
1117 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 1123 static inline long long int min() {
return std::numeric_limits<long long int>::min(); }
1124 static inline long long int max() {
return std::numeric_limits<long long int>::max(); }
1125 static inline long long int defaultStep() {
return 1; }
1126 static inline unsigned short defaultPrecision() {
return 0; }
1133 static inline long long unsigned int min() {
return std::numeric_limits<long long unsigned int>::min(); }
1134 static inline long long unsigned int max() {
return std::numeric_limits<long long unsigned int>::max(); }
1135 static inline long long unsigned int defaultStep() {
return 1; }
1136 static inline unsigned short defaultPrecision() {
return 0; }
1140 #endif // HAVE_TEUCHOS_LONG_LONG_INT 1143 #ifdef HAVE_TEUCHOSCORE_QUADMATH 1147 static inline __float128 min() {
return -std::numeric_limits<__float128>::max(); }
1148 static inline __float128 max() {
return std::numeric_limits<__float128>::max(); }
1149 static inline __float128 defaultStep() {
return 1; }
1150 static inline unsigned short defaultPrecision() {
return 100; }
1152 #endif // HAVE_TEUCHOSCORE_QUADMATH 1157 static inline double min() {
return -std::numeric_limits<double>::max(); }
1158 static inline double max() {
return std::numeric_limits<double>::max(); }
1159 static inline double defaultStep() {
return 1; }
1160 static inline unsigned short defaultPrecision() {
return 100; }
1166 static inline float min() {
return -std::numeric_limits<float>::max(); }
1167 static inline float max() {
return std::numeric_limits<float>::max(); }
1168 static inline float defaultStep() {
return 1; }
1169 static inline unsigned short defaultPrecision() {
return 100; }
1205 minVal(min), maxVal(max), step_(step), precision_(precision),
1206 containsMin(true), containsMax(true){}
1218 containsMax(false){}
1256 precision_ = precision;
1329 std::string
const &sublistName)
const;
1337 void printDoc(std::string
const &docString, std::ostream &out)
const{
1339 out <<
"#\tValidator Used: " << std::endl;
1340 out <<
"#\t\tNumber Validator" << std::endl;
1343 out <<
"#\t\tMin (inclusive): " << minVal << std::endl;
1344 out <<
"#\t\tMax (inclusive): " << maxVal << std::endl;
1369 unsigned short precision_;
1385 std::string
const &sublistName)
const 1392 "The \"" << paramName <<
"\"" <<
1393 " parameter in the \"" << sublistName <<
1394 "\" sublist is has an error." << std::endl << std::endl <<
1395 "Error: The value that you entered was the wrong type." << std::endl <<
1396 "Parameter: " << paramName << std::endl <<
1397 "Type specified: " << entryName << std::endl <<
1400 bool isValueInRange;
1401 any_cast<T>(anyValue) >= minVal && any_cast<T>(anyValue) <= maxVal
1402 ? isValueInRange =
true : isValueInRange=
false;
1405 "The \"" << paramName <<
"\"" <<
1406 " parameter in the \"" << sublistName <<
1407 "\" sublist is has an error." << std::endl << std::endl <<
1408 "Error: The value that was entered doesn't fall with in " <<
1409 "the range set by the validator" << std::endl <<
1410 "Parameter: " << paramName << std::endl <<
1411 "Min: " << minVal << std::endl <<
1412 "Max: " << maxVal << std::endl <<
1413 "Value entered: " <<
1414 (any_cast<T>(anyValue)) << std::endl << std::endl);
1486 bool fileMustExist()
const;
1501 bool fileEmptyNameOK()
const;
1516 bool setFileMustExist(
bool shouldFileExist);
1526 bool setFileEmptyNameOK(
bool isEmptyNameOK);
1539 std::string
const ¶mName,
1540 std::string
const &sublistName)
const;
1546 void printDoc(std::string
const &docString, std::ostream &out)
const;
1558 bool mustAlreadyExist_;
1636 std::string
const &sublistName)
const;
1642 void printDoc(std::string
const &docString, std::ostream &out)
const;
1685 template<
class Val
idatorType,
class EntryType>
1701 prototypeValidator_(prototypeValidator){}
1710 return prototypeValidator_;
1720 return prototypeValidator_->validStringValues();
1753 template<
class Val
idatorType,
class EntryType>
1775 std::string
const &sublistName)
const;
1779 return "TwoDArrayValidator(" +
1780 this->getPrototype()->getXMLTypeName() +
", " +
1785 virtual void printDoc(std::string
const &docString, std::ostream &out)
const 1788 std::string toPrint;
1789 toPrint +=
"TwoDArrayValidator:\n";
1790 toPrint +=
"Prototype Validator:\n";
1791 this->getPrototype()->printDoc(toPrint, out);
1798 template<
class Val
idatorType,
class EntryType>
1800 std::string
const &sublistName)
const 1806 "The \"" << paramName <<
"\"" <<
1807 " parameter in the \"" << sublistName <<
1808 "\" sublist is has an error." << std::endl << std::endl <<
1809 "Error: The value you entered was the wrong type." << std::endl <<
1810 "Parameter: " << paramName << std::endl <<
1811 "Type specified: " << entryName << std::endl <<
1813 std::endl << std::endl);
1816 getValue<Teuchos::TwoDArray<EntryType> >(entry);
1818 for(
int i = 0; i<extracted.getNumRows(); ++i){
1819 for(
int j = 0; j<extracted.getNumCols(); ++j){
1821 dummyParameter.
setValue(extracted(i,j));
1823 prototype->validate(
1824 dummyParameter, paramName, sublistName);
1827 std::stringstream oss;
1828 oss <<
"TwoDArray Validator Exception:" << std::endl <<
1829 "Bad Index: (" << i <<
"," << j <<
")" << std::endl << e.what();
1842 template<
class Val
idatorType,
class EntryType>
1859 template<
class Val
idatorType,
class EntryType>
1938 template<
class Val
idatorType,
class EntryType>
1961 std::string
const &sublistName)
const;
1965 return "ArrayValidator(" +
1966 this->getPrototype()->getXMLTypeName() +
", " +
1971 virtual void printDoc(std::string
const &docString, std::ostream &out)
const 1974 std::string toPrint;
1975 toPrint +=
"ArrayValidator:\n";
1976 toPrint +=
"Prototype Validator:\n";
1977 this->getPrototype()->printDoc(toPrint, out);
1984 template<
class Val
idatorType,
class EntryType>
1986 std::string
const &sublistName)
const 1992 "The \"" << paramName <<
"\"" <<
1993 " parameter in the \"" << sublistName <<
1994 "\" sublist is has an error." << std::endl << std::endl <<
1995 "Error: The value you entered was the wrong type." << std::endl <<
1996 "Parameter: " << paramName << std::endl <<
1997 "Type specified: " << entryName << std::endl <<
1999 std::endl << std::endl);
2002 getValue<Teuchos::Array<EntryType> >(entry);
2004 for(
int i = 0; i<extracted.size(); ++i){
2006 dummyParameter.
setValue(extracted[i]);
2008 prototype->validate(
2009 dummyParameter, paramName, sublistName);
2012 std::stringstream oss;
2013 oss <<
"Array Validator Exception:" << std::endl <<
2014 "Bad Index: " << i << std::endl << e.what();
2025 template<
class Val
idatorType,
class EntryType>
2042 template<
class Val
idatorType,
class EntryType>
2136 template<
class IntegralType>
2139 std::string
const& defaultParameterName,
2140 const bool caseSensitive) :
2142 defaultParameterName_ (defaultParameterName),
2143 caseSensitive_ (caseSensitive)
2145 typedef typename map_t::value_type val_t;
2146 for (
int i = 0; i < static_cast<int> (strings.
size ()); ++i) {
2147 const bool unique = caseSensitive_ ?
2148 map_.insert (val_t (strings[i], static_cast<IntegralType> (i))).second :
2149 map_.insert (val_t (upperCase (strings[i]), static_cast<IntegralType> (i))).second;
2151 ! unique, std::logic_error,
2152 "For parameter \"" << defaultParameterName_ <<
"\": " 2153 "strings[" << i <<
"] = \"" << strings[i] <<
"\" is a duplicate.");
2155 setValidValues (strings);
2159 template<
class IntegralType>
2163 std::string
const& defaultParameterName,
2164 const bool caseSensitive) :
2166 defaultParameterName_ (defaultParameterName),
2167 caseSensitive_ (caseSensitive)
2169 #ifdef TEUCHOS_DEBUG 2173 strings.
size() != integralValues.
size(),
2175 "The input arrays strings and integralValues must have the same length.");
2177 typedef typename map_t::value_type val_t;
2178 for (
int i = 0; i < static_cast<int> (strings.
size ()); ++i) {
2179 const bool unique = caseSensitive_ ?
2180 map_.insert (val_t (strings[i], integralValues[i])).second :
2181 map_.insert (val_t (upperCase (strings[i]), integralValues[i])).second;
2184 ! unique, std::logic_error,
2185 "For parameter \"" << defaultParameterName_ <<
"\": " 2186 "strings[" << i <<
"] = \"" << strings[i] <<
"\" is a duplicate.");
2188 setValidValues (strings);
2191 template<
class IntegralType>
2196 std::string
const& defaultParameterName,
2197 const bool caseSensitive) :
2199 defaultParameterName_ (defaultParameterName),
2200 caseSensitive_ (caseSensitive)
2202 #ifdef TEUCHOS_DEBUG 2208 strings.
size() != integralValues.
size(),
2210 "The input arrays strings and integralValues must have the same length.");
2213 strings.
size() != stringsDocs.
size(),
2215 "The input arrays strings and stringsDocs must have the same length.");
2217 typedef typename map_t::value_type val_t;
2218 for (
int i = 0; i < static_cast<int> (strings.
size ()); ++i) {
2219 const bool unique = caseSensitive_ ?
2220 map_.insert (val_t (strings[i], integralValues[i])).second :
2221 map_.insert (val_t (upperCase (strings[i]), integralValues[i])).second;
2223 ! unique, std::logic_error,
2224 "For parameter \"" << defaultParameterName_ <<
"\": " 2225 "strings[" << i <<
"] = \"" << strings[i] <<
"\" is a duplicate.");
2227 setValidValues(strings,&stringsDocs);
2233 template<
class IntegralType>
2236 const std::string &str,
const std::string ¶mName
2237 ,
const std::string &sublistName
2240 typename map_t::const_iterator itr = map_.find (caseSensitive_ ? str : upperCase (str));
2243 ,
"Error, the value \"" << str <<
"\" is not recognized for the parameter \"" 2244 << ( paramName.length() ? paramName : defaultParameterName_ ) <<
"\"" 2245 <<
"\nin the sublist \"" << sublistName <<
"\"." 2246 <<
"\n\nValid values include:" 2251 return (*itr).second;
2255 template<
class IntegralType>
2259 ,
const std::string &sublistName,
const bool activeQuery
2262 const bool validType = ( entry.
getAny(activeQuery).
type() ==
typeid(std::string) );
2265 ,
"Error, the parameter {paramName=\""<<(paramName.length()?paramName:defaultParameterName_)
2267 <<
"\nin the sublist \"" << sublistName <<
"\"" 2268 <<
"\nhas the wrong type." 2269 <<
"\n\nThe correct type is \"string\"!" 2272 &strValue = any_cast<std::string>(entry.
getAny(activeQuery));
2277 template<
class IntegralType>
2281 ,
const std::string &sublistName,
const bool activeQuery
2287 return any_cast<std::string>(entry.
getAny(activeQuery));
2291 template<
class IntegralType>
2295 ,
const std::string &defaultValue
2298 const std::string& strValue =
2299 paramList.
get (paramName,
2300 caseSensitive_ ? defaultValue : upperCase (defaultValue));
2305 template<
class IntegralType>
2309 ,
const std::string &defaultValue
2312 const std::string& strValue =
2313 paramList.
get (paramName,
2314 caseSensitive_ ? defaultValue : upperCase (defaultValue));
2319 template<
class IntegralType>
2323 return validStringValuesDocs_;
2326 template<
class IntegralType>
2330 return defaultParameterName_;
2333 template<
class IntegralType>
2336 const std::string &str,
const std::string ¶mName
2337 ,
const std::string &sublistName
2349 template<
class IntegralType>
2355 template<
class IntegralType>
2357 std::string
const& docString
2362 out <<
"# Valid std::string values:\n";
2364 if(validStringValuesDocs_.
get()) {
2365 for(
int i = 0; i < static_cast<int>(validStringValues_->size()); ++i ) {
2366 out <<
"# \"" << (*validStringValues_)[i] <<
"\"\n";
2379 template<
class IntegralType>
2383 return validStringValues_;
2387 template<
class IntegralType>
2390 ,std::string
const& paramName
2391 ,std::string
const& sublistName
2400 template<
class IntegralType>
2406 if (caseSensitive_) {
2412 (*vals)[i] = upperCase (strings[i]);
2421 std::ostringstream oss;
2422 for (
int i = 0; i < static_cast<int> (strings.
size()); ++i) {
2423 oss <<
" \"" << strings[i] <<
"\"\n";
2426 validValues_ = oss.str();
2438 template<
class IntegralType>
2441 Teuchos::stringToIntegralParameterEntryValidator(
2443 std::string
const& defaultParameterName
2448 strings, defaultParameterName
2454 template<
class IntegralType>
2457 Teuchos::stringToIntegralParameterEntryValidator(
2459 std::string
const& defaultParameterName,
2460 const bool caseSensitive
2464 return rcp (
new ret_type (strings, defaultParameterName, caseSensitive));
2469 template<
class IntegralType>
2472 Teuchos::stringToIntegralParameterEntryValidator(
2475 std::string
const& defaultParameterName
2480 strings, integralValues, defaultParameterName
2486 template<
class IntegralType>
2489 Teuchos::stringToIntegralParameterEntryValidator(
2492 std::string
const& defaultParameterName,
2493 const bool caseSensitive)
2496 return rcp (
new ret_type (strings, integralValues,
2497 defaultParameterName, caseSensitive));
2501 template<
class IntegralType>
2504 Teuchos::stringToIntegralParameterEntryValidator(
2508 std::string
const& defaultParameterName
2513 strings, stringsDocs, integralValues, defaultParameterName
2519 template<
class IntegralType>
2522 Teuchos::stringToIntegralParameterEntryValidator(
2526 std::string
const& defaultParameterName,
2527 const bool caseSensitive)
2530 return rcp (
new ret_type (strings, stringsDocs, integralValues,
2531 defaultParameterName, caseSensitive));
2535 template<
class IntegralType>
2536 void Teuchos::setStringToIntegralParameter(
2537 std::string
const& paramName,
2538 std::string
const& defaultValue,
2539 std::string
const& docString,
2547 paramName, defaultValue, docString,
2548 rcp_implicit_cast<const PEV>(
2549 stringToIntegralParameterEntryValidator<IntegralType>(
2557 template<
class IntegralType>
2558 void Teuchos::setStringToIntegralParameter(
2559 std::string
const& paramName,
2560 std::string
const& defaultValue,
2561 std::string
const& docString,
2570 paramName, defaultValue, docString,
2571 rcp_implicit_cast<const PEV>(
2572 stringToIntegralParameterEntryValidator<IntegralType>(
2573 strings, integralValues, paramName
2580 template<
class IntegralType>
2581 void Teuchos::setStringToIntegralParameter(
2582 std::string
const& paramName,
2583 std::string
const& defaultValue,
2584 std::string
const& docString,
2595 paramName, defaultValue, docString,
2596 rcp_implicit_cast<const PEV>(
2597 stringToIntegralParameterEntryValidator<IntegralType>(
2598 strings, stringsDocs, integralValues, paramName
2605 template<
class IntegralType>
2606 IntegralType Teuchos::getIntegralValue(
2607 ParameterList const& paramList, std::string
const& paramName
2612 integralValidator = getStringToIntegralParameterEntryValidator<IntegralType>(
2613 entry, paramList, paramName
2615 return integralValidator->getIntegralValue(
2616 entry, paramName, paramList.name(), true );
2620 template<
class IntegralType>
2621 std::string Teuchos::getStringValue(
2622 ParameterList const& paramList, std::string
const& paramName
2627 integralValidator = getStringToIntegralParameterEntryValidator<IntegralType>(
2628 entry, paramList, paramName
2630 return integralValidator->getStringValue(
2631 entry, paramName, paramList.name(), true
2636 template<
class IntegralType>
2640 std::string
const& paramName
2646 "Error! The parameter \""<<paramName<<
"\" exists\n" 2647 "in the parameter (sub)list \""<<paramList.
name()<<
"\"\n" 2648 "but it does not contain any validator needed to extract\n" 2657 "Error! The parameter \""<<paramName<<
"\" exists\n" 2658 "in the parameter (sub)list \""<<paramList.
name()<<
"\"\n" 2659 "but it contains the wrong type of validator. The expected validator type\n" 2661 "but the contained validator type is \""<<
typeName(*validator)<<
"\"!" 2663 return integralValidator;
2667 #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.
bool isCaseSensitive() const
Whether this validator is case sensitive.
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
Print documentation to the given output string.
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.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
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 an enum or i...
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
Validate the given ParameterEntry.
const std::string getXMLTypeName() const
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.
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
For a string value, find its corresponding enum or integer 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)