Webserv
Loading...
Searching...
No Matches
ServerConfig.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ServerBlock.hpp"
4#include <ostream>
5
6namespace config {
7
8typedef std::map<int, ServerBlockVec> ServerBlockMap;
9
19public:
20 // ========================= Construction & Destruction =========================
21
23 ServerConfig(char const *fpath, bool perform_fs_checks = true);
24 ServerConfig(std::string const &content, bool perform_fs_checks = true);
25
26 // ============================== Public Interface ==============================
34 ServerBlock const *getServer(int port, std::string const &server_name) const;
35 void addServer(ServerBlock const &);
36
37 // ============================== Getters & Setters =============================
38
39 ServerBlockMap const &getServersMap() const;
40
41private:
42 void build(std::string const &content, bool perform_fs_checks);
43
45};
46
47std::ostream &operator<<(std::ostream &o, ServerConfig const &t);
48
49} // namespace config
Represents a single 'server' block from the configuration file.
Definition ServerBlock.hpp:18
A strongly-typed data container for a server block's configuration.
Definition ServerConfig.hpp:18
void addServer(ServerBlock const &)
Definition ServerConfig.cpp:51
void build(std::string const &content, bool perform_fs_checks)
Definition ServerConfig.cpp:30
ServerBlockMap const & getServersMap() const
Definition ServerConfig.cpp:41
ServerBlockMap servers_
Definition ServerConfig.hpp:44
ServerConfig()
Definition ServerConfig.cpp:15
ServerBlock const * getServer(int port, std::string const &server_name) const
Retrieves the server configuration that best matches a port and server name.
Definition ServerConfig.cpp:43
Definition ConfigException.hpp:6
std::ostream & operator<<(std::ostream &o, Token const &t)
Definition Token.cpp:29
std::map< int, ServerBlockVec > ServerBlockMap
Definition ServerConfig.hpp:8