forked from aalto-speech/AaltoASR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModuleConfig.hh
49 lines (37 loc) · 1.58 KB
/
ModuleConfig.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef MODULECONFIG_HH
#define MODULECONFIG_HH
#include <map>
#include <vector>
#include <string>
class ModuleConfig {
public:
bool exists(const std::string &name) const;
void set(const std::string &name, int value);
void set(const std::string &name, float value);
void set(const std::string &name, const std::string &str);
void set(const std::string &name, const std::vector<int> &vec);
void set(const std::string &name, const std::vector<float> &vec);
void set(const std::string &name, const std::vector<std::string> &vec);
// Leaves 'value' unchanged if 'name' not defined
bool get(const std::string &name, int &value) const;
bool get(const std::string &name, float &value) const;
bool get(const std::string &name, std::string &str) const;
bool get(const std::string &name, std::vector<int> &vec) const;
bool get(const std::string &name, std::vector<float> &vec) const;
bool get(const std::string &name, std::vector<std::string> &vec) const;
/** Writes the configuration in file. */
void write(FILE *file, int indent = 0) const;
/** Reads configuration from file. */
void read(FILE *file);
/** Return the number of lines read on last call of \ref read() */
int num_lines_read() const { return m_num_lines_read; }
private:
/** Insert the (name, value) pair in the map and vector structures. */
void insert(const std::string &name, const std::string &value);
typedef std::map<std::string, int> ValueMap;
ValueMap m_value_map;
std::vector<std::string> m_values;
std::vector<std::string> m_names;
int m_num_lines_read;
};
#endif /* MODULECONFIG_HH */