-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigReader.hpp
More file actions
58 lines (53 loc) · 1.67 KB
/
ConfigReader.hpp
File metadata and controls
58 lines (53 loc) · 1.67 KB
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
50
51
52
53
54
55
56
57
58
#ifndef CONFIGREADER_H
#define CONFIGREADER_H
#include<string>
#include<unordered_map>
#include<vector>
#include<tuple>
#include<fstream>
class ConfigReader
{
public:
ConfigReader(const std::string& file_location);
enum CaseType {
DontCare,
Sensitive,
Lower,
Upper
};
ConfigReader(const std::string& file_location, CaseType const& _m_case);
bool open(const std::string& file_location);
void elaborate();
template <typename T>
std::vector<T> get(const std::string& name);
template <typename T>
std::vector<T> get(char* name);
template <typename T>
void append(char* name, T const& t);
template <typename T>
void append(std::string const& name, T const& t);
template <typename T>
void overwrite(char* name, T const& t);
template <typename T>
void overwrite(std::string const& name, T const& t);
template <typename T>
void overwrite(char* name, std::vector<T> const& t);
template <typename T>
void overwrite(std::string const& name, std::vector<T> const& t);
bool delete_entry(std::string const& name);
bool save();
bool close();
void reload();
void print(std::ostream& os);
CaseType const m_case = CaseType::DontCare;
private:
std::vector<std::string> read_lines; //the lines read from file
std::unordered_map<std::string, std::size_t> name_map; //given a variable name, returns the number of the line containing such variable name in line_vector
std::vector<std::vector<std::string> > line_vector; //contains the lines in order of appearance, unless the variable_name has already been seen, then it appends
std::vector<bool> line_has_variable;
std::ifstream file_data;
std::string file_path;
bool is_open = false;
bool is_loaded = false;
};
#endif // CONFIGREADER_H