go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
itk::ParameterFileParser Class Reference

#include <itkParameterFileParser.h>

Detailed Description

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 "\n 5) Values that are numbers should be unquoted\n For example: \n (ParameterName1 "string1" "string2")\n (ParameterName2 3 5.8)\n (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:

The resulting map can be accessed via:
parser->GetParameterMap();

See also
itk::ParameterMapInterface

Definition at line 78 of file itkParameterFileParser.h.

+ Inheritance diagram for itk::ParameterFileParser:

Public Types

typedef SmartPointer< const SelfConstPointer
 
typedef std::map< std::string, ParameterValuesTypeParameterMapType
 
typedef std::vector< std::string > ParameterValuesType
 
typedef SmartPointer< SelfPointer
 
typedef ParameterFileParser Self
 
typedef Object Superclass
 

Public Member Functions

virtual const char * GetClassName () const
 
virtual const char * GetParameterFileName () const
 
virtual const ParameterMapTypeGetParameterMap (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 ()
 
 ~ParameterFileParser () override
 

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::string m_ParameterFileName
 
ParameterMapType m_ParameterMap
 

Member Typedef Documentation

◆ ConstPointer

typedef SmartPointer< const Self > itk::ParameterFileParser::ConstPointer

Definition at line 86 of file itkParameterFileParser.h.

◆ ParameterMapType

Definition at line 98 of file itkParameterFileParser.h.

◆ ParameterValuesType

typedef std::vector< std::string > itk::ParameterFileParser::ParameterValuesType

Typedefs.

Definition at line 95 of file itkParameterFileParser.h.

◆ Pointer

typedef SmartPointer< Self > itk::ParameterFileParser::Pointer

Definition at line 85 of file itkParameterFileParser.h.

◆ Self

Standard ITK typedefs.

Definition at line 83 of file itkParameterFileParser.h.

◆ Superclass

Definition at line 84 of file itkParameterFileParser.h.

Constructor & Destructor Documentation

◆ ParameterFileParser() [1/2]

itk::ParameterFileParser::ParameterFileParser ( )
protected

◆ ~ParameterFileParser()

itk::ParameterFileParser::~ParameterFileParser ( )
overrideprotected

◆ ParameterFileParser() [2/2]

itk::ParameterFileParser::ParameterFileParser ( const Self )
private

Member Function Documentation

◆ BasicFileChecking()

void itk::ParameterFileParser::BasicFileChecking ( void  ) const
private

Performs the following checks:

  • Is a filename is given
  • Does the file exist
  • Is a text file, i.e. does it end with .txt If one of these conditions fail, an exception is thrown.

◆ CheckLine()

bool itk::ParameterFileParser::CheckLine ( const std::string &  line,
std::string &  lineOut 
) const
private

Checks a line.

  • Returns true if it is a valid line: containing a parameter.
  • Returns false if it is a valid line: empty or comment.
  • Throws an exception if it is not a valid line.

◆ GetClassName()

virtual const char * itk::ParameterFileParser::GetClassName ( ) const
virtual

Run-time type information (and related methods).

◆ GetParameterFileName()

virtual const char * itk::ParameterFileParser::GetParameterFileName ( ) const
virtual

◆ GetParameterFromLine()

void itk::ParameterFileParser::GetParameterFromLine ( const std::string &  fullLine,
const std::string &  line 
)
private

Fills m_ParameterMap with valid entries.

◆ GetParameterMap()

virtual const ParameterMapType & itk::ParameterFileParser::GetParameterMap ( void  ) const
virtual

Return the parameter map.

◆ New()

static Pointer itk::ParameterFileParser::New ( )
static

Method for creation through the object factory.

◆ operator=()

void itk::ParameterFileParser::operator= ( const Self )
private

◆ ReadParameterFile()

void itk::ParameterFileParser::ReadParameterFile ( void  )

Read the parameters in the parameter map.

◆ ReturnParameterFileAsString()

std::string itk::ParameterFileParser::ReturnParameterFileAsString ( void  )

Read the parameter file and return the content as a string. Useful for printing the content.

◆ SetParameterFileName()

virtual void itk::ParameterFileParser::SetParameterFileName ( const char *  _arg)
virtual

Set the name of the file containing the parameters.

◆ SplitLine()

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.

◆ ThrowException()

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.

Field Documentation

◆ m_ParameterFileName

std::string itk::ParameterFileParser::m_ParameterFileName
private

Member variables.

Definition at line 154 of file itkParameterFileParser.h.

◆ m_ParameterMap

ParameterMapType itk::ParameterFileParser::m_ParameterMap
private

Definition at line 155 of file itkParameterFileParser.h.



Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo