forked from MaybeShewill-CV/lanenet-lane-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_parser.h
64 lines (43 loc) · 1.63 KB
/
config_parser.h
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
59
60
61
62
63
64
/************************************************
* Author: MaybeShewill-CV
* File: configParser.h
* Date: 2019/10/10 上午10:39
************************************************/
#ifndef MNN_CONFIGPARSER_H
#define MNN_CONFIGPARSER_H
// Config parser
#include <exception>
#include <stdio.h>
#include <string>
#include <map>
const extern int __CONFIG_BUFFER_SIZE;
namespace beec {
namespace config_parse_utils {
class ConfigParser {
using config_values = std::map<std::string, std::string>;
public:
explicit ConfigParser(const std::string& filename);
~ConfigParser() = default;
config_values get_section(const std::string& section_name) const;
config_values operator[](const std::string& section_name) const;
void dump(FILE* log_file);
private:
std::map<std::string, std::map<std::string, std::string> > _m_sections;
std::string read_header(const std::string& line);
void read_configuration(const std::string& line, const std::string& header);
// trim from start (in place)
void ltrim(std::string &s);
// trim from end (in place)
void rtrim(std::string &s);
// trim from both ends (in place)
void trim(std::string &s);
// trim from start (copying)
std::string ltrim_copy(std::string s);
// trim from end (copying)
std::string rtrim_copy(std::string s);
// trim from both ends (copying)
std::string trim_copy(std::string s);
};
}
}
#endif //MNN_CONFIGPARSER_H