Mania++
 All Classes Functions Variables Pages
Config.h
1 #ifndef CONFIG_H_
2 #define CONFIG_H_
3 
4 #include <string>
5 #include <iostream>
6 
7 #include <yaml-cpp/yaml.h>
8 
9 #include "../Permissions/Permission.h"
10 
11 //* ServerConfig
18 {
19  std::string address;
20  int port;
21  std::string username;
22  std::string password;
23 };
24 
25 //* DatabaseConfig
32 {
33  std::string address;
34  int port;
35  std::string username;
36  std::string password;
37  std::string database;
38 };
39 
40 //* ProgramConfig
47 {
48  bool checkVersion = true;
49 };
50 
51 //* PluginConfig
58 {
59  std::string name;
60  std::map<std::string, std::string> settings;
61 };
62 
63 //* Config
67 class Config
68 {
69 public:
75  Config(std::string configFile);
76 
80  ~Config();
81 
85  std::map<std::string, PluginConfig>* Plugins;
86  std::map<std::string, Permission>* Permissions;
88 private:
92  void parseConfig();
93 
99  void parsePermissions(YAML::Node permissions);
100 
106  void parsePlugins(YAML::Node plugins);
107 
108  std::string configFile;
109 };
110 
111 #endif // CONFIG_H_
Config(std::string configFile)
Calls parseConfig to parse the configuration file.
Definition: Config.cpp:3
ProgramConfig * Program
Instance of ProgramConfig which stores program settings.
Definition: Config.h:84
std::string password
Password with which to authenticate on the server.
Definition: Config.h:22
void parsePermissions(YAML::Node permissions)
Reads permissions from YAML file.
Definition: Config.cpp:48
std::string name
Plugin name (directory name).
Definition: Config.h:59
int port
Server XML-RPC port.
Definition: Config.h:20
std::string configFile
Name of the configuration file, set by constructor.
Definition: Config.h:108
std::map< std::string, std::string > settings
Plugin settings.
Definition: Config.h:60
std::map< std::string, PluginConfig > * Plugins
List of plugin configurations.
Definition: Config.h:85
Reads and stores configuration information.
Definition: Config.h:67
int port
Database serverport.
Definition: Config.h:34
std::string username
Username with which to authenticate on the database server.
Definition: Config.h:35
std::string username
Username with which to authenticate on the server.
Definition: Config.h:21
void parseConfig()
Reads information from YAML file and puts this in configuration struct(s).
Definition: Config.cpp:17
Plugin settings.
Definition: Config.h:57
~Config()
Definition: Config.cpp:9
std::string address
Server address (either hostname or IP Address).
Definition: Config.h:19
std::string database
Name of the database that should be used.
Definition: Config.h:37
DatabaseConfig * Database
Instance of DatabaseConfig which stores the database server connection settings.
Definition: Config.h:83
void parsePlugins(YAML::Node plugins)
Reads plugin information from YAML file.
Definition: Config.cpp:74
std::map< std::string, Permission > * Permissions
Overview of permissions from configuration.
Definition: Config.h:86
Server connection settings.
Definition: Config.h:17
Database connection settings.
Definition: Config.h:31
std::string password
Password with which to authenticate on the database server.
Definition: Config.h:36
ServerConfig * Server
Instance of ServerConfig which stores the server connection settings.
Definition: Config.h:82
bool checkVersion
Check for updates on start-up.
Definition: Config.h:48
std::string address
Database address (either hostname or IP Address).
Definition: Config.h:33
Program settings.
Definition: Config.h:46