Nemo  2.3.46
paramsparser.h
Go to the documentation of this file.
1 
30 #ifndef PARSER_H
31 #define PARSER_H
32 
33 #include <iostream>
34 #include <vector>
35 #include <string>
36 #include <map>
37 
38 using namespace std;
40 class ParamsParser {
41 
42 public:
43 
44  ParamsParser(const char* name) {_sname = name;}
45  virtual ~ParamsParser(){}
46 
47  void setName(const char* name) {_sname = name;}
48 
49  map< string, string > get_inputParams() {return _inputParams;}
50  map< string, vector< string > >& getParsedParameters(const char* stream_name);
51  map< string, vector< string > >& getParsedParameters( ) {return _parsedParams;}
52  map< string, string >& getParameters(const char* stream_name);
53  map< string, string >& getParameters( ) {return _inputParams;}
54 
57  virtual bool read(const char* stream) = 0;
60  void parse();
61  static void getBlockArgument (istream& IN, char& c, string& arg);
62  static void getArguments (string& arg_str, vector< string >& arg_vect);
63 
64 protected:
65 
66  void reset_inputParams() {_inputParams.clear();}
67  void add_inputParam (string& param, const string& arg) {_inputParams[param] = arg;}
68 
69 private:
71  const char* _sname;
73  map< string, string > _inputParams;
75  map< string, vector< string > > _parsedParams;
76 
77 };
78 
80 class StreamParser: public ParamsParser {
81 
82 public:
83  StreamParser(const char* stream) : ParamsParser(stream) {}
84  virtual ~StreamParser(){}
85 
86  virtual bool read (const char* stream);
87  static bool removeComment (istream& IN, int& l_count);
88  static bool removeSpaceAndComment (istream& IN, int& l_count, bool keepLast = false);
89  virtual bool readArguments (istream& IN, int& l_count, string& args);
90  static string readUntilCharacter (istream& IN, int& l_count, char& start_c, const char end_c);
91  static void eatLine (istream& IN, int& l_count);
92  void replaceCR (string& stream, const char rpl = '\n');
93 
94 
95 private:
96 
97 };
98 #endif
map< string, vector< string > > _parsedParams
The parsed set of simulation parameters after sequential parameters have been separated.
Definition: paramsparser.h:75
Read parameters from a text buffer.
Definition: paramsparser.h:80
virtual ~ParamsParser()
Definition: paramsparser.h:45
map< string, vector< string > > & getParsedParameters()
Definition: paramsparser.h:51
const char * _sname
Attached file of stream name.
Definition: paramsparser.h:71
map< string, string > _inputParams
The whole, unparsed set of input parameters.
Definition: paramsparser.h:73
virtual ~StreamParser()
Definition: paramsparser.h:84
Provides interface to read input parameters from various sources and parses them. ...
Definition: paramsparser.h:40
map< string, string > get_inputParams()
Definition: paramsparser.h:49
map< string, string > & getParameters()
Definition: paramsparser.h:53
void add_inputParam(string &param, const string &arg)
Definition: paramsparser.h:67
void reset_inputParams()
Definition: paramsparser.h:66
StreamParser(const char *stream)
Definition: paramsparser.h:83
void setName(const char *name)
Definition: paramsparser.h:47
ParamsParser(const char *name)
Definition: paramsparser.h:44

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR