forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_parser.hpp
47 lines (36 loc) · 1.05 KB
/
config_parser.hpp
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
#ifndef RBX_CONFIG_PARSER
#define RBX_CONFIG_PARSER
#include <string>
#include <iostream>
#include <vector>
namespace rubinius {
class Configuration;
class ConfigParser {
public:
class Entry {
public:
std::string variable;
std::string value;
bool is_number() const;
bool is_true() const;
bool in_section(std::string prefix) const;
long to_i() const;
};
typedef std::vector< std::pair<std::string, Entry*> > ConfigVector;
typedef std::vector<Entry*> EntryList;
ConfigVector variables;
virtual ~ConfigParser();
bool load_file(std::string path);
Entry* parse_line(const char* line);
void import_line(const char* line);
void set(const char* name, const char* val);
void import_many(std::string string);
void import_stream(std::istream&);
Entry* find(std::string variable);
EntryList* get_section(std::string prefix);
void update_configuration(Configuration&);
private:
bool process_internal(std::string key, std::string val);
};
}
#endif