Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Private Types | Private Member Functions | Private Attributes | Related Functions
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]

List of all members.

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

Constructors

 StringToIntegralParameterEntryValidator (ArrayView< const std::string > const &strings, std::string const &defaultParameterName)
 Construct with a mapping from strings to ordinals 0 to n-1.
 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.
 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.

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

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
 

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 documenation 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 2023 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 2043 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 2071 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 2111 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 2133 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 recored as an active query which will turn the isUsed bool to true.

Definition at line 2155 of file Teuchos_StandardParameterEntryValidators.hpp.

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

Lookup a parameter from a parameter list, perform a mapping from a std::string value embedded in the ParameterEntry object and return its associated integral value.

Definition at line 2169 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 2182 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 2195 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 2202 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 2209 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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines