Last Update (partial) have to link every file in the right place
This commit is contained in:
36
core/Config.cpp
Normal file
36
core/Config.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "Config.hpp"
|
||||
#include <iostream>
|
||||
|
||||
Config::Config(const char* filename){
|
||||
setConfFile(filename);
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
void Config::setConfFile(const char * filename){
|
||||
config_file.open(filename);
|
||||
}
|
||||
|
||||
void Config::loadConfig(){
|
||||
std::string key, value;
|
||||
while(config_file){
|
||||
getline(config_file, key,':');
|
||||
config_file >> value;
|
||||
config_file >> std::ws;
|
||||
if(!config_file){
|
||||
break;
|
||||
}
|
||||
config_map[key] = value;
|
||||
}
|
||||
config_file.close();
|
||||
}
|
||||
|
||||
void Config::printConfig(){
|
||||
for(std::map<std::string,std::string>::iterator it = config_map.begin(); it != config_map.end(); it++){
|
||||
std::cout << it->first << " : " << it->second << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Config::getValue(std::string key){
|
||||
return config_map[key];
|
||||
}
|
||||
|
26
core/Config.hpp
Normal file
26
core/Config.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
class Config
|
||||
{
|
||||
private:
|
||||
std::map<std::string, std::string> config_map;
|
||||
|
||||
std::ifstream config_file;
|
||||
|
||||
|
||||
public:
|
||||
Config(const char* filename);
|
||||
void loadConfig();
|
||||
void setConfFile(const char* filename);
|
||||
|
||||
void printConfig();
|
||||
|
||||
std::string getValue(std::string key);
|
||||
};
|
||||
|
||||
#endif /* CONFIG_H */
|
17
core/main.cpp
Normal file
17
core/main.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "Database.hpp"
|
||||
#include "Network.hpp"
|
||||
#include "Config.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main( int carg, char* varg[] ){
|
||||
|
||||
Config conf("config.txt");
|
||||
|
||||
Database db;
|
||||
|
||||
Network net;
|
||||
|
||||
net.run();
|
||||
|
||||
}
|
Reference in New Issue
Block a user