Enigma  3.2.0
A Simple, Reliable and Efficient Encryption Tool
Config.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef ENIGMA_CONFIG_H
3 #define ENIGMA_CONFIG_H
4 
5 #include <Core/Core.hpp>
6 #include <INIReader.h>
7 #include <Utility/FileUtils.hpp>
8 
11 class Config {
12  public:
18  explicit Config(const fs::path& file_name);
19  ~Config() = default;
20 
21  public:
28  template<typename T>
29  inline typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value, T>::type
30  Get(const std::string& section, const std::string& name, const T& default_value) const {
31  return static_cast<T>(m_ini_reader->GetInteger(section, name, default_value));
32  }
33 
39  template<typename T>
40  inline typename std::enable_if<std::is_floating_point<T>::value, T>::type
41  Get(const std::string& section, const std::string& name, const T& default_value) const {
42  return static_cast<T>(m_ini_reader->GetReal(section, name, default_value));
43  }
44 
50  template<typename T>
51  inline typename std::enable_if<std::is_same<T, bool>::value, T>::type
52  Get(const std::string& section, const std::string& name, const T& default_value) const {
53  return m_ini_reader->GetBoolean(section, name, default_value);
54  }
55 
61  template<typename T>
62  inline typename std::enable_if<std::is_same<T, std::string>::value, T>::type
63  Get(const std::string& section, const std::string& name, const T& default_value) const {
64  return m_ini_reader->GetString(section, name, default_value);
65  }
66 
67  private:
68  std::unique_ptr<INIReader> m_ini_reader{};
69 };
71 
72 #endif // !ENIGMA_CONFIG_H
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition: Macros.hpp:13
#define NS_ENIGMA_END
Definition: Macros.hpp:14
Config(const fs::path &file_name)
std::enable_if< std::is_same< T, bool >::value, T >::type Get(const std::string &section, const std::string &name, const T &default_value) const
Definition: Config.hpp:52
std::enable_if< std::is_same< T, std::string >::value, T >::type Get(const std::string &section, const std::string &name, const T &default_value) const
Definition: Config.hpp:63
std::enable_if< std::is_floating_point< T >::value, T >::type Get(const std::string &section, const std::string &name, const T &default_value) const
Definition: Config.hpp:41
std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value, T >::type Get(const std::string &section, const std::string &name, const T &default_value) const
Definition: Config.hpp:30
~Config()=default