2021-12-05 17:54:36 +00:00
|
|
|
#pragma once
|
|
|
|
#include <fstream>
|
2022-12-04 22:25:58 +00:00
|
|
|
#include <map>
|
2021-12-05 17:54:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class dConfig {
|
|
|
|
public:
|
|
|
|
dConfig(const std::string& filepath);
|
|
|
|
|
2023-12-30 13:07:49 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the specified filepath exists
|
|
|
|
*/
|
|
|
|
static const bool Exists(const std::string& filepath);
|
|
|
|
|
2022-12-04 22:25:58 +00:00
|
|
|
/**
|
|
|
|
* Gets the specified key from the config. Returns an empty string if the value is not found.
|
|
|
|
*
|
|
|
|
* @param key Key to find
|
|
|
|
* @return The keys value in the config
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
const std::string& GetValue(std::string key);
|
|
|
|
|
2022-12-04 22:25:58 +00:00
|
|
|
/**
|
|
|
|
* Loads the config from a file
|
|
|
|
*/
|
|
|
|
void LoadConfig();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reloads the config file to reset values
|
|
|
|
*/
|
|
|
|
void ReloadConfig();
|
2021-12-05 17:54:36 +00:00
|
|
|
private:
|
|
|
|
void ProcessLine(const std::string& line);
|
|
|
|
|
|
|
|
private:
|
2022-12-04 22:25:58 +00:00
|
|
|
std::map<std::string, std::string> m_ConfigValues;
|
|
|
|
std::string m_ConfigFilePath;
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|