JDFTx  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParamList Class Reference

Wrapper to std::istringstream that eases parsing of input file command lines. More...

#include <ParamList.h>

Public Member Functions

 ParamList (string params)
 Construct given the string with all the parameters.
 
void rewind ()
 Rewind to beginning of stream (useful for commands with multiple alternate syntaxes)
 
template<typename T >
void get (T &t, T tDefault, string paramName, bool required=false)
 Retrieve a parameter from stream or, if stream ends, set it to a default value. Note that t is set to tDefault if any error occurs. More...
 
template<typename T >
void get (T &t, T tDefault, const EnumStringMap< T > &tMap, string paramName, bool required=false)
 Retreive an enum parameter from stream with default handling. More...
 
string getRemainder ()
 Get the section of the input string not yet parsed.
 

Detailed Description

Wrapper to std::istringstream that eases parsing of input file command lines.

Member Function Documentation

template<typename T >
void ParamList::get ( T &  t,
tDefault,
string  paramName,
bool  required = false 
)
inline

Retrieve a parameter from stream or, if stream ends, set it to a default value. Note that t is set to tDefault if any error occurs.

Template Parameters
Tdata type of parameter, which could be anything that std::istream supports
Parameters
tDestination for the retrieved parameter
tDefaultDefault vaue of the parameter to set if stream ends while parsing
paramNameName of the parameter to use in error messages
requiredIf true, report an error if the stream ends instead of using the default.
template<typename T >
void ParamList::get ( T &  t,
tDefault,
const EnumStringMap< T > &  tMap,
string  paramName,
bool  required = false 
)
inline

Retreive an enum parameter from stream with default handling.

Template Parameters
TType of the enum parameter
Parameters
tDestination for the retrieved parameter
tDefaultDefault vaue of the parameter to set if stream ends while parsing
tMapMap between the enum values and corresponding string names
paramNameName of the parameter to use in error messages
requiredIf true, report an error if the stream ends instead of using the default.

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