![]() |
Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages |
#include <itkParameterFileParser.h>
Public Types | |
typedef SmartPointer< const Self > | ConstPointer |
typedef std::map< std::string, ParameterValuesType > | ParameterMapType |
typedef std::vector< std::string > | ParameterValuesType |
typedef SmartPointer< Self > | Pointer |
typedef ParameterFileParser | Self |
typedef Object | Superclass |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual const char * | GetParameterFileName () const |
virtual const ParameterMapType & | GetParameterMap (void) const |
void | ReadParameterFile (void) |
std::string | ReturnParameterFileAsString (void) |
virtual void | SetParameterFileName (const char *_arg) |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
ParameterFileParser () | |
virtual | ~ParameterFileParser () |
Private Member Functions | |
void | BasicFileChecking (void) const |
bool | CheckLine (const std::string &line, std::string &lineOut) const |
void | GetParameterFromLine (const std::string &fullLine, const std::string &line) |
void | operator= (const Self &) |
ParameterFileParser (const Self &) | |
void | SplitLine (const std::string &fullLine, const std::string &line, std::vector< std::string > &splittedLine) const |
void | ThrowException (const std::string &line, const std::string &hint) const |
Private Attributes | |
std::ifstream | m_ParameterFile |
std::string | m_ParameterFileName |
ParameterMapType | m_ParameterMap |
Implements functionality to read a parameter file.
A parameter file is a text file that contains parameters and their values. Parameters should be specified obeying certain rules.
1) A single parameter should be on a single line
2) A parameter should be specified between brackets: (...)
3) Parameters are specified by a single name, followed by one or more values, all separated by spaces
4) Values that are strings should be quoted using "
5) Values that are numbers should be unquoted
For example:
(ParameterName1 "string1" "string2")
(ParameterName2 3 5.8)
(ParameterName3 "true" "false" "true")
The parameter file is read, and parameter name-value combinations are stored in an std::map< std::string, std::vector<std:string> >, where the string is the parameter name, and the vector of strings are the values. Exceptions are raised in case:
Here is an example on how to use this class:
itk::ParameterFileParser::Pointer parser = itk::ParameterFileParser::New(); parser->SetParameterFileName( parameterFileName ); try { parser->Initialize(); } catch ( itk::ExceptionObject & e ) { ... }
The resulting map can be accessed via:
parser->GetParameterMap();
Definition at line 77 of file itkParameterFileParser.h.
typedef SmartPointer< const Self > itk::ParameterFileParser::ConstPointer |
Definition at line 85 of file itkParameterFileParser.h.
typedef std::map< std::string, ParameterValuesType > itk::ParameterFileParser::ParameterMapType |
Definition at line 97 of file itkParameterFileParser.h.
typedef std::vector< std::string > itk::ParameterFileParser::ParameterValuesType |
Typedefs.
Definition at line 91 of file itkParameterFileParser.h.
typedef SmartPointer< Self > itk::ParameterFileParser::Pointer |
Definition at line 84 of file itkParameterFileParser.h.
Standard ITK typedefs.
Definition at line 82 of file itkParameterFileParser.h.
typedef Object itk::ParameterFileParser::Superclass |
Definition at line 83 of file itkParameterFileParser.h.
itk::ParameterFileParser::ParameterFileParser | ( | ) | [protected] |
virtual itk::ParameterFileParser::~ParameterFileParser | ( | ) | [protected, virtual] |
itk::ParameterFileParser::ParameterFileParser | ( | const Self & | ) | [private] |
void itk::ParameterFileParser::BasicFileChecking | ( | void | ) | const [private] |
Performs the following checks:
bool itk::ParameterFileParser::CheckLine | ( | const std::string & | line, |
std::string & | lineOut | ||
) | const [private] |
Checks a line.
virtual const char* itk::ParameterFileParser::GetClassName | ( | ) | const [virtual] |
Run-time type information (and related methods).
virtual const char* itk::ParameterFileParser::GetParameterFileName | ( | ) | const [virtual] |
void itk::ParameterFileParser::GetParameterFromLine | ( | const std::string & | fullLine, |
const std::string & | line | ||
) | [private] |
Fills m_ParameterMap with valid entries.
virtual const ParameterMapType& itk::ParameterFileParser::GetParameterMap | ( | void | ) | const [virtual] |
Return the parameter map.
static Pointer itk::ParameterFileParser::New | ( | ) | [static] |
Method for creation through the object factory.
void itk::ParameterFileParser::operator= | ( | const Self & | ) | [private] |
void itk::ParameterFileParser::ReadParameterFile | ( | void | ) |
Read the parameters in the parameter map.
std::string itk::ParameterFileParser::ReturnParameterFileAsString | ( | void | ) |
Read the parameter file and return the content as a string. Useful for printing the content.
virtual void itk::ParameterFileParser::SetParameterFileName | ( | const char * | _arg | ) | [virtual] |
Set the name of the file containing the parameters.
void itk::ParameterFileParser::SplitLine | ( | const std::string & | fullLine, |
const std::string & | line, | ||
std::vector< std::string > & | splittedLine | ||
) | const [private] |
Splits a line in parameter name and values.
void itk::ParameterFileParser::ThrowException | ( | const std::string & | line, |
const std::string & | hint | ||
) | const [private] |
Uniform way to throw exceptions when the parameter file appears to be invalid.
std::ifstream itk::ParameterFileParser::m_ParameterFile [private] |
Definition at line 152 of file itkParameterFileParser.h.
std::string itk::ParameterFileParser::m_ParameterFileName [private] |
Member variables.
Definition at line 151 of file itkParameterFileParser.h.
Definition at line 153 of file itkParameterFileParser.h.
Generated on 24-05-2012 for elastix by ![]() |
![]() |