From aee178901d8bd03f9e0aeb50e3a5ed7570d9f910 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 11 Jan 2018 19:33:38 +0100 Subject: Start with config object types, for git dependencies --- include/Conf.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include/Conf.hpp') diff --git a/include/Conf.hpp b/include/Conf.hpp index 0b97960..90f150a 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -21,7 +21,8 @@ namespace sibs { NONE, SINGLE, - LIST + LIST, + OBJECT }; ConfigValue() : type(Type::NONE) {} @@ -37,10 +38,18 @@ namespace sibs values(_values) { + } + + ConfigValue(const std::unordered_map &_map) : + type(Type::OBJECT), + map(_map) + { + } bool isSingle() const { return type == Type::SINGLE; } bool isList() const { return type == Type::LIST; } + bool isObject() const { return type == Type::OBJECT; } StringView asSingle() const { @@ -53,9 +62,16 @@ namespace sibs assert(isList()); return values; } + + const std::unordered_map& asObject() const + { + assert(isObject()); + return map; + } private: Type type; std::vector values; + std::unordered_map map; }; class Parser; -- cgit v1.2.3