# class utils::IniParser

## Overview

    #include <IniParser.h>

    class IniParser {
    public:
        // construction

        IniParser();
        IniParser(const std::string& filename);

        // methods

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

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

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

        template <glm::length_t N, typename Type>
        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));

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

    protected:
        // typedefs

        typedef std::pair<std::string, std::string> Record;

        // fields

        std::map<std::string, std::string> replacement_map_;
        const bool is_replacement_map_enabled_ = false;
        utils::Dictionary dictionary_;
        std::string error_log_;
        std::unordered_set<std::string> unreadable_records_;

        // methods

        void LogStandardError(const std::string& key, const std::string& val) const;
        virtual Record GetRecord(const std::string& line);
    };

## Detailed Documentation

### Methods

    std::string PopErrorLog()

Returns the error log as a string.

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

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

    bool LoadFile(const std::string& file_name)

Reads INI values from a file.

    void Clear()

Clears config data.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    template <glm::length_t N, typename Type>
    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.

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

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

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

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

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

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

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

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