Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
Private Types | Private Member Functions | Private Attributes | Related Functions | List of all members
Teuchos::StringToIntegralParameterEntryValidator< IntegralType > Class Template Reference

Standard implementation of a ParameterEntryValidator that maps from a list of strings to some integral type value. More...

#include <Teuchos_StandardParameterEntryValidators.hpp>

Inheritance diagram for Teuchos::StringToIntegralParameterEntryValidator< IntegralType >:
Inheritance graph
[legend]

Private Types

typedef std::map< std::string, IntegralType > map_t
 

Private Member Functions

void setValidValues (ArrayView< const std::string > const &strings, ArrayView< const std::string > const *stringsDocs=NULL)
 
 StringToIntegralParameterEntryValidator ()
 

Private Attributes

std::string defaultParameterName_
 
std::string validValues_
 
ValidStringsList validStringValues_
 
ValidStringsList validStringValuesDocs_
 
map_t map_
 

Related Functions

(Note that these are not member functions.)

template<class IntegralType >
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator (ArrayView< const std::string > const &strings, std::string const &defaultParameterName)
 Nonmember constructor (see implementation). More...
 
template<class IntegralType >
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator (ArrayView< const std::string > const &strings, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName)
 Nonmember constructor (see implementation). More...
 
template<class IntegralType >
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator (ArrayView< const std::string > const &strings, ArrayView< const std::string > const &stringsDocs, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName)
 Nonmember constructor (see implementation). More...
 

Constructors

 StringToIntegralParameterEntryValidator (ArrayView< const std::string > const &strings, std::string const &defaultParameterName)
 Construct with a mapping from strings to ordinals 0 to n-1. More...
 
 StringToIntegralParameterEntryValidator (ArrayView< const std::string > const &strings, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName)
 Construct with a mapping from strings to aribitrary typed integral values. More...
 
 StringToIntegralParameterEntryValidator (ArrayView< const std::string > const &strings, ArrayView< const std::string > const &stringsDocs, ArrayView< const IntegralType > const &integralValues, std::string const &defaultParameterName)
 Construct with a mapping from strings (with documentation) to aribitrary typed integral values. More...
 

Local non-virtual validated lookup functions

IntegralType getIntegralValue (const std::string &str, const std::string &paramName="", const std::string &sublistName="") const
 Perform a mapping from a std::string value to its integral value. More...
 
IntegralType getIntegralValue (const ParameterEntry &entry, const std::string &paramName="", const std::string &sublistName="", const bool activeQuery=true) const
 Perform a mapping from a std::string value embedded in a ParameterEntry object and return its associated integral value. More...
 
std::string getStringValue (const ParameterEntry &entry, const std::string &paramName="", const std::string &sublistName="", const bool activeQuery=true) const
 Get and validate a std::string value embedded in a ParameterEntry object. More...
 
IntegralType getIntegralValue (ParameterList &paramList, const std::string &paramName, const std::string &defaultValue) const
 Get the integer enum value for the given parameter. More...
 
std::string getStringValue (ParameterList &paramList, const std::string &paramName, const std::string &defaultValue) const
 Lookup a parameter from a parameter list, validate the std::string value, and return the std::string value. More...
 
ValidStringsList getStringDocs () const
 Get a pointer to the array containing all the documentation strings. More...
 
const std::string & getDefaultParameterName () const
 Get the name of the default parameter for the validator. More...
 
std::string validateString (const std::string &str, const std::string &paramName="", const std::string &sublistName="") const
 Validate the std::string and pass it on. 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
 

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...
 
virtual void validateAndModify (std::string const &paramName, std::string const &sublistName, ParameterEntry *entry) const
 Validate and perhaps modify a parameter entry's value. 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...
 
- 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

template<class IntegralType>
class Teuchos::StringToIntegralParameterEntryValidator< IntegralType >

Standard implementation of a ParameterEntryValidator that maps from a list of strings to some integral type value.

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 StringToIntegralValidatorXMLConverter for documentation regarding the XML representation of this validator.

Definition at line 71 of file Teuchos_StandardParameterEntryValidators.hpp.

Member Typedef Documentation

template<class IntegralType>
typedef std::map<std::string,IntegralType> Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::map_t
private

Constructor & Destructor Documentation

template<class IntegralType >
Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::StringToIntegralParameterEntryValidator ( ArrayView< const std::string > const &  strings,
std::string const &  defaultParameterName 
)

Construct with a mapping from strings to ordinals 0 to n-1.

Parameters
strings[in] Array of unique std::string names.
defaultParameterName[in] The default name of the parameter (used in error messages)

Definition at line 2005 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType>
Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::StringToIntegralParameterEntryValidator ( ArrayView< const std::string > const &  strings,
ArrayView< const IntegralType > const &  integralValues,
std::string const &  defaultParameterName 
)

Construct with a mapping from strings to aribitrary typed integral values.

Parameters
strings[in] Array of unique std::string names.
integralValues[in] Array that gives the integral values associated with strings[]
defaultParameterName[in] The default name of the parameter (used in error messages)

Preconditions:

  • strings.size() == integralValues.size()

Definition at line 2025 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType>
Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::StringToIntegralParameterEntryValidator ( ArrayView< const std::string > const &  strings,
ArrayView< const std::string > const &  stringsDocs,
ArrayView< const IntegralType > const &  integralValues,
std::string const &  defaultParameterName 
)

Construct with a mapping from strings (with documentation) to aribitrary typed integral values.

Parameters
strings[in] Array of unique std::string names.
stringsDocs[in] Array of documentation strings for each std::string value.
integralValues[in] Array that gives the integral values associated with strings[]
defaultParameterName[in] The default name of the parameter (used in error messages)

Preconditions:

  • strings.size() == stringDocs.size()
  • strings.size() == integralValues.size()

Definition at line 2053 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType>
Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::StringToIntegralParameterEntryValidator ( )
private

Member Function Documentation

template<class IntegralType >
IntegralType Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getIntegralValue ( const std::string &  str,
const std::string &  paramName = "",
const std::string &  sublistName = "" 
) const

Perform a mapping from a std::string value to its integral value.

Parameters
str[in] String that is being used to lookup the corresponding integral value.
paramName[in] Optional name that will be used to generate error messages.

If the std::string name str does not exist, the an std::exception will be thrown with a very descriptive error message.

Definition at line 2093 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
IntegralType Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getIntegralValue ( const ParameterEntry &  entry,
const std::string &  paramName = "",
const std::string &  sublistName = "",
const bool  activeQuery = true 
) const

Perform a mapping from a std::string value embedded in a ParameterEntry object and return its associated integral value.

Parameters
entry[in] The std::string entry.
paramName[in] Optional name that will be used to generate error messages.
sublistName[in] The name of the sublist.
activeQuery[in] If true, then this lookup will be recored as an active query which will turn the isUsed bool to true.

Definition at line 2115 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
std::string Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getStringValue ( const ParameterEntry &  entry,
const std::string &  paramName = "",
const std::string &  sublistName = "",
const bool  activeQuery = true 
) const

Get and validate a std::string value embedded in a ParameterEntry object.

Parameters
entry[in] The std::string entry.
paramName[in] Optional name that will be used to generate error messages.
sublistName[in] The name of the sublist.
activeQuery[in] If true, then this lookup will be recorded as an active query which will turn the isUsed bool to true.

Definition at line 2137 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
IntegralType Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getIntegralValue ( ParameterList &  paramList,
const std::string &  paramName,
const std::string &  defaultValue 
) const

Get the integer enum value for the given parameter.

Look up a parameter from a parameter list, map from the std::string value in the ParameterEntry object to its corresponding integer enum value, and return the integer enum value.

Definition at line 2151 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
std::string Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getStringValue ( ParameterList &  paramList,
const std::string &  paramName,
const std::string &  defaultValue 
) const

Lookup a parameter from a parameter list, validate the std::string value, and return the std::string value.

Definition at line 2164 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
ParameterEntryValidator::ValidStringsList Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getStringDocs ( ) const

Get a pointer to the array containing all the documentation strings.

Returns
A point to the array containing all the documentation strings.

Definition at line 2177 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
const std::string & Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getDefaultParameterName ( ) const

Get the name of the default parameter for the validator.

Returns
The name of the default parameter for the validator.

Definition at line 2184 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
std::string Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::validateString ( const std::string &  str,
const std::string &  paramName = "",
const std::string &  sublistName = "" 
) const

Validate the std::string and pass it on.

Parameters
str[in] String that is being used to lookup the corresponding integral value.
name[in] Optional name that will be used to generate error messages.

If the std::string name str does not exist, the an std::exception will be thrown with a very descriptive error message.

Definition at line 2191 of file Teuchos_StandardParameterEntryValidators.hpp.

template<class IntegralType >
const std::string Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::getXMLTypeName ( ) const
virtual
template<class IntegralType >
void Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::printDoc ( std::string const &  docString,
std::ostream &  out 
) const
virtual
template<class IntegralType >
ParameterEntryValidator::ValidStringsList Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::validStringValues ( ) const
virtual
template<class IntegralType >
void Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::validate ( ParameterEntry const &  entry,
std::string const &  paramName,
std::string const &  sublistName 
) const
virtual
template<class IntegralType >
void Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::setValidValues ( ArrayView< const std::string > const &  strings,
ArrayView< const std::string > const *  stringsDocs = NULL 
)
private

Friends And Related Function Documentation

template<class IntegralType >
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator ( ArrayView< const std::string > const &  strings,
std::string const &  defaultParameterName 
)
related

Nonmember constructor (see implementation).

template<class IntegralType >
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator ( ArrayView< const std::string > const &  strings,
ArrayView< const IntegralType > const &  integralValues,
std::string const &  defaultParameterName 
)
related

Nonmember constructor (see implementation).

template<class IntegralType >
RCP< StringToIntegralParameterEntryValidator< IntegralType > > stringToIntegralParameterEntryValidator ( ArrayView< const std::string > const &  strings,
ArrayView< const std::string > const &  stringsDocs,
ArrayView< const IntegralType > const &  integralValues,
std::string const &  defaultParameterName 
)
related

Nonmember constructor (see implementation).

Member Data Documentation

template<class IntegralType>
std::string Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::defaultParameterName_
private
template<class IntegralType>
std::string Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::validValues_
private
template<class IntegralType>
ValidStringsList Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::validStringValues_
private
template<class IntegralType>
ValidStringsList Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::validStringValuesDocs_
private
template<class IntegralType>
map_t Teuchos::StringToIntegralParameterEntryValidator< IntegralType >::map_
private

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