42 #ifndef TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H
43 #define TEUCHOS_STANDARD_PARAMETER_ENTRY_VALIDATORS_H
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;
293 template<
class IntegralType>
295 stringToIntegralParameterEntryValidator(
297 std::string
const& defaultParameterName
305 template<
class IntegralType>
307 stringToIntegralParameterEntryValidator(
310 std::string
const& defaultParameterName
318 template<
class IntegralType>
320 stringToIntegralParameterEntryValidator(
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>
403 IntegralType getIntegralValue(
419 template<
class IntegralType>
420 std::string getStringValue(
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");
677 const std::string getXMLTypeName()
const;
681 std::string
const& docString,
687 validStringValues()
const;
692 std::string
const& paramName,
693 std::string
const& sublistName
697 void validateAndModify(
698 std::string
const& paramName,
699 std::string
const& sublistName,
716 #pragma warning(push)
717 #pragma warning(disable:4251)
730 return intEnumString_;
736 return doubleEnumString_;
742 return stringEnumString_;
746 void finishInitialization();
750 std::string
const& paramName,
751 std::string
const& sublistName
765 anyNumberParameterEntryValidator();
773 anyNumberParameterEntryValidator(
775 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
784 std::string
const& paramName,
785 int const value, std::string
const& docString,
786 ParameterList *paramList,
787 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
788 = AnyNumberParameterEntryValidator::AcceptedTypes()
798 std::string
const& paramName,
799 double const& value, std::string
const& docString,
800 ParameterList *paramList,
801 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
802 = AnyNumberParameterEntryValidator::AcceptedTypes()
812 std::string
const& paramName,
813 std::string
const& value, std::string
const& docString,
814 ParameterList *paramList,
815 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
816 = AnyNumberParameterEntryValidator::AcceptedTypes()
835 ParameterList
const& paramList, std::string
const& paramName
854 ParameterList
const& paramList,
855 std::string
const& paramName
875 ParameterList
const& paramList,
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(); }
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(); }
983 static inline int min() {
return std::numeric_limits<int>::min(); }
984 static inline int max() {
return std::numeric_limits<int>::max(); }
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(); }
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(); }
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(); }
1020 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
1024 class EnhancedNumberTraits<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; }
1034 class EnhancedNumberTraits<long long unsigned int>{
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; }
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(); }
1059 static inline float min() {
return -std::numeric_limits<float>::max(); }
1060 static inline float max() {
return std::numeric_limits<float>::max(); }
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;
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);
1403 ValidStringsList validStringValues()
const;
1408 std::string
const ¶mName,
1409 std::string
const &sublistName)
const;
1412 const std::string getXMLTypeName()
const;
1415 void printDoc(std::string
const &docString, std::ostream &out)
const;
1491 ValidStringsList setValidStrings(
1500 ValidStringsList validStringValues()
const;
1503 void validate(
ParameterEntry const &entry, std::string
const ¶mName,
1504 std::string
const &sublistName)
const;
1507 const std::string getXMLTypeName()
const;
1510 void printDoc(std::string
const &docString, std::ostream &out)
const;
1553 template<
class Val
idatorType,
class EntryType>
1621 template<
class Val
idatorType,
class EntryType>
1643 std::string
const &sublistName)
const;
1647 return "TwoDArrayValidator(" +
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";
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(" +
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";
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 \""
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 \""
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 \""
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));
2131 return getIntegralValue(strValue,paramName,sublistName);
2135 template<
class IntegralType>
2139 ,
const std::string &sublistName,
const bool activeQuery
2143 this->getIntegralValue(entry,paramName,sublistName,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);
2158 return getIntegralValue(strValue,paramName,paramList.
name());
2162 template<
class IntegralType>
2166 ,
const std::string &defaultValue
2170 &strValue = paramList.
get(paramName,defaultValue);
2171 getIntegralValue(strValue,paramName,paramList.
name());
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
2196 getIntegralValue(str,paramName,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
2250 this->getIntegralValue(entry,paramName,sublistName,
false);
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(
2288 ArrayView<const std::string>
const& strings,
2289 std::string
const& defaultParameterName
2293 new StringToIntegralParameterEntryValidator<IntegralType>(
2294 strings, defaultParameterName
2300 template<
class IntegralType>
2303 Teuchos::stringToIntegralParameterEntryValidator(
2304 ArrayView<const std::string>
const& strings,
2305 ArrayView<const IntegralType>
const& integralValues,
2306 std::string
const& defaultParameterName
2310 new StringToIntegralParameterEntryValidator<IntegralType>(
2311 strings, integralValues, defaultParameterName
2317 template<
class IntegralType>
2320 Teuchos::stringToIntegralParameterEntryValidator(
2321 ArrayView<const std::string>
const& strings,
2322 ArrayView<const std::string>
const& stringsDocs,
2323 ArrayView<const IntegralType>
const& integralValues,
2324 std::string
const& defaultParameterName
2328 new StringToIntegralParameterEntryValidator<IntegralType>(
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,
2339 ArrayView<const std::string>
const& strings,
2340 ParameterList * paramList
2343 typedef ParameterEntryValidator PEV;
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,
2361 ArrayView<const std::string>
const& strings,
2362 ArrayView<const IntegralType>
const& integralValues,
2363 ParameterList * paramList
2366 typedef ParameterEntryValidator PEV;
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,
2384 ArrayView<const std::string>
const& strings,
2385 ArrayView<const std::string>
const& stringsDocs,
2386 ArrayView<const IntegralType>
const& integralValues,
2387 ParameterList * paramList
2391 typedef ParameterEntryValidator PEV;
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
2409 const ParameterEntry &entry = paramList.getEntry(paramName);
2410 RCP<const StringToIntegralParameterEntryValidator<IntegralType> >
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
2424 const ParameterEntry &entry = paramList.getEntry(paramName);
2425 RCP<const StringToIntegralParameterEntryValidator<IntegralType> >
2426 integralValidator = getStringToIntegralParameterEntryValidator<IntegralType>(
2427 entry, paramList, paramName
2429 return integralValidator->getStringValue(
2430 entry, paramName, paramList.name(), true
2435 template<
class IntegralType>
2438 ParameterEntry
const& entry, ParameterList
const& paramList,
2439 std::string
const& paramName
2442 const RCP<const ParameterEntryValidator> validator = entry.validator();
2444 is_null(validator), Exceptions::InvalidParameterType,
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"
2448 "an integral value of type \""<<TypeNameTraits<IntegralType>::name()<<
"\"!"
2450 const RCP<const StringToIntegralParameterEntryValidator<IntegralType> > integralValidator =
2451 rcp_dynamic_cast<
const StringToIntegralParameterEntryValidator<IntegralType> >(
2455 is_null(integralValidator), Exceptions::InvalidParameterType,
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"
2459 "is \""<<TypeNameTraits<StringToIntegralParameterEntryValidator<IntegralType> >::name()<<
"\"\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< 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...
static const std::string & getStringEnumString()
static short int defaultStep()
const std::string & name() const
The name of this ParameterList.
T getMax() const
Gets the maximum acceptable value for the validator.
EVerbosityLevel
Verbosity level.
EnhancedNumberValidator()
Constructs a EnhancedNumberValidator without an explicit minimum or maximum.
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
Convience class for StringValidators that are to be applied to TwoDArrays.
void printDoc(std::string const &docString, std::ostream &out) const
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
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...
static float defaultStep()
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?
std::string acceptedTypesString_
Convience class for EnhancedNumberValidators that are to be applied to arrays.
RCP< T2 > rcp_dynamic_cast(const RCP< T1 > &p1, bool throw_on_fail=false)
Dynamic cast of underlying RCP type from T1* to T2*.
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.
This object is held as the "value" in the Teuchos::ParameterList std::map.
const AcceptedTypes acceptedTypes_
T minVal
The minimum value accepted by the validator.
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?
static unsigned short defaultPrecision()
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
static long unsigned int defaultStep()
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.
EPreferredType preferredType_
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.
static long int defaultStep()
static double defaultStep()
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.
ValidStringsList validStrings_
An array containing a list of all the valid string values.
static const std::string & getDoubleEnumString()
static unsigned short defaultPrecision()
static unsigned short defaultPrecision()
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.
bool is_null(const ArrayRCP< T > &p)
Returns true if p.get()==NULL.
ValidStringsList validStringValuesDocs_
static unsigned short defaultPrecision()
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.
A std::string utilities class for Teuchos.
Determines the types that are accepted.
StringToIntegralParameterEntryValidator()
ValidStringsList validStringValues() const
A thin wrapper around the Array class which causes it to be interpurted as a 2D Array.
static const std::string & getIntEnumString()
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 unsigned short defaultPrecision()
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
bool containsMax
Whetehr or not a maximum value has been specified for this validator.
const std::string getXMLTypeName() const
static unsigned short defaultPrecision()
std::string toString(const HashSet< Key > &h)
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.
static short unsigned int defaultStep()
Validate a file name entry.
std::map< std::string, IntegralType > map_t
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.
static unsigned short defaultPrecision()
Takes a validator, wraps it, and applies it to an array.
A list of parameters of arbitrary type.
static long unsigned int min()
static unsigned int defaultStep()
bool mustAlreadyExist_
Whether or not the file specified in the parameter should already exist.
bool allowDouble() const
Allow an double value?
static unsigned short defaultPrecision()
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.
static short unsigned int min()
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
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.
unsigned short precision_
The number of decimal places with which the nubmer will be displayed in a UI. This value is meaningle...
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.
ValidStringsList validStringValues_
void setValidValues(ArrayView< const std::string > const &strings, ArrayView< const std::string > const *stringsDocs=NULL)
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)
static long unsigned int max()
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.
T step_
The increment to use when increaseing or decreaseing the value the validator is validating.
Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different ...
static unsigned int max()
T getStep() const
Gets the step being used for the validator.
std::string defaultParameterName_
Defines basic traits returning the name of a type in a portable and readable way. ...
static short unsigned int max()
bool containsMin
Whether or not a minimum value has been specified for this validator.
#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()
T maxVal
The maximum value accepted by the validator.
RCP< const ValidatorType > prototypeValidator_
The prototype validator to be applied to each entry in the Array.
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
static unsigned int min()
ArrayNumberValidator(RCP< const EnhancedNumberValidator< T > > prototypeValidator)