-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.hpp
More file actions
58 lines (54 loc) · 1.6 KB
/
Config.hpp
File metadata and controls
58 lines (54 loc) · 1.6 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
#pragma once
#include <map>
#include <string>
#include <vector>
#include <list>
#include "MyServer.hpp"
#include "Location.hpp"
#include "Reader.hpp"
using namespace std;
class Config
{
private:
map<string, string> conf;
unsigned int port;
string protocol;
string root;
string servName;
list<Location> locations;
string defaultLanguage;
string defaultIndex;
map<string, string> languages;
vector<string> methods = {"GET", "PUT"};
string error_log;
void parseConf(int fd);
void parseConf(const string &filename);
map<string, string> parseLocations(Reader &rd);
const string &get(const string &key) const;
void validateSetPort();
void validateSetProtocol();
void validateSetRoot();
void validateSetIndex();
void validateSetServName();
void validateSetServLanguage();
void validateSetLocations(const map<string, string> &loc);
void validateSetErrorLog();
unsigned long long validateSetMaxBody(const string &val);
public:
Config(const string &filename);
~Config();
unsigned int getPort() const;
const string &getServName() const;
const string &getProtocol() const;
const string &getErrorLog() const;
const string &getRoot() const;
const string &getDefLanguage() const;
const map<string, string> &getLanguages() const;
const vector<string> &getAllowedMethods() const;
const list<Location> &getLocations() const;
struct Exception : public MyServer::Exception
{
Exception(const string &msg) : MyServer::Exception(msg) {}
};
};
ostream &operator<<(ostream &out, const Config &c);