Simpact Cyan
Population based event driven simulation using mNRM
configreader.h
Go to the documentation of this file.
1 #ifndef CONFIGREADER_H
2 
3 #define CONFIGREADER_H
4 
9 #include "errut/errorbase.h"
10 #include <string>
11 #include <vector>
12 #include <map>
13 
34 {
35 public:
36  ConfigReader();
37  ~ConfigReader();
38 
40  bool read(const std::string &fileName);
41 
43  void getKeys(std::vector<std::string> &keys) const;
44 
47  bool getKeyValue(const std::string &key, std::string &value) const;
48 
50  void printAll() const;
51 
53  void clear();
54 private:
55  std::string substituteVariables(const std::string &s);
56 
57  std::map<std::string, std::string> m_keyValues;
58  std::map<std::string, std::string> m_variables;
59 };
60 
61 #endif // CONFIGREADER_H
62 
bool getKeyValue(const std::string &key, std::string &value) const
For the key specified by the key parameter, the corresponding value will be stored in value...
Definition: configreader.cpp:91
Base class which allows an error message to be set.
Definition: errorbase.h:49
bool read(const std::string &fileName)
Reads the config file specified by fileName.
Definition: configreader.cpp:18
void printAll() const
Prints all key/value pairs to the standard output.
Definition: configreader.cpp:107
A helper class to read config files.
Definition: configreader.h:33
void getKeys(std::vector< std::string > &keys) const
Stores all keys found in the config file in keys.
Definition: configreader.cpp:123
void clear()
Clears the stored key/value pairs.
Definition: configreader.cpp:118