Marlin  01.17.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
marlin::Parser Class Reference

Simple parser class for Marlin. More...

#include <Parser.h>

+ Inheritance diagram for marlin::Parser:

Public Member Functions

 Parser (const std::string &fileName)
 
virtual ~Parser ()
 
std::shared_ptr< StringParametersgetParameters (const std::string &sectionName) const
 Return the StringParameters defined for this section of the steering file. More...
 
void setCmdLineParameters (const CommandLineParametersMap &)
 set command line parameters More...
 
void parse ()
 Parse the input file. More...
 
void write (const std::string &fname) const
 Write down the parsed file in a new file. More...
 
- Public Member Functions inherited from marlin::IParser
virtual ~IParser ()
 

Protected Member Functions

int readNextValidLine (std::string &str, std::istream &stream)
 Helper method that reads the next line from a stream that is not empty or starts with a '#'. More...
 

Protected Attributes

StringParametersMap _map {}
 
StringParameters_current
 
std::string _fileName
 

Private Member Functions

 Parser ()=delete
 
 Parser (const marlin::Parser &)=delete
 
Parseroperator= (const marlin::Parser &)=delete
 

Detailed Description

Simple parser class for Marlin.

Creates Parameter objects for all sections in a steering file defined by enclosing
.begin SectionName
.end
Parameters are defined for every line that doesn't start with #. The first string is the name of the parameter (key) the rest of the line is interpreted as the list of values separated by whitespace. Values from multiple lines starting with the same name/key are appended to the corresponding list.

Author
F. Gaede, DESY
Version
Id:
Parser.h,v 1.3 2005-10-11 12:56:28 gaede Exp

Definition at line 36 of file Parser.h.

Constructor & Destructor Documentation

marlin::Parser::Parser ( const std::string fileName)

Definition at line 8 of file Parser.cc.

marlin::Parser::~Parser ( )
virtual

Definition at line 12 of file Parser.cc.

marlin::Parser::Parser ( )
privatedelete
marlin::Parser::Parser ( const marlin::Parser )
privatedelete

Member Function Documentation

std::shared_ptr< StringParameters > marlin::Parser::getParameters ( const std::string sectionName) const
virtual

Return the StringParameters defined for this section of the steering file.

Implements marlin::IParser.

Definition at line 113 of file Parser.cc.

References _map, std::map< K, T >::begin(), and std::map< K, T >::end().

Referenced by createProcessors().

Parser& marlin::Parser::operator= ( const marlin::Parser )
privatedelete
void marlin::Parser::parse ( )
virtual
int marlin::Parser::readNextValidLine ( std::string str,
std::istream stream 
)
protected

Helper method that reads the next line from a stream that is not empty or starts with a '#'.

Definition at line 132 of file Parser.cc.

References std::istream::eof(), and std::string::length().

Referenced by parse().

void marlin::Parser::setCmdLineParameters ( const CommandLineParametersMap )
inlinevirtual

set command line parameters

Implements marlin::IParser.

Definition at line 51 of file Parser.h.

void marlin::Parser::write ( const std::string fname) const
virtual

Write down the parsed file in a new file.

For this implementation, just copy paste the steering file

Implements marlin::IParser.

Definition at line 163 of file Parser.cc.

References _fileName, std::string::c_str(), and std::endl().

Member Data Documentation

StringParameters* marlin::Parser::_current
protected

Definition at line 73 of file Parser.h.

Referenced by parse().

std::string marlin::Parser::_fileName
protected

Definition at line 75 of file Parser.h.

Referenced by parse(), and write().

StringParametersMap marlin::Parser::_map {}
mutableprotected

Definition at line 72 of file Parser.h.

Referenced by getParameters(), and parse().


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