mirror of https://github.com/Icinga/icinga2.git
Apply clang-tidy fix 'modernize-use-emplace'
This commit is contained in:
parent
e3ad0be769
commit
becfa85094
|
@ -111,7 +111,7 @@ void MainForm::OnTypeSelected(wxTreeEvent& event)
|
|||
ApiType::Ptr type = m_Types[typeName.ToStdString()];
|
||||
|
||||
std::vector<String> attrs;
|
||||
attrs.push_back("__name");
|
||||
attrs.emplace_back("__name");
|
||||
|
||||
m_ApiClient->GetObjects(type->PluralName, std::bind(&MainForm::ObjectsCompletionHandler, this, _1, _2, true),
|
||||
std::vector<String>(), attrs);
|
||||
|
@ -170,7 +170,7 @@ void MainForm::OnObjectSelected(wxListEvent& event)
|
|||
return;
|
||||
|
||||
std::vector<String> names;
|
||||
names.push_back(objectName);
|
||||
names.emplace_back(objectName);
|
||||
|
||||
m_ApiClient->GetObjects(type->PluralName, std::bind(&MainForm::ObjectDetailsCompletionHandler, this, _1, _2, true),
|
||||
names, std::vector<String>(), std::vector<String>(), true);
|
||||
|
|
|
@ -227,43 +227,43 @@ const std::vector<String>& ConfigWriter::GetKeywords()
|
|||
boost::mutex::scoped_lock lock(mutex);
|
||||
|
||||
if (keywords.empty()) {
|
||||
keywords.push_back("object");
|
||||
keywords.push_back("template");
|
||||
keywords.push_back("include");
|
||||
keywords.push_back("include_recursive");
|
||||
keywords.push_back("include_zones");
|
||||
keywords.push_back("library");
|
||||
keywords.push_back("null");
|
||||
keywords.push_back("true");
|
||||
keywords.push_back("false");
|
||||
keywords.push_back("const");
|
||||
keywords.push_back("var");
|
||||
keywords.push_back("this");
|
||||
keywords.push_back("globals");
|
||||
keywords.push_back("locals");
|
||||
keywords.push_back("use");
|
||||
keywords.push_back("__using");
|
||||
keywords.push_back("default");
|
||||
keywords.push_back("ignore_on_error");
|
||||
keywords.push_back("current_filename");
|
||||
keywords.push_back("current_line");
|
||||
keywords.push_back("apply");
|
||||
keywords.push_back("to");
|
||||
keywords.push_back("where");
|
||||
keywords.push_back("import");
|
||||
keywords.push_back("assign");
|
||||
keywords.push_back("ignore");
|
||||
keywords.push_back("function");
|
||||
keywords.push_back("return");
|
||||
keywords.push_back("break");
|
||||
keywords.push_back("continue");
|
||||
keywords.push_back("for");
|
||||
keywords.push_back("if");
|
||||
keywords.push_back("else");
|
||||
keywords.push_back("while");
|
||||
keywords.push_back("throw");
|
||||
keywords.push_back("try");
|
||||
keywords.push_back("except");
|
||||
keywords.emplace_back("object");
|
||||
keywords.emplace_back("template");
|
||||
keywords.emplace_back("include");
|
||||
keywords.emplace_back("include_recursive");
|
||||
keywords.emplace_back("include_zones");
|
||||
keywords.emplace_back("library");
|
||||
keywords.emplace_back("null");
|
||||
keywords.emplace_back("true");
|
||||
keywords.emplace_back("false");
|
||||
keywords.emplace_back("const");
|
||||
keywords.emplace_back("var");
|
||||
keywords.emplace_back("this");
|
||||
keywords.emplace_back("globals");
|
||||
keywords.emplace_back("locals");
|
||||
keywords.emplace_back("use");
|
||||
keywords.emplace_back("__using");
|
||||
keywords.emplace_back("default");
|
||||
keywords.emplace_back("ignore_on_error");
|
||||
keywords.emplace_back("current_filename");
|
||||
keywords.emplace_back("current_line");
|
||||
keywords.emplace_back("apply");
|
||||
keywords.emplace_back("to");
|
||||
keywords.emplace_back("where");
|
||||
keywords.emplace_back("import");
|
||||
keywords.emplace_back("assign");
|
||||
keywords.emplace_back("ignore");
|
||||
keywords.emplace_back("function");
|
||||
keywords.emplace_back("return");
|
||||
keywords.emplace_back("break");
|
||||
keywords.emplace_back("continue");
|
||||
keywords.emplace_back("for");
|
||||
keywords.emplace_back("if");
|
||||
keywords.emplace_back("else");
|
||||
keywords.emplace_back("while");
|
||||
keywords.emplace_back("throw");
|
||||
keywords.emplace_back("try");
|
||||
keywords.emplace_back("except");
|
||||
}
|
||||
|
||||
return keywords;
|
||||
|
|
|
@ -59,7 +59,7 @@ std::vector<Object::Ptr> DependencyGraph::GetParents(const Object::Ptr& child)
|
|||
if (it != m_Dependencies.end()) {
|
||||
typedef std::pair<Object *, int> kv_pair;
|
||||
for (const kv_pair& kv : it->second) {
|
||||
objects.push_back(kv.first);
|
||||
objects.emplace_back(kv.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -580,9 +580,9 @@ bool Utility::Glob(const String& pathSpec, const std::function<void (const Strin
|
|||
continue;
|
||||
|
||||
if (S_ISDIR(statbuf.st_mode) && (type & GlobDirectory))
|
||||
dirs.push_back(*gp);
|
||||
dirs.emplace_back(*gp);
|
||||
else if (!S_ISDIR(statbuf.st_mode) && (type & GlobFile))
|
||||
files.push_back(*gp);
|
||||
files.emplace_back(*gp);
|
||||
}
|
||||
|
||||
globfree(&gr);
|
||||
|
@ -1003,7 +1003,7 @@ String Utility::FormatDuration(double duration)
|
|||
if (milliseconds >= 1)
|
||||
tokens.emplace_back(Convert::ToString(milliseconds) + (milliseconds != 1 ? " milliseconds" : " millisecond"));
|
||||
else
|
||||
tokens.push_back("less than 1 millisecond");
|
||||
tokens.emplace_back("less than 1 millisecond");
|
||||
}
|
||||
|
||||
return NaturalJoin(tokens);
|
||||
|
@ -1254,10 +1254,10 @@ int Utility::CompareVersion(const String& v1, const String& v2)
|
|||
boost::algorithm::split(tokensv2, v2, boost::is_any_of("."));
|
||||
|
||||
for (std::vector<String>::size_type i = 0; i < tokensv2.size() - tokensv1.size(); i++)
|
||||
tokensv1.push_back("0");
|
||||
tokensv1.emplace_back("0");
|
||||
|
||||
for (std::vector<String>::size_type i = 0; i < tokensv1.size() - tokensv2.size(); i++)
|
||||
tokensv2.push_back("0");
|
||||
tokensv2.emplace_back("0");
|
||||
|
||||
for (std::vector<String>::size_type i = 0; i < tokensv1.size(); i++) {
|
||||
if (Convert::ToLong(tokensv2[i]) > Convert::ToLong(tokensv1[i]))
|
||||
|
|
|
@ -327,7 +327,7 @@ void ConfigItem::Register()
|
|||
/* If this is a non-abstract object with a composite name
|
||||
* we register it in m_UnnamedItems instead of m_Items. */
|
||||
if (!m_Abstract && dynamic_cast<NameComposer *>(m_Type.get()))
|
||||
m_UnnamedItems.push_back(this);
|
||||
m_UnnamedItems.emplace_back(this);
|
||||
else {
|
||||
auto& items = m_Items[m_Type];
|
||||
|
||||
|
|
|
@ -457,32 +457,32 @@ String CompatUtility::GetCheckableNotificationNotificationOptions(const Checkabl
|
|||
/* notification state filters */
|
||||
if (service) {
|
||||
if (notification_state_filter & ServiceWarning) {
|
||||
notification_options.push_back("w");
|
||||
notification_options.emplace_back("w");
|
||||
}
|
||||
if (notification_state_filter & ServiceUnknown) {
|
||||
notification_options.push_back("u");
|
||||
notification_options.emplace_back("u");
|
||||
}
|
||||
if (notification_state_filter & ServiceCritical) {
|
||||
notification_options.push_back("c");
|
||||
notification_options.emplace_back("c");
|
||||
}
|
||||
} else {
|
||||
if (notification_state_filter & HostDown) {
|
||||
notification_options.push_back("d");
|
||||
notification_options.emplace_back("d");
|
||||
}
|
||||
}
|
||||
|
||||
/* notification type filters */
|
||||
if (notification_type_filter & NotificationRecovery) {
|
||||
notification_options.push_back("r");
|
||||
notification_options.emplace_back("r");
|
||||
}
|
||||
if ((notification_type_filter & NotificationFlappingStart) ||
|
||||
(notification_type_filter & NotificationFlappingEnd)) {
|
||||
notification_options.push_back("f");
|
||||
notification_options.emplace_back("f");
|
||||
}
|
||||
if ((notification_type_filter & NotificationDowntimeStart) ||
|
||||
(notification_type_filter & NotificationDowntimeEnd) ||
|
||||
(notification_type_filter & NotificationDowntimeRemoved)) {
|
||||
notification_options.push_back("s");
|
||||
notification_options.emplace_back("s");
|
||||
}
|
||||
|
||||
return boost::algorithm::join(notification_options, ",");
|
||||
|
|
|
@ -71,10 +71,10 @@ LivestatusQuery::LivestatusQuery(const std::vector<String>& lines, const String&
|
|||
m_CompatLogPath = compat_log_path;
|
||||
|
||||
/* default separators */
|
||||
m_Separators.push_back("\n");
|
||||
m_Separators.push_back(";");
|
||||
m_Separators.push_back(",");
|
||||
m_Separators.push_back("|");
|
||||
m_Separators.emplace_back("\n");
|
||||
m_Separators.emplace_back(";");
|
||||
m_Separators.emplace_back(",");
|
||||
m_Separators.emplace_back("|");
|
||||
|
||||
String line = lines[0];
|
||||
|
||||
|
@ -233,7 +233,7 @@ LivestatusQuery::LivestatusQuery(const std::vector<String>& lines, const String&
|
|||
aggregators.pop_back();
|
||||
}
|
||||
|
||||
deq.push_back(filter);
|
||||
deq.emplace_back(filter);
|
||||
if (&deq == &stats) {
|
||||
Aggregator::Ptr aggregator = new CountAggregator();
|
||||
aggregator->SetFilter(filter);
|
||||
|
@ -317,7 +317,7 @@ Filter::Ptr LivestatusQuery::ParseFilter(const String& params, unsigned long& fr
|
|||
tokens.emplace_back(std::move(temp_buffer));
|
||||
|
||||
if (tokens.size() == 2)
|
||||
tokens.push_back("");
|
||||
tokens.emplace_back("");
|
||||
|
||||
if (tokens.size() < 3)
|
||||
return nullptr;
|
||||
|
|
|
@ -373,7 +373,7 @@ void InfluxdbWriter::SendMetric(const Dictionary::Ptr& tmpl, const String& label
|
|||
#endif /* I2_DEBUG */
|
||||
|
||||
// Buffer the data point
|
||||
m_DataBuffer.push_back(msgbuf.str());
|
||||
m_DataBuffer.emplace_back(msgbuf.str());
|
||||
|
||||
// Flush if we've buffered too much to prevent excessive memory use
|
||||
if (static_cast<int>(m_DataBuffer.size()) >= GetFlushThreshold()) {
|
||||
|
@ -423,7 +423,7 @@ void InfluxdbWriter::Flush()
|
|||
url->SetPort(GetPort());
|
||||
|
||||
std::vector<String> path;
|
||||
path.push_back("write");
|
||||
path.emplace_back("write");
|
||||
url->SetPath(path);
|
||||
|
||||
url->AddQueryElement("db", GetDatabase());
|
||||
|
|
|
@ -69,7 +69,7 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques
|
|||
}
|
||||
} else {
|
||||
FilterUtility::CheckPermission(user, permission);
|
||||
objs.push_back(nullptr);
|
||||
objs.emplace_back(nullptr);
|
||||
}
|
||||
|
||||
Array::Ptr results = new Array();
|
||||
|
|
|
@ -122,7 +122,7 @@ void ApiClient::GetObjects(const String& pluralType, const ObjectsCompletionCall
|
|||
params["joins"].push_back(join);
|
||||
}
|
||||
|
||||
params["all_joins"].push_back(all_joins ? "1" : "0");
|
||||
params["all_joins"].emplace_back(all_joins ? "1" : "0");
|
||||
|
||||
url->SetQuery(params);
|
||||
|
||||
|
@ -232,7 +232,7 @@ void ApiClient::ExecuteScript(const String& session, const String& command, bool
|
|||
std::map<String, std::vector<String> > params;
|
||||
params["session"].push_back(session);
|
||||
params["command"].push_back(command);
|
||||
params["sandboxed"].push_back(sandboxed ? "1" : "0");
|
||||
params["sandboxed"].emplace_back(sandboxed ? "1" : "0");
|
||||
url->SetQuery(params);
|
||||
|
||||
try {
|
||||
|
@ -311,7 +311,7 @@ void ApiClient::AutocompleteScript(const String& session, const String& command,
|
|||
std::map<String, std::vector<String> > params;
|
||||
params["session"].push_back(session);
|
||||
params["command"].push_back(command);
|
||||
params["sandboxed"].push_back(sandboxed ? "1" : "0");
|
||||
params["sandboxed"].emplace_back(sandboxed ? "1" : "0");
|
||||
url->SetQuery(params);
|
||||
|
||||
try {
|
||||
|
|
|
@ -127,7 +127,7 @@ static void FilteredAddTarget(ScriptFrame& permissionFrame, Expression *permissi
|
|||
ScriptFrame& frame, Expression *ufilter, std::vector<Value>& result, const String& variableName, const Object::Ptr& target)
|
||||
{
|
||||
if (FilterUtility::EvaluateFilter(permissionFrame, permissionFilter, target, variableName) && FilterUtility::EvaluateFilter(frame, ufilter, target, variableName))
|
||||
result.push_back(target);
|
||||
result.emplace_back(target);
|
||||
}
|
||||
|
||||
void FilterUtility::CheckPermission(const ApiUser::Ptr& user, const String& permission, Expression **permissionFilter)
|
||||
|
|
|
@ -27,13 +27,12 @@ BOOST_AUTO_TEST_SUITE(base_base64)
|
|||
BOOST_AUTO_TEST_CASE(base64)
|
||||
{
|
||||
std::vector<String> clearText;
|
||||
clearText.push_back("");
|
||||
clearText.push_back("1");
|
||||
clearText.push_back("12");
|
||||
clearText.push_back("123");
|
||||
clearText.push_back("1234");
|
||||
clearText.push_back(
|
||||
"VsowLvPqEiAeITDmo-5L_NB-k7fsT3sT2d3K9O4iC2uBk41hvCPAxrgGSxrdeX5s"
|
||||
clearText.emplace_back("");
|
||||
clearText.emplace_back("1");
|
||||
clearText.emplace_back("12");
|
||||
clearText.emplace_back("123");
|
||||
clearText.emplace_back("1234");
|
||||
clearText.emplace_back("VsowLvPqEiAeITDmo-5L_NB-k7fsT3sT2d3K9O4iC2uBk41hvCPAxrgGSxrdeX5s"
|
||||
"Zo0Z9b1kxDZlzf8GHQ9ARW6YLeGODMtiZo8cKkUzfSbxyZ_wlE9u6pCTTg9kODCM"
|
||||
"Ve-X_a3jWkOy89RoDkT5ahKBY-8S25L6wlvWt8ZyQ2bLxfplzEzuHgEknTMKKp2K"
|
||||
"jRlwI2p3gF4FYeQM7dx0E5O782Lh1P3IC6jPNqiZgTgWmsRYZbAN8oU2V626bQxD"
|
||||
|
|
|
@ -41,8 +41,8 @@ BOOST_AUTO_TEST_CASE(simple)
|
|||
macrosB->Set("testD", testD);
|
||||
|
||||
MacroProcessor::ResolverList resolvers;
|
||||
resolvers.push_back(std::make_pair("macrosA", macrosA));
|
||||
resolvers.push_back(std::make_pair("macrosB", macrosB));
|
||||
resolvers.emplace_back("macrosA", macrosA);
|
||||
resolvers.emplace_back("macrosB", macrosB);
|
||||
|
||||
BOOST_CHECK(MacroProcessor::ResolveMacros("$macrosA.testB$ $macrosB.testC$", resolvers) == "hello world");
|
||||
BOOST_CHECK(MacroProcessor::ResolveMacros("$testA$", resolvers) == "7");
|
||||
|
|
|
@ -67,10 +67,10 @@ BOOST_AUTO_TEST_CASE(hosts)
|
|||
BOOST_TEST_MESSAGE( "Querying Livestatus...");
|
||||
|
||||
std::vector<String> lines;
|
||||
lines.push_back("GET hosts");
|
||||
lines.push_back("Columns: host_name address check_command");
|
||||
lines.push_back("OutputFormat: json");
|
||||
lines.push_back("\n");
|
||||
lines.emplace_back("GET hosts");
|
||||
lines.emplace_back("Columns: host_name address check_command");
|
||||
lines.emplace_back("OutputFormat: json");
|
||||
lines.emplace_back("\n");
|
||||
|
||||
/* use our query helper */
|
||||
String output = LivestatusQueryHelper(lines);
|
||||
|
@ -97,10 +97,10 @@ BOOST_AUTO_TEST_CASE(services)
|
|||
BOOST_TEST_MESSAGE( "Querying Livestatus...");
|
||||
|
||||
std::vector<String> lines;
|
||||
lines.push_back("GET services");
|
||||
lines.push_back("Columns: host_name service_description check_command notes");
|
||||
lines.push_back("OutputFormat: json");
|
||||
lines.push_back("\n");
|
||||
lines.emplace_back("GET services");
|
||||
lines.emplace_back("Columns: host_name service_description check_command notes");
|
||||
lines.emplace_back("OutputFormat: json");
|
||||
lines.emplace_back("\n");
|
||||
|
||||
/* use our query helper */
|
||||
String output = LivestatusQueryHelper(lines);
|
||||
|
|
|
@ -34,9 +34,9 @@ BOOST_AUTO_TEST_CASE(id_and_path)
|
|||
BOOST_CHECK(url->GetAuthority() == "icinga.com");
|
||||
|
||||
std::vector<String> PathCorrect;
|
||||
PathCorrect.push_back("foo");
|
||||
PathCorrect.push_back("bar");
|
||||
PathCorrect.push_back("baz");
|
||||
PathCorrect.emplace_back("foo");
|
||||
PathCorrect.emplace_back("bar");
|
||||
PathCorrect.emplace_back("baz");
|
||||
|
||||
BOOST_CHECK(url->GetPath() == PathCorrect);
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
|||
|
||||
for (const Field& field : klass.Fields) {
|
||||
auto hash = static_cast<int>(SDBM(field.Name, hlen));
|
||||
jumptable[hash].push_back(std::make_pair(num, field.Name));
|
||||
jumptable[hash].emplace_back(num, field.Name);
|
||||
num++;
|
||||
|
||||
if (jumptable[hash].size() > 1)
|
||||
|
@ -403,7 +403,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
|||
<< "\t" << "std::vector<String> deps;" << std::endl;
|
||||
|
||||
for (const std::string& dep : klass.LoadDependencies)
|
||||
m_Impl << "\t" << "deps.push_back(\"" << dep << "\");" << std::endl;
|
||||
m_Impl << "\t" << "deps.emplace_back(\"" << dep << "\");" << std::endl;
|
||||
|
||||
m_Impl << "\t" << "return deps;" << std::endl
|
||||
<< "}" << std::endl << std::endl;
|
||||
|
@ -1208,7 +1208,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string&
|
|||
else
|
||||
subvalidator_prefix = name;
|
||||
|
||||
m_Impl << (type_check ? "\t" : "") << (indent ? "\t\t" : "") << "\t\t" << "location.push_back(akey);" << std::endl
|
||||
m_Impl << (type_check ? "\t" : "") << (indent ? "\t\t" : "") << "\t\t" << "location.emplace_back(akey);" << std::endl
|
||||
<< (type_check ? "\t" : "") << (indent ? "\t\t" : "") << "\t\t" << "TIValidate" << subvalidator_prefix << "_" << i << "(object, akey, avalue, location, utils);" << std::endl
|
||||
<< (type_check ? "\t" : "") << (indent ? "\t\t" : "") << "\t\t" << "location.pop_back();" << std::endl;
|
||||
|
||||
|
@ -1313,7 +1313,7 @@ void ClassCompiler::HandleValidator(const Validator& validator, const ClassDebug
|
|||
<< "{" << std::endl
|
||||
<< "\t" << "SimpleValidate" << it.first.second << "(value, utils);" << std::endl
|
||||
<< "\t" << "std::vector<String> location;" << std::endl
|
||||
<< "\t" << "location.push_back(\"" << it.second.Name << "\");" << std::endl
|
||||
<< "\t" << "location.emplace_back(\"" << it.second.Name << "\");" << std::endl
|
||||
<< "\t" << "TIValidate" << it.first.first << it.first.second << "(this, value, location, utils);" << std::endl
|
||||
<< "\t" << "location.pop_back();" << std::endl
|
||||
<< "}" << std::endl << std::endl;
|
||||
|
|
Loading…
Reference in New Issue