Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string>
- #include <vector>
- #include <memory>
- enum ConfigValueType
- {
- CONFIG_INT,
- CONFIG_FLOAT,
- CONFIG_BOOL,
- CONFIG_STRING
- };
- struct ConfigValue
- {
- ConfigValue() {}
- ConfigValue(int Value, ConfigValueType Type)
- {
- this->Int = Value;
- this->Type = Type;
- }
- ConfigValue(float Value, ConfigValueType Type)
- {
- this->Float = Value;
- this->Type = Type;
- }
- ConfigValue(bool Value, ConfigValueType Type)
- {
- this->Bool = Value;
- this->Type = Type;
- }
- ConfigValue(std::string Value, ConfigValueType Type)
- {
- this->String = Value;
- this->Type = Type;
- }
- int Int;
- float Float;
- bool Bool;
- std::string String;
- ConfigValueType Type;
- };
- struct ConfigSection;
- class CConfig
- {
- public:
- void SetValue(std::string SectionName, std::string KeyName, std::unique_ptr<ConfigValue> Value);
- std::shared_ptr<ConfigValue> GetValue(const std::string& SectionName, const std::string& KeyName);
- // Returns true if succeeded, returns false if failed.
- bool Save(std::string PathToINI);
- void Load(std::string PathToINI);
- // Dump config values into a formatted string.
- std::string DumpValues();
- private:
- std::vector<std::unique_ptr<ConfigSection>> Sections;
- };
- extern std::unique_ptr<CConfig> Config;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement