/* * This source code is released into the public domain. */ module; /* * The configuration store. There should only be one of these. */ #include #include #include export module nihil.config:store; import nihil; import :error; import :option; namespace nihil::config { // Exception thrown on an attempt to fetch an undefined option. export struct unknown_option final : error { unknown_option(std::string_view option_name); auto option_name(this unknown_option const &self) -> std::string_view; private: std::string _option_name; }; struct store final { /* * Get the global config store. */ static auto get() -> store &; /* * Register a new value with the config store. */ auto register_option(this store &self, option *object) -> void; /* * Remove a value from the config store. */ auto unregister_option(this store &self, option *object) -> void; /* * Fetch an existing value in the config store. */ auto fetch(this store const &self, std::string_view name) -> option &; /* * Fetch all values in the configuration store. */ auto all(this store const &self) -> nihil::generator