mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Allow ServerConfig::Conf{Value,Tags} to have a fallback default.
This commit is contained in:
parent
2b1d0f5ef4
commit
74661a8112
@ -304,15 +304,17 @@ class CoreExport ServerConfig
|
||||
|
||||
/** Get a configuration tag by name. If one or more tags are present then the first is returned.
|
||||
* @param tag The name of the tag to get.
|
||||
* @param def The value to return if the tag doesn't exist.
|
||||
* @returns Either a tag from the config or EmptyTag.
|
||||
*/
|
||||
std::shared_ptr<ConfigTag> ConfValue(const std::string& tag);
|
||||
std::shared_ptr<ConfigTag> ConfValue(const std::string& tag, std::shared_ptr<ConfigTag> def = nullptr);
|
||||
|
||||
/** Get a list of configuration tags by name.
|
||||
* @param tag The name of the tags to get.
|
||||
* @param def The value to return if the tag doesn't exist.
|
||||
* @returns Either a list of tags from the config or an empty TagList.
|
||||
*/
|
||||
TagList ConfTags(const std::string& tag);
|
||||
TagList ConfTags(const std::string& tag, std::optional<TagList> def = std::nullopt);
|
||||
|
||||
/** An empty configuration tag. */
|
||||
std::shared_ptr<ConfigTag> EmptyTag;
|
||||
|
@ -615,11 +615,11 @@ void ServerConfig::ApplyModules(User* user)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<ConfigTag> ServerConfig::ConfValue(const std::string& tag)
|
||||
std::shared_ptr<ConfigTag> ServerConfig::ConfValue(const std::string& tag, std::shared_ptr<ConfigTag> def)
|
||||
{
|
||||
auto tags = stdalgo::equal_range(config_data, tag);
|
||||
if (tags.empty())
|
||||
return EmptyTag;
|
||||
return def ? def : EmptyTag;
|
||||
|
||||
if (tags.count() > 1)
|
||||
{
|
||||
@ -629,9 +629,10 @@ std::shared_ptr<ConfigTag> ServerConfig::ConfValue(const std::string& tag)
|
||||
return tags.begin()->second;
|
||||
}
|
||||
|
||||
ServerConfig::TagList ServerConfig::ConfTags(const std::string& tag)
|
||||
ServerConfig::TagList ServerConfig::ConfTags(const std::string& tag, std::optional<TagList> def)
|
||||
{
|
||||
return stdalgo::equal_range(config_data, tag);
|
||||
auto range = stdalgo::equal_range(config_data, tag);
|
||||
return range.empty() && def ? *def : range;
|
||||
}
|
||||
|
||||
std::string ServerConfig::Escape(const std::string& str)
|
||||
|
Loading…
x
Reference in New Issue
Block a user