Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Related Functions | List of all members
Teuchos::AnyNumberParameterEntryValidator Class Reference

Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different formats and converts them to numbers in another format. More...

#include <Teuchos_StandardParameterEntryValidators.hpp>

Inheritance diagram for Teuchos::AnyNumberParameterEntryValidator:
Teuchos::ParameterEntryValidator Teuchos::Describable Teuchos::LabeledObject

Classes

class  AcceptedTypes
 Determines the types that are accepted. More...
 

Public Types

Public types
enum  EPreferredType
 Determines what type is the preferred type. More...
 
- Public Types inherited from Teuchos::ParameterEntryValidator
typedef unsigned int ValidatorID
 
typedef RCP< const Array
< std::string > > 
ValidStringsList
 

Public Member Functions

Constructors
 AnyNumberParameterEntryValidator ()
 Construct with a preferrded type of double and accept all types. More...
 
 AnyNumberParameterEntryValidator (EPreferredType const preferredType, AcceptedTypes const &acceptedTypes)
 Construct with allowed input and output types and the preferred type. More...
 
Overridden from ParameterEntryValidator
const std::string getXMLTypeName () const
 
void printDoc (std::string const &docString, std::ostream &out) const
 
ValidStringsList validStringValues () const
 
void validate (ParameterEntry const &entry, std::string const &paramName, std::string const &sublistName) const
 
void validateAndModify (std::string const &paramName, std::string const &sublistName, ParameterEntry *entry) const
 
- Public Member Functions inherited from Teuchos::ParameterEntryValidator
 ParameterEntryValidator ()
 Default Constructor. More...
 
- Public Member Functions inherited from Teuchos::Describable
virtual std::string description () const
 Return a simple one-line description of this object. More...
 
virtual void describe (FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 Print the object with some verbosity level to a FancyOStream. More...
 
void describe (std::ostream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 Version of describe() that takes an std::ostream instead of a FancyOStream. More...
 
virtual ~Describable ()
 Destructor (marked virtual for memory safety of derived classes). More...
 
- Public Member Functions inherited from Teuchos::LabeledObject
 LabeledObject ()
 Construct with an empty label. More...
 
virtual ~LabeledObject ()
 
virtual void setObjectLabel (const std::string &objectLabel)
 Set the object label (see LabeledObject). More...
 
virtual std::string getObjectLabel () const
 Get the object label (see LabeledObject). More...
 

Related Functions

(Note that these are not member functions.)

TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
RCP
< AnyNumberParameterEntryValidator
anyNumberParameterEntryValidator ()
 Nonmember constructor AnyNumberParameterEntryValidator. More...
 
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
RCP
< AnyNumberParameterEntryValidator
anyNumberParameterEntryValidator (AnyNumberParameterEntryValidator::EPreferredType const preferredType, AnyNumberParameterEntryValidator::AcceptedTypes const &acceptedTypes)
 Nonmember constructor AnyNumberParameterEntryValidator. More...
 

Local non-virtual validated lookup functions

int getInt (const ParameterEntry &entry, const std::string &paramName="", 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 formatted strings but some formats can be accepted, such as "1.1" becoming 1. More...
 
long long getLongLong (const ParameterEntry &entry, const std::string &paramName="", 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 badly formatted strings but some formats can be accepted, such as "1.1" becoming 1. More...
 
double getDouble (const ParameterEntry &entry, const std::string &paramName="", const std::string &sublistName="", const bool activeQuery=true) const
 Get a double value from a parameter entry. will call std::stod. More...
 
std::string getString (const ParameterEntry &entry, const std::string &paramName="", const std::string &sublistName="", const bool activeQuery=true) const
 Get a std::string value from a parameter entry. More...
 
int getInt (ParameterList &paramList, const std::string &paramName, const int defaultValue) const
 Lookup parameter from a parameter list and return as an int value. More...
 
long long getLongLong (ParameterList &paramList, const std::string &paramName, const long long defaultValue) const
 Lookup parameter from a parameter list and return as a long long value. More...
 
double getDouble (ParameterList &paramList, const std::string &paramName, const double defaultValue) const
 Lookup parameter from a parameter list and return as an double value. More...
 
std::string getString (ParameterList &paramList, const std::string &paramName, const std::string &defaultValue) const
 Lookup parameter from a parameter list and return as an std::string value. More...
 
bool isIntAllowed () const
 Lookup whether or not ints are allowed. More...
 
bool isLongLongAllowed () const
 Lookup whether or not long longs are allowed. More...
 
bool isDoubleAllowed () const
 Lookup whether or not doubles are allowed. More...
 
bool isStringAllowed () const
 Lookup whether or not strings are allowed. More...
 
EPreferredType getPreferredType () const
 Lookup the preferred type. More...
 
static const std::string & getPrefferedTypeString (EPreferredType enumValue)
 Gets the string representation of a given preferred type enum. More...
 
static EPreferredType getPrefferedTypeStringEnum (const std::string &enumString)
 Gets the preferred type enum associated with a give string. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Teuchos::Describable
static const EVerbosityLevel verbLevel_default = VERB_DEFAULT
 Default value for the verbLevel argument of describe(). More...
 

Detailed Description

Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different formats and converts them to numbers in another format.

Objects of this type are meant to be used as both abstract objects passed to Teuchos::ParameterList objects to be used to validate parameter types and values, and to be used by the code that reads parameter values. Having a single definition for the types of valids input and outputs for a parameter value makes it easier to write error-free validated code.

Please see AnyNumberValidatorXMLConverter for documenation regarding the XML representation of this validator.

Definition at line 701 of file Teuchos_StandardParameterEntryValidators.hpp.

Member Enumeration Documentation

Determines what type is the preferred type.

Definition at line 710 of file Teuchos_StandardParameterEntryValidators.hpp.

Constructor & Destructor Documentation

Teuchos::AnyNumberParameterEntryValidator::AnyNumberParameterEntryValidator ( )

Construct with a preferrded type of double and accept all types.

Definition at line 230 of file Teuchos_StandardParameterEntryValidators.cpp.

Teuchos::AnyNumberParameterEntryValidator::AnyNumberParameterEntryValidator ( EPreferredType const  preferredType,
AcceptedTypes const &  acceptedTypes 
)

Construct with allowed input and output types and the preferred type.

Parameters
preferredType[in] Determines the preferred type. This enum value is used to set the default value in the override validateAndModify().
acceptedType[in] Determines the types that are allowed in the parameter list.

Definition at line 237 of file Teuchos_StandardParameterEntryValidators.cpp.

Member Function Documentation

int Teuchos::AnyNumberParameterEntryValidator::getInt ( const ParameterEntry entry,
const std::string &  paramName = "",
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 formatted strings but some formats can be accepted, such as "1.1" becoming 1.

Definition at line 249 of file Teuchos_StandardParameterEntryValidators.cpp.

long long Teuchos::AnyNumberParameterEntryValidator::getLongLong ( const ParameterEntry entry,
const std::string &  paramName = "",
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 badly formatted strings but some formats can be accepted, such as "1.1" becoming 1.

Definition at line 267 of file Teuchos_StandardParameterEntryValidators.cpp.

double Teuchos::AnyNumberParameterEntryValidator::getDouble ( const ParameterEntry entry,
const std::string &  paramName = "",
const std::string &  sublistName = "",
const bool  activeQuery = true 
) const

Get a double value from a parameter entry. will call std::stod.

Definition at line 285 of file Teuchos_StandardParameterEntryValidators.cpp.

std::string Teuchos::AnyNumberParameterEntryValidator::getString ( const ParameterEntry entry,
const std::string &  paramName = "",
const std::string &  sublistName = "",
const bool  activeQuery = true 
) const

Get a std::string value from a parameter entry.

Definition at line 304 of file Teuchos_StandardParameterEntryValidators.cpp.

int Teuchos::AnyNumberParameterEntryValidator::getInt ( ParameterList paramList,
const std::string &  paramName,
const int  defaultValue 
) const

Lookup parameter from a parameter list and return as an int value.

Definition at line 323 of file Teuchos_StandardParameterEntryValidators.cpp.

long long Teuchos::AnyNumberParameterEntryValidator::getLongLong ( ParameterList paramList,
const std::string &  paramName,
const long long  defaultValue 
) const

Lookup parameter from a parameter list and return as a long long value.

Definition at line 333 of file Teuchos_StandardParameterEntryValidators.cpp.

double Teuchos::AnyNumberParameterEntryValidator::getDouble ( ParameterList paramList,
const std::string &  paramName,
const double  defaultValue 
) const

Lookup parameter from a parameter list and return as an double value.

Definition at line 343 of file Teuchos_StandardParameterEntryValidators.cpp.

std::string Teuchos::AnyNumberParameterEntryValidator::getString ( ParameterList paramList,
const std::string &  paramName,
const std::string &  defaultValue 
) const

Lookup parameter from a parameter list and return as an std::string value.

Definition at line 354 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isIntAllowed ( ) const

Lookup whether or not ints are allowed.

Definition at line 364 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isLongLongAllowed ( ) const

Lookup whether or not long longs are allowed.

Definition at line 369 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isDoubleAllowed ( ) const

Lookup whether or not doubles are allowed.

Definition at line 374 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isStringAllowed ( ) const

Lookup whether or not strings are allowed.

Definition at line 379 of file Teuchos_StandardParameterEntryValidators.cpp.

AnyNumberParameterEntryValidator::EPreferredType Teuchos::AnyNumberParameterEntryValidator::getPreferredType ( ) const

Lookup the preferred type.

Definition at line 386 of file Teuchos_StandardParameterEntryValidators.cpp.

static const std::string& Teuchos::AnyNumberParameterEntryValidator::getPrefferedTypeString ( EPreferredType  enumValue)
inlinestatic

Gets the string representation of a given preferred type enum.

Definition at line 867 of file Teuchos_StandardParameterEntryValidators.hpp.

static EPreferredType Teuchos::AnyNumberParameterEntryValidator::getPrefferedTypeStringEnum ( const std::string &  enumString)
inlinestatic

Gets the preferred type enum associated with a give string.

Definition at line 885 of file Teuchos_StandardParameterEntryValidators.hpp.

const std::string Teuchos::AnyNumberParameterEntryValidator::getXMLTypeName ( ) const
virtual
void Teuchos::AnyNumberParameterEntryValidator::printDoc ( std::string const &  docString,
std::ostream &  out 
) const
virtual
ParameterEntryValidator::ValidStringsList Teuchos::AnyNumberParameterEntryValidator::validStringValues ( ) const
virtual
void Teuchos::AnyNumberParameterEntryValidator::validate ( ParameterEntry const &  entry,
std::string const &  paramName,
std::string const &  sublistName 
) const
virtual
void Teuchos::AnyNumberParameterEntryValidator::validateAndModify ( std::string const &  paramName,
std::string const &  sublistName,
ParameterEntry entry 
) const
virtual

Friends And Related Function Documentation

TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< AnyNumberParameterEntryValidator > anyNumberParameterEntryValidator ( )
related

Nonmember constructor AnyNumberParameterEntryValidator.

TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< AnyNumberParameterEntryValidator > anyNumberParameterEntryValidator ( AnyNumberParameterEntryValidator::EPreferredType const  preferredType,
AnyNumberParameterEntryValidator::AcceptedTypes const &  acceptedTypes 
)
related

Nonmember constructor AnyNumberParameterEntryValidator.


The documentation for this class was generated from the following files: