// This source code is released into the public domain. module nihil.config; import nihil.std; import nihil.generator; import nihil.util; namespace nihil::config { store::store() = default; auto store::get() -> store & { static auto instance = store(); return instance; } auto store::register_option(this store &self, option *object) -> std::expected { auto [it, okay] = self.m_options.insert( std::pair{object->name(), object}); if (okay) return {}; return std::unexpected(error(std::format( "attempt to register duplicate " "configuration option '{0}'", object->name()))); } auto store::unregister_option(this store &self, option *object) -> std::expected { auto it = self.m_options.find(object->name()); if (it == self.m_options.end()) return std::unexpected(error(std::format( "attempt to unregister non-existent " "configuration option '{}'", object->name()))); self.m_options.erase(it); return {}; } auto store::fetch(this store const &self, std::string_view name) -> std::expected