class Config

Overview

Singleton for holding and requesting configuration file parameters. More…

#include <Config.h>

class Config {
public:
    // methods

    static std::string PopErrorLog();
    static const std::unordered_set<std::string>& GetUnreadableRecords();
    static bool LoadFile(const std::string& file_name);
    static void Clear();
    static bool Exists(const std::string& key);
    static std::string GetStr(const std::string& key, const std::string& default_val = "");
    static bool GetBool(const std::string& key, const bool default_val = false);
    static size_t GetSizeT(const std::string& key, const size_t default_val = 0);

    template <typename T>
    static T GetUint(const std::string& key, const T default_val = 0);

    static int GetInt(const std::string& key, const int default_val = 0);
    static float GetFloat(const std::string& key, const float default_val = 0.0f);
    static double GetDouble(const std::string& key, const double default_val = 0.0);

    template <glm::length_t N, typename Type>
    static glm::vec<N, Type, glm::highp> GetVec(const std::string& key, const glm::vec<N, Type, glm::highp> default_val = glm::vec<N, Type, glm::highp>(0));

    static std::vector<std::string> GetArray(const std::string& key, const std::vector<std::string>& default_val = {});
    static std::vector<float> GetFloatArray(const std::string& key, const std::vector<float>& default_val = {});
    static std::vector<int> GetIntArray(const std::string& key, const std::vector<int>& default_val = {});
    static std::vector<bool> GetBoolArray(const std::string& key, const std::vector<bool>& default_val = {});
};

Detailed Documentation

Singleton for holding and requesting configuration file parameters.

Methods

static std::string PopErrorLog()

Returns the error log as a string.

static const std::unordered_set<std::string>& GetUnreadableRecords()

Get skipped unreadable (most likely non-ASCII) records.

static bool LoadFile(const std::string& file_name)

Loads config file into the config singleton.

static void Clear()

Clears config data.

static bool Exists(const std::string& key)

If the key does exist in the singletons data, returns true.

static std::string GetStr(const std::string& key, const std::string& default_val = "")

Returns a string value for the key, if the exists.

static bool GetBool(const std::string& key, const bool default_val = false)

Returns a bool value for the key if the key does exist.

static size_t GetSizeT(const std::string& key, const size_t default_val = 0)

Returns a size_t value for the key if the key does exist.

template <typename T>
static T GetUint(const std::string& key, const T default_val = 0)

Returns an unsigned integer value for the key if the key does exist.

static int GetInt(const std::string& key, const int default_val = 0)

Returns an int value for the key if the key does exist.

static float GetFloat(const std::string& key, const float default_val = 0.0f)

Returns an float value for the key if the key does exist.

static double GetDouble(const std::string& key, const double default_val = 0.0)

Returns a double value for the key if the key does exist.

template <glm::length_t N, typename Type>
static glm::vec<N, Type, glm::highp> GetVec(const std::string& key, const glm::vec<N, Type, glm::highp> default_val = glm::vec<N, Type, glm::highp>(0))

Returns a glm::vec value for the key if the key does exist.

static std::vector<std::string> GetArray(const std::string& key, const std::vector<std::string>& default_val = {})

Returns a std::vector<std::string> value for the key if the key does exist.

static std::vector<float> GetFloatArray(const std::string& key, const std::vector<float>& default_val = {})

Returns a std::vector<float> value for the key if the key does exist.

static std::vector<int> GetIntArray(const std::string& key, const std::vector<int>& default_val = {})

Returns a std::vector<int> value for the key if the key does exist.

static std::vector<bool> GetBoolArray(const std::string& key, const std::vector<bool>& default_val = {})

Returns a std::vector<bool> value for the key if the key does exist.