diff options
Diffstat (limited to 'include/Conf.hpp')
-rw-r--r-- | include/Conf.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/Conf.hpp b/include/Conf.hpp index 8b98189..3634f4c 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -4,6 +4,7 @@ #include "Result.hpp" #include "StringView.hpp" #include "utils.hpp" +#include "Dependency.hpp" #include <vector> #include <cassert> #include <stdexcept> @@ -79,6 +80,36 @@ namespace sibs public: static Result<bool> readFromFile(const char *filepath, const ConfigCallback &callback); }; + + class SibsConfig : public ConfigCallback + { + public: + SibsConfig() : finishedProcessing(false) {} + + const std::string& getPackageName() const + { + assert(finishedProcessing); + return packageName; + } + + const std::vector<Dependency>& getDependencies() const + { + return dependencies; + } + protected: + void processObject(StringView name) override; + void processField(StringView name, const ConfigValue &value) override; + + void finished() override + { + finishedProcessing = true; + } + private: + StringView currentObject; + std::string packageName; + std::vector<Dependency> dependencies; + bool finishedProcessing; + }; } #endif //SIBS_CONF_HPP |