aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-11-03 18:43:19 +0000
committerGravatar Sadie Powell2020-11-03 19:54:13 +0000
commitbe3b34fcea6512c8e5c4e170c50caaa7f14bb15a (patch)
treebc6c6ea00ea80f271d4ed5b86d920758b767d367 /src
parentConvert ConnectClass from reference<> to std::shared_ptr<>. (diff)
downloadinspircd++-be3b34fcea6512c8e5c4e170c50caaa7f14bb15a.tar.gz
inspircd++-be3b34fcea6512c8e5c4e170c50caaa7f14bb15a.tar.bz2
inspircd++-be3b34fcea6512c8e5c4e170c50caaa7f14bb15a.zip
Rename ConfigItems to ConfigTag::Items.
Diffstat (limited to 'src')
-rw-r--r--src/configparser.cpp25
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/modules/m_httpd_config.cpp6
-rw-r--r--src/modules/m_sqloper.cpp2
-rw-r--r--src/users.cpp14
5 files changed, 23 insertions, 28 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 9fef22f15..af7d052cd 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -179,7 +179,7 @@ struct Parser
unget(ch);
}
- bool kv(ConfigItems* items)
+ bool kv(ConfigTag::Items* items)
{
std::string key;
nextword(key);
@@ -288,7 +288,7 @@ struct Parser
if (name.empty())
throw CoreException("Empty tag name");
- ConfigItems* items;
+ ConfigTag::Items* items;
tag = ConfigTag::create(name, current.name, current.line, items);
while (kv(items))
@@ -308,17 +308,13 @@ struct Parser
}
else if (stdalgo::string::equalsci(name, "files"))
{
- for(ConfigItems::const_iterator i = items->begin(); i != items->end(); i++)
- {
- stack.DoReadFile(i->first, i->second, flags, false);
- }
+ for (const auto& [key, value] : *items)
+ stack.DoReadFile(key, value, flags, false);
}
else if (stdalgo::string::equalsci(name, "execfiles"))
{
- for(ConfigItems::const_iterator i = items->begin(); i != items->end(); i++)
- {
- stack.DoReadFile(i->first, i->second, flags, true);
- }
+ for (const auto& [key, value] : *items)
+ stack.DoReadFile(key, value, flags, true);
}
else if (stdalgo::string::equalsci(name, "define"))
{
@@ -495,11 +491,12 @@ bool ParseStack::ParseFile(const std::string& path, int flags, const std::string
bool ConfigTag::readString(const std::string& key, std::string& value, bool allow_lf) const
{
- for(ConfigItems::const_iterator j = items.begin(); j != items.end(); ++j)
+ for (const auto& [ikey, ivalue] : items)
{
- if(j->first != key)
+ if (!stdalgo::string::equalsci(ikey, key))
continue;
- value = j->second;
+
+ value = ivalue;
if (!allow_lf && (value.find('\n') != std::string::npos))
{
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + tag + ":" + key + "> at " + getTagLocation() +
@@ -690,7 +687,7 @@ std::string ConfigTag::getTagLocation() const
return src_name + ":" + ConvToStr(src_line);
}
-std::shared_ptr<ConfigTag> ConfigTag::create(const std::string& Tag, const std::string& file, int line, ConfigItems*& Items)
+std::shared_ptr<ConfigTag> ConfigTag::create(const std::string& Tag, const std::string& file, int line, Items*& Items)
{
std::shared_ptr<ConfigTag> rv(new ConfigTag(Tag, file, line));
Items = &rv->items;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 78a21eec7..dd0fe826a 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -62,7 +62,7 @@ ServerConfig::ServerPaths::ServerPaths(std::shared_ptr<ConfigTag> tag)
static std::shared_ptr<ConfigTag> CreateEmptyTag()
{
- ConfigItems* items;
+ ConfigTag::Items* items;
return ConfigTag::create("empty", "<auto>", 0, items);
}
@@ -181,7 +181,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
if (blk_count == 0)
{
// No connect blocks found; make a trivial default block
- ConfigItems* items;
+ ConfigTag::Items* items;
auto tag = ConfigTag::create("connect", "<auto>", 0, items);
(*items)["allow"] = "*";
config_data.insert(std::make_pair("connect", tag));
diff --git a/src/modules/m_httpd_config.cpp b/src/modules/m_httpd_config.cpp
index b9cd256b8..826768d8a 100644
--- a/src/modules/m_httpd_config.cpp
+++ b/src/modules/m_httpd_config.cpp
@@ -55,10 +55,10 @@ class ModuleHttpConfig : public Module, public HTTPRequestEventListener
// Print out the tag with all keys aligned vertically.
const std::string indent(tag->tag.length() + 2, ' ');
- const ConfigItems& items = tag->getItems();
- for (ConfigItems::const_iterator kiter = items.begin(); kiter != items.end(); )
+ const ConfigTag::Items& items = tag->GetItems();
+ for (ConfigTag::Items::const_iterator kiter = items.begin(); kiter != items.end(); )
{
- ConfigItems::const_iterator curr = kiter++;
+ ConfigTag::Items::const_iterator curr = kiter++;
buffer << curr->first << "=\"" << ServerConfig::Escape(curr->second) << '"';
if (kiter != items.end())
buffer << std::endl << indent;
diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp
index 11c995dab..5d6d86aa9 100644
--- a/src/modules/m_sqloper.cpp
+++ b/src/modules/m_sqloper.cpp
@@ -70,7 +70,7 @@ class OperQuery : public SQL::Query
res.GetCols(cols);
// Create the oper tag as if we were the conf file.
- ConfigItems* items;
+ ConfigTag::Items* items;
auto tag = ConfigTag::create("oper", MODNAME, 0, items);
/** Iterate through each column in the SQLOpers table. An infinite number of fields can be specified.
diff --git a/src/users.cpp b/src/users.cpp
index cee201d0b..9be5cdada 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1239,26 +1239,24 @@ ConnectClass::ConnectClass(std::shared_ptr<ConfigTag> tag, char t, const std::st
// Connect classes can inherit from each other but this is problematic for modules which can't use
// ConnectClass::Update so we build a hybrid tag containing all of the values set on this class as
// well as the parent class.
- ConfigItems* items = NULL;
+ ConfigTag::Items* items;
config = ConfigTag::create(tag->tag, tag->src_name, tag->src_line, items);
- const ConfigItems& parentkeys = parent->config->getItems();
- for (ConfigItems::const_iterator piter = parentkeys.begin(); piter != parentkeys.end(); ++piter)
+ for (const auto& [key, value] : parent->config->GetItems())
{
// The class name and parent name are not inherited
- if (stdalgo::string::equalsci(piter->first, "name") || stdalgo::string::equalsci(piter->first, "parent"))
+ if (stdalgo::string::equalsci(key, "name") || stdalgo::string::equalsci(key, "parent"))
continue;
// Store the item in the config tag. If this item also
// exists in the child it will be overwritten.
- (*items)[piter->first] = piter->second;
+ (*items)[key] = value;
}
- const ConfigItems& childkeys = tag->getItems();
- for (ConfigItems::const_iterator citer = childkeys.begin(); citer != childkeys.end(); ++citer)
+ for (const auto& [key, value] : tag->GetItems())
{
// This will overwrite the parent value if present.
- (*items)[citer->first] = citer->second;
+ (*items)[key] = value;
}
}