2021-02-20 18:13:51 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2021-12-30 18:06:04 +01:00
|
|
|
#include <map>
|
2021-02-20 18:13:51 +01:00
|
|
|
|
|
|
|
namespace VUtils {
|
|
|
|
class Environment {
|
|
|
|
public:
|
|
|
|
Environment();
|
|
|
|
explicit Environment(const char *filename);
|
|
|
|
void setFile(const char *filename);
|
|
|
|
void setPrefix(std::string prefix);
|
|
|
|
void loadFile();
|
|
|
|
std::string& getEnv(const std::string& name, std::string def);
|
|
|
|
bool hasEnv(const std::string& name);
|
|
|
|
int getAsInt(const std::string& name, int def);
|
|
|
|
double getAsDouble(const std::string& name, double def);
|
|
|
|
bool getAsBool(const std::string& name);
|
|
|
|
bool saveFile();
|
|
|
|
void set(const char* name, const char *value);
|
|
|
|
void setNumber(const char* name, double value);
|
|
|
|
protected:
|
2021-12-30 18:06:04 +01:00
|
|
|
std::map<std::string, std::string> m_env;
|
2021-02-20 18:13:51 +01:00
|
|
|
std::string m_prefix = "VENV_";
|
|
|
|
std::string m_filename;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|