aboutsummaryrefslogtreecommitdiffstats
path: root/src/configparser.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-11-03 19:01:53 +0000
committerGravatar Sadie Powell2020-11-03 19:54:13 +0000
commit33a987368e577c117bff53c240b9a3167a981056 (patch)
treeb015b1cffb0c829234ebb97112bf61825d78b8bc /src/configparser.cpp
parentRename ConfigItems to ConfigTag::Items. (diff)
downloadinspircd++-33a987368e577c117bff53c240b9a3167a981056.tar.gz
inspircd++-33a987368e577c117bff53c240b9a3167a981056.tar.bz2
inspircd++-33a987368e577c117bff53c240b9a3167a981056.zip
Replace ConfigTag::create with a public constructor.
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r--src/configparser.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp
index af7d052cd..7bb55bb50 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -179,7 +179,7 @@ struct Parser
unget(ch);
}
- bool kv(ConfigTag::Items* items)
+ bool kv()
{
std::string key;
nextword(key);
@@ -266,10 +266,8 @@ struct Parser
value.push_back(ch);
}
- if (items->find(key) != items->end())
+ if (!tag->GetItems().insert({key, value}).second)
throw CoreException("Duplicate key '" + key + "' found");
-
- (*items)[key] = value;
return true;
}
@@ -288,10 +286,8 @@ struct Parser
if (name.empty())
throw CoreException("Empty tag name");
- ConfigTag::Items* items;
- tag = ConfigTag::create(name, current.name, current.line, items);
-
- while (kv(items))
+ tag = std::make_shared<ConfigTag>(name, current.name, current.line);
+ while (kv())
{
// Do nothing here (silences a GCC warning).
}
@@ -308,12 +304,12 @@ struct Parser
}
else if (stdalgo::string::equalsci(name, "files"))
{
- for (const auto& [key, value] : *items)
+ for (const auto& [key, value] : tag->GetItems())
stack.DoReadFile(key, value, flags, false);
}
else if (stdalgo::string::equalsci(name, "execfiles"))
{
- for (const auto& [key, value] : *items)
+ for (const auto& [key, value] : tag->GetItems())
stack.DoReadFile(key, value, flags, true);
}
else if (stdalgo::string::equalsci(name, "define"))
@@ -687,13 +683,6 @@ 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, Items*& Items)
-{
- std::shared_ptr<ConfigTag> rv(new ConfigTag(Tag, file, line));
- Items = &rv->items;
- return rv;
-}
-
ConfigTag::ConfigTag(const std::string& Tag, const std::string& file, int line)
: tag(Tag), src_name(file), src_line(line)
{