47 const EVerbosityLevel verbLevel
65 true, std::invalid_argument,
"Teuchos::getVerbosityLevelParameterValue"
66 "Name(const Teuchos::EVerbosityLevel): Input argument " << verbLevel <<
67 " has an invalid value. Valid values are VERB_DEFAULT=" << VERB_DEFAULT
68 <<
", VERB_NONE=" << VERB_NONE <<
", VERB_LOW=" << VERB_LOW <<
", "
69 "VERB_MEDIUM=" << VERB_MEDIUM <<
", VERB_HIGH=" << VERB_HIGH <<
", AND "
70 "VERB_EXTREME=" << VERB_EXTREME <<
".");
89 std::string
const& defaultParameterName
93 new StringToIntegralParameterEntryValidator<EVerbosityLevel>(
95 getVerbosityLevelParameterValueName(VERB_DEFAULT),
96 getVerbosityLevelParameterValueName(VERB_NONE),
97 getVerbosityLevelParameterValueName(VERB_LOW),
98 getVerbosityLevelParameterValueName(VERB_MEDIUM),
99 getVerbosityLevelParameterValueName(VERB_HIGH),
100 getVerbosityLevelParameterValueName(VERB_EXTREME)
103 "Use level set in code",
105 "Produce minimal output",
106 "Produce a little more output",
107 "Produce a higher level of output",
108 "Produce the highest level of output"
110 tuple<EVerbosityLevel>(
150 if(
anyValue.type() ==
typeid(
bool) )
152 if(
anyValue.type() ==
typeid(std::string) ) {
156 if(
str ==
"false" ) {
159 else if(
str ==
"true" ) {
182 return "boolValidator";
186 std::string
const & docString,
229 std::ostringstream
oss;
246 ,
"Error, the parameter {paramName=\""<<
paramName<<
"\""
249 <<
"\nhas the wrong type."
263 : preferredType_(PREFER_DOUBLE), acceptedTypes_(
AcceptedTypes())
429 return "anynumberValidator";
434 std::string
const & docString,
509 std::ostringstream
oss;
516 oss <<
"\"long long\"";
542 ,
"Error, the parameter {paramName=\""<<
paramName<<
"\""
545 <<
"\nhas the wrong type."
554 return anyNumberParameterEntryValidator(
604 "\" sublist is has an error." << std::endl << std::endl <<
605 "Error: The value that you entered was the wrong type." << std::endl <<
606 "Parameter: " <<
paramName << std::endl <<
607 "Type specified: " <<
entryName << std::endl <<
608 "Type accepted: " <<
typeid(std::string).name() <<
609 std::endl << std::endl);
616 "\" sublist is has an error." << std::endl << std::endl <<
617 "Error: The file must already exists. The value you entered does " <<
618 "not corresspond to an existing file name." << std::endl <<
619 "Parameter: " <<
paramName << std::endl <<
620 "File name specified: " <<
fileName << std::endl << std::endl);
627 return "FilenameValidator";
632 std::string
const &docString, std::ostream &out)
const
635 out <<
"# Validator Used: " << std::endl;
636 out <<
"# FileName Validator" << std::endl;
681 "\" sublist is has an error." << std::endl << std::endl <<
682 "Error: The value that you entered was the wrong type." <<
683 "Parameter: " <<
paramName << std::endl <<
684 "Type specified: " <<
entryName << std::endl <<
695 "\" sublist is has an error." << std::endl << std::endl <<
696 "Error: The value that was entered doesn't fall with in "
697 "the range set by the validator." <<
698 "Parameter: " <<
paramName << std::endl <<
708 return "StringValidator";
713 std::ostream &out)
const
716 out <<
"# Validator Used: " << std::endl;
717 out <<
"# String Validator" << std::endl;
719 out <<
"# Acceptable Values: " << *
validStrings_ << std::endl;
735Teuchos::boolParameterEntryValidator()
737 return rcp(
new BoolParameterEntryValidator());
741Teuchos::anyNumberParameterEntryValidator()
743 return rcp(
new AnyNumberParameterEntryValidator());
748Teuchos::anyNumberParameterEntryValidator(
749 AnyNumberParameterEntryValidator::EPreferredType
const preferredType,
750 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
754 new AnyNumberParameterEntryValidator(
755 preferredType, acceptedTypes
760void Teuchos::setIntParameter(
761 std::string
const& paramName,
762 int const value, std::string
const& docString,
763 ParameterList *paramList,
764 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
768 const RCP<const ParameterEntryValidator> paramEntryValidator =
769 anyNumberParameterEntryValidator(
770 AnyNumberParameterEntryValidator::PREFER_INT, acceptedTypes
772 paramList->set(paramName, value, docString, paramEntryValidator);
776void Teuchos::setLongLongParameter(
777 std::string
const& paramName,
778 long long const value, std::string
const& docString,
779 ParameterList *paramList,
780 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
784 const RCP<const ParameterEntryValidator> paramEntryValidator =
785 anyNumberParameterEntryValidator(
786 AnyNumberParameterEntryValidator::PREFER_LONG_LONG, acceptedTypes
788 paramList->set(paramName, value, docString, paramEntryValidator);
792void Teuchos::setDoubleParameter(
793 std::string
const& paramName,
794 double const& value, std::string
const& docString,
795 ParameterList *paramList,
796 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
800 const RCP<const ParameterEntryValidator> paramEntryValidator =
801 anyNumberParameterEntryValidator(
802 AnyNumberParameterEntryValidator::PREFER_DOUBLE, acceptedTypes
804 paramList->set(paramName, value, docString, paramEntryValidator);
808void Teuchos::setNumericStringParameter(
809 std::string
const& paramName,
810 std::string
const& value, std::string
const& docString,
811 ParameterList *paramList,
812 AnyNumberParameterEntryValidator::AcceptedTypes
const& acceptedTypes
816 const RCP<const ParameterEntryValidator> paramEntryValidator =
817 anyNumberParameterEntryValidator(
818 AnyNumberParameterEntryValidator::PREFER_STRING, acceptedTypes
820 paramList->set(paramName, value, docString, paramEntryValidator);
824int Teuchos::getIntParameter(
825 ParameterList
const& paramList,
826 std::string
const& paramName
829 const ParameterEntry &entry = paramList.getEntry(paramName);
830 RCP<const AnyNumberParameterEntryValidator>
831 anyNumValidator = rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
834 if ( !
is_null(anyNumValidator) )
835 return anyNumValidator->getInt(entry,paramName,paramList.name());
836 if (
typeid(
int) == entry.getAny().type() )
837 return any_cast<int>(entry.getAny());
839 const AnyNumberParameterEntryValidator myAnyNumValidator;
840 return myAnyNumValidator.getInt(entry,paramName,paramList.name());
844long long Teuchos::getLongLongParameter(
845 ParameterList
const& paramList,
846 std::string
const& paramName
849 const ParameterEntry &entry = paramList.getEntry(paramName);
850 RCP<const AnyNumberParameterEntryValidator>
851 anyNumValidator = rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
854 if ( !
is_null(anyNumValidator) )
855 return anyNumValidator->getLongLong(entry,paramName,paramList.name());
856 if (
typeid(
long long) == entry.getAny().type() )
857 return any_cast<long long>(entry.getAny());
859 const AnyNumberParameterEntryValidator myAnyNumValidator;
860 return myAnyNumValidator.getLongLong(entry,paramName,paramList.name());
864double Teuchos::getDoubleParameter(
865 ParameterList
const& paramList,
866 std::string
const& paramName
869 const ParameterEntry &entry = paramList.getEntry(paramName);
870 RCP<const AnyNumberParameterEntryValidator>
871 anyNumValidator = rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
874 if ( !
is_null(anyNumValidator) )
875 return anyNumValidator->getDouble(entry,paramName,paramList.name());
876 if (
typeid(
double) == entry.getAny().type() )
877 return any_cast<double>(entry.getAny());
879 const AnyNumberParameterEntryValidator myAnyNumValidator;
880 return myAnyNumValidator.getDouble(entry,paramName,paramList.name());
884std::string Teuchos::getNumericStringParameter(
885 ParameterList
const& paramList,
886 std::string
const& paramName
889 const ParameterEntry &entry = paramList.getEntry(paramName);
890 RCP<const AnyNumberParameterEntryValidator>
891 anyNumValidator = rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
894 if ( !
is_null(anyNumValidator) )
895 return anyNumValidator->getString(entry,paramName,paramList.name());
896 if (
typeid(std::string) == entry.getAny().type() )
897 return any_cast<std::string>(entry.getAny());
899 const AnyNumberParameterEntryValidator myAnyNumValidator;
900 return myAnyNumValidator.getString(entry,paramName,paramList.name());
Definition of Teuchos::as, for conversions between types.
Determines the types that are accepted.
const std::string getXMLTypeName() const
void throwTypeError(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
void finishInitialization()
const AcceptedTypes acceptedTypes_
void printDoc(std::string const &docString, std::ostream &out) const
double getDouble(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get a double value from a parameter entry. will call std::stod.
long long getLongLong(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get a long long value from a parameter entry. will call std::stoll Note that std::stoll throws on bad...
std::string getString(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get a std::string value from a parameter entry.
AnyNumberParameterEntryValidator()
Construct with a preferrded type of double and accept all types.
int getInt(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get an integer value from a parameter entry. will call std::stoi Note that std::stoi throws on badly ...
std::string acceptedTypesString_
ValidStringsList validStringValues() const
bool isLongLongAllowed() const
Lookup whether or not long longs are allowed.
void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
bool isStringAllowed() const
Lookup whether or not strings are allowed.
bool isDoubleAllowed() const
Lookup whether or not doubles are allowed.
EPreferredType
Determines what type is the preferred type.
EPreferredType getPreferredType() const
Lookup the preferred type.
EPreferredType preferredType_
bool isIntAllowed() const
Lookup whether or not ints are allowed.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
std::vector< T >::const_iterator const_iterator
The type of a const forward iterator.
void throwTypeError(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
void validateAndModify(std::string const ¶mName, std::string const &sublistName, ParameterEntry *entry) const
std::string acceptedTypesString_
const std::string getXMLTypeName() const
BoolParameterEntryValidator()
ValidStringsList validStringValues() const
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
bool getBool(const ParameterEntry &entry, const std::string ¶mName="", const std::string &sublistName="", const bool activeQuery=true) const
Get bool value from a parameter entry.
void finishInitialization()
void printDoc(std::string const &docString, std::ostream &out) const
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
Validate a file name entry.
bool mustAlreadyExist_
Whether or not the file specified in the parameter should already exist.
ValidStringsList validStringValues() const
const std::string getXMLTypeName() const
bool fileEmptyNameOK() const
Gets the variable describing whether or not this validator is OK with file name being empty (even if ...
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
bool setFileEmptyNameOK(bool isEmptyNameOK)
Sets whether or not the validator is OK with empty file name (even if fileMustExist() returns true)
bool fileMustExist() const
Gets the variable describing whether or not this validator wants the file that is specified to alread...
FileNameValidator(bool mustAlreadyExist=mustAlreadyExistDefault())
Constructs a FileNameValidator.
bool setFileMustExist(bool shouldFileExist)
Sets whether or not the validator requires the file to already exist.
void printDoc(std::string const &docString, std::ostream &out) const
Abstract interface for an object that can validate a ParameterEntry's value.
int convertStringToInt(std::string str) const
double convertStringToDouble(std::string str) const
int convertStringToLongLong(std::string str) const
This object is held as the "value" in the Teuchos::ParameterList std::map.
any & getAny(bool activeQry=true)
Direct access to the Teuchos::any data value underlying this object. The bool argument activeQry (def...
void setValue(T value, bool isDefault=false, const std::string &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method that uses the input value type to determine the type of parameter.
A list of parameters of arbitrary type.
Smart reference counting pointer class for automatic garbage collection.
Concrete serial communicator subclass.
static std::ostream & printLines(std::ostream &os, const std::string &linePrefix, const std::string &lines)
Print lines with prefix first.
A simple validator that only allows certain string values to be choosen or simply enforces that a par...
ValidStringsList validStrings_
An array containing a list of all the valid string values.
const std::string getXMLTypeName() const
void validate(ParameterEntry const &entry, std::string const ¶mName, std::string const &sublistName) const
StringValidator()
Constructs a StringValidator.
void printDoc(std::string const &docString, std::ostream &out) const
ValidStringsList validStringValues() const
ValidStringsList setValidStrings(const Teuchos::Array< std::string > &validStrings)
Sets the Array of valid strings and returns what the current array of valid string now is.
Default traits class that just returns typeid(T).name().
static std::string toString(const double &x)
Write a double as a std::string.
Modified boost::any class, which is a container for a templated value.
std::string typeName() const
Return the name of the type.
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool is_null(const boost::shared_ptr< T > &p)
Returns true if p.get()==NULL.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
@ VERB_MEDIUM
Generate more output.
@ VERB_HIGH
Generate a high level of output.
@ VERB_EXTREME
Generate the most output possible.
@ VERB_NONE
Generate no output.
@ VERB_DEFAULT
Generate output as defined by the object.
@ VERB_LOW
Generate only a minimal amount of output.