6 #include "StringParameters.h"
7 #include "marlin/Exceptions.h"
18 typedef std::map< std::string , std::shared_ptr<StringParameters> > StringParametersMap;
45 Parser(
const std::string& fileName ) ;
48 std::shared_ptr<StringParameters>
getParameters(
const std::string& sectionName )
const ;
52 throw ParseException(
"dynamic command line options only supported for xml steering files" ) ;
61 void write(
const std::string& fname)
const ;
72 mutable StringParametersMap _map{};
73 StringParameters* _current ;
75 std::string _fileName ;
92 std::vector< std::string >& _tokens ;
98 LCTokenizer( std::vector< std::string >& tokens,
char del,
size_t max=-1 ) : _tokens(tokens) , _del(del), _last(del), _max(max) {
102 void operator()(
const char& c) {
104 if( c != _del or _tokens.size() >= _max ) {
106 if( _last == _del and _tokens.size() < _max ) {
107 _tokens.push_back(
"") ;
109 _tokens.back() += c ;
119 std::vector<std::string> & result() {
std::shared_ptr< StringParameters > getParameters(const std::string §ionName) const
Return the StringParameters defined for this section of the steering file.
Definition: Parser.cc:113
ParseException used for parse errors, e.g.
Definition: Exceptions.h:16
Interface for a parser of a steering file to be used with marlin.
Definition: IParser.h:19
Simple parser class for Marlin.
Definition: Parser.h:36
void setCmdLineParameters(const CommandLineParametersMap &)
set command line parameters
Definition: Parser.h:51
Helper class for Parser.
Definition: Parser.h:90
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 '#'...
Definition: Parser.cc:132
void parse()
Parse the input file.
Definition: Parser.cc:16
void write(const std::string &fname) const
Write down the parsed file in a new file.
Definition: Parser.cc:163