Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string>
- namespace configuration
- {
- class interface
- {
- public:
- virtual ~interface()
- {
- }
- virtual std::string read(const std::string &) const = 0;
- virtual interface &write(const std::string &, const std::string &) = 0;
- virtual bool is_set(const std::string &) const = 0;
- template<typename T>
- T get(const std::string &) const;
- template<typename T>
- void set(const std::string &, const T &);
- };
- template<typename T>
- T interface::get(const std::string &name) const
- {
- return T(read(name));
- }
- template<>
- int interface::get(const std::string &) const
- {
- return 15;
- }
- template<typename T>
- void interface::set(const std::string &name, const T &value)
- {
- write(name, std::string(value));
- }
- template<>
- void interface::set(const std::string &name, const int &)
- {
- write(name, "15");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment