Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Private Member Functions | Static Private Member Functions | Private Attributes | 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:
Inheritance graph
[legend]

Classes

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

Private Member Functions

void finishInitialization ()
 
void throwTypeError (ParameterEntry const &entry, std::string const &paramName, std::string const &sublistName) const
 

Static Private Member Functions

static const std::string & getIntEnumString ()
 
static const std::string & getLongLongEnumString ()
 
static const std::string & getDoubleEnumString ()
 
static const std::string & getStringEnumString ()
 

Private Attributes

EPreferredType preferredType_
 
std::string acceptedTypesString_
 
const AcceptedTypes acceptedTypes_
 

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...
 

Public types

enum  EPreferredType { PREFER_INT, PREFER_LONG_LONG, PREFER_DOUBLE, PREFER_STRING }
 Determines what type is the preferred type. More...
 

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...
 

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...
 

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
 

Additional Inherited Members

- Public Types inherited from Teuchos::ParameterEntryValidator
typedef unsigned int ValidatorID
 
typedef RCP< const Array
< std::string > > 
ValidStringsList
 
- Public Member Functions inherited from Teuchos::ParameterEntryValidator
 ParameterEntryValidator ()
 Default Constructor. More...
 
double convertStringToDouble (std::string str) const
 
int convertStringToInt (std::string str) const
 
int convertStringToLongLong (std::string str) const
 
- 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...
 
- 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 709 of file Teuchos_StandardParameterEntryValidators.hpp.

Member Enumeration Documentation

Determines what type is the preferred type.

Enumerator
PREFER_INT 
PREFER_LONG_LONG 
PREFER_DOUBLE 
PREFER_STRING 

Definition at line 718 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 262 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 269 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 281 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 299 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 317 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 336 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 355 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 365 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 375 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 386 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isIntAllowed ( ) const

Lookup whether or not ints are allowed.

Definition at line 396 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isLongLongAllowed ( ) const

Lookup whether or not long longs are allowed.

Definition at line 401 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isDoubleAllowed ( ) const

Lookup whether or not doubles are allowed.

Definition at line 406 of file Teuchos_StandardParameterEntryValidators.cpp.

bool Teuchos::AnyNumberParameterEntryValidator::isStringAllowed ( ) const

Lookup whether or not strings are allowed.

Definition at line 411 of file Teuchos_StandardParameterEntryValidators.cpp.

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

Lookup the preferred type.

Definition at line 418 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 875 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 893 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
static const std::string& Teuchos::AnyNumberParameterEntryValidator::getIntEnumString ( )
inlinestaticprivate
static const std::string& Teuchos::AnyNumberParameterEntryValidator::getLongLongEnumString ( )
inlinestaticprivate
static const std::string& Teuchos::AnyNumberParameterEntryValidator::getDoubleEnumString ( )
inlinestaticprivate
static const std::string& Teuchos::AnyNumberParameterEntryValidator::getStringEnumString ( )
inlinestaticprivate
void Teuchos::AnyNumberParameterEntryValidator::finishInitialization ( )
private
void Teuchos::AnyNumberParameterEntryValidator::throwTypeError ( ParameterEntry const &  entry,
std::string const &  paramName,
std::string const &  sublistName 
) const
private

Friends And Related Function Documentation

TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< AnyNumberParameterEntryValidator > anyNumberParameterEntryValidator ( )
related

Nonmember constructor AnyNumberParameterEntryValidator.

Nonmember constructor AnyNumberParameterEntryValidator.

Member Data Documentation

EPreferredType Teuchos::AnyNumberParameterEntryValidator::preferredType_
private
std::string Teuchos::AnyNumberParameterEntryValidator::acceptedTypesString_
private
const AcceptedTypes Teuchos::AnyNumberParameterEntryValidator::acceptedTypes_
private

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