-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigParser.hpp
More file actions
34 lines (30 loc) · 895 Bytes
/
ConfigParser.hpp
File metadata and controls
34 lines (30 loc) · 895 Bytes
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
#pragma once
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <locale>
#include <map>
struct parsed_t
{
const std::string lvalue;
const std::string rvalue;
parsed_t(const std::string a, const std::string b): lvalue(a), rvalue(b) {};
};
class ConfigParser
{
std::vector<std::string> keys;
std::string separator {""};
std::map<std::string, std::string> output_map;
bool trim(std::string &str);
bool checkKeyValidity(const std::string &key);
virtual bool checkMapValidity();
public:
ConfigParser(const std::vector<std::string> &v);
ConfigParser(const std::vector<std::string> &v, const std::string &sep);
// ~ConfigParser();
std::unique_ptr<struct parsed_t> parseString(std::string &str);
bool parseStream(std::fstream &stream);
std::map<std::string, std::string> getMap();
void viewConfig();
};