static bool ArraySortCmp(const Function::Ptr& cmp, const Value& a, const Value& b)
{
- std::vector<Value> args;
- args.push_back(a);
- args.push_back(b);
- return cmp->Invoke(args);
+ return cmp->Invoke({ a, b });
}
static Array::Ptr ArraySort(const std::vector<Value>& args)
ObjectLock olock(self);
for (const Value& item : self) {
- std::vector<Value> args;
- args.push_back(item);
- result->Add(function->Invoke(args));
+ result->Add(function->Invoke({ item }));
}
return result;
ObjectLock olock(self);
for (size_t i = 1; i < self->GetLength(); i++) {
- std::vector<Value> args;
- args.push_back(result);
- args.push_back(self->Get(i));
- result = function->Invoke(args);
+ result = function->Invoke({ result, self->Get(i) });
}
return result;
ObjectLock olock(self);
for (const Value& item : self) {
- std::vector<Value> args;
- args.push_back(item);
- if (function->Invoke(args))
+ if (function->Invoke({ item }))
result->Add(item);
}
ObjectLock olock(self);
for (const Value& item : self) {
- std::vector<Value> args;
- args.push_back(item);
- if (function->Invoke(args))
+ if (function->Invoke({ item }))
return true;
}
ObjectLock olock(self);
for (const Value& item : self) {
- std::vector<Value> args;
- args.push_back(item);
- if (!function->Invoke(args))
+ if (!function->Invoke({ item }))
return false;
}
{
ObjectLock olock(this);
- m_Data.push_back(std::move(value));
+ m_Data.emplace_back(std::move(value));
}
/**
Function::Ptr self = static_cast<Function::Ptr>(vframe->Self);
std::vector<Value> uargs(args.begin() + 1, args.end());
- return self->Invoke(args[0], uargs);
+ return self->InvokeThis(args[0], uargs);
}
static Value FunctionCallV(const Value& thisArg, const Array::Ptr& args)
uargs = std::vector<Value>(args->Begin(), args->End());
}
- return self->Invoke(thisArg, uargs);
+ return self->InvokeThis(thisArg, uargs);
}
return m_Callback(arguments);
}
-Value Function::Invoke(const Value& otherThis, const std::vector<Value>& arguments)
+Value Function::InvokeThis(const Value& otherThis, const std::vector<Value>& arguments)
{
ScriptFrame frame;
frame.Self = otherThis;
{ }
Value Invoke(const std::vector<Value>& arguments = std::vector<Value>());
- Value Invoke(const Value& otherThis, const std::vector<Value>& arguments = std::vector<Value>());
+ Value InvokeThis(const Value& otherThis, const std::vector<Value>& arguments = std::vector<Value>());
inline bool IsSideEffectFree(void) const
{
event.LifesupportReference = event.Descriptor.LifesupportObject;
VERIFY(event.LifesupportReference);
- events.push_back(event);
+ events.emplace_back(std::move(event));
}
}
event.LifesupportReference = event.Descriptor.LifesupportObject;
VERIFY(event.LifesupportReference);
- events.push_back(event);
+ events.emplace_back(std::move(event));
}
}
if (policy == LowLatencyScheduler)
queue.SpawnWorker(m_ThreadGroup);
- queue.Items.push_back(wi);
+ queue.Items.emplace_back(std::move(wi));
queue.CV.notify_one();
}
static void InvokeAttributeHandlerHelper(const Function::Ptr& callback,
const Object::Ptr& object, const Value& cookie)
{
- std::vector<Value> arguments;
- arguments.push_back(object);
- callback->Invoke(arguments);
+ callback->Invoke({ object });
}
static void TypeRegisterAttributeHandler(const String& fieldName, const Function::Ptr& callback)
if (duration >= 86400) {
int days = duration / 86400;
- tokens.push_back(Convert::ToString(days) + (days != 1 ? " days" : " day"));
+ tokens.emplace_back(Convert::ToString(days) + (days != 1 ? " days" : " day"));
duration = static_cast<int>(duration) % 86400;
}
if (duration >= 3600) {
int hours = duration / 3600;
- tokens.push_back(Convert::ToString(hours) + (hours != 1 ? " hours" : " hour"));
+ tokens.emplace_back(Convert::ToString(hours) + (hours != 1 ? " hours" : " hour"));
duration = static_cast<int>(duration) % 3600;
}
if (duration >= 60) {
int minutes = duration / 60;
- tokens.push_back(Convert::ToString(minutes) + (minutes != 1 ? " minutes" : " minute"));
+ tokens.emplace_back(Convert::ToString(minutes) + (minutes != 1 ? " minutes" : " minute"));
duration = static_cast<int>(duration) % 60;
}
if (duration >= 1) {
int seconds = duration;
- tokens.push_back(Convert::ToString(seconds) + (seconds != 1 ? " seconds" : " second"));
+ tokens.emplace_back(Convert::ToString(seconds) + (seconds != 1 ? " seconds" : " second"));
}
if (tokens.size() == 0) {
int milliseconds = std::floor(duration * 1000);
if (milliseconds >= 1)
- tokens.push_back(Convert::ToString(milliseconds) + (milliseconds != 1 ? " milliseconds" : " millisecond"));
+ tokens.emplace_back(Convert::ToString(milliseconds) + (milliseconds != 1 ? " milliseconds" : " millisecond"));
else
tokens.push_back("less than 1 millisecond");
}
Utility::CopyFile(ca, target_ca);
/* fix permissions: root -> icinga daemon user */
- std::vector<String> files;
- files.push_back(ca_path);
- files.push_back(ca);
- files.push_back(ca_key);
- files.push_back(target_ca);
- files.push_back(key);
- files.push_back(csr);
- files.push_back(cert);
-
- for (const String& file : files) {
+ for (const String& file : { ca_path, ca, ca_key, target_ca, key, csr, cert }) {
if (!Utility::SetFileOwnership(file, user, group)) {
Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << file << "'.";
{
Log(LogInformation, "cli", "Enabling the 'api' feature.");
- std::vector<std::string> features;
- features.push_back("api");
- FeatureUtility::EnableFeatures(features);
+ FeatureUtility::EnableFeatures({ "api" });
return true;
}
std::vector<std::string> configs;
if (vm.count("config") > 0)
- configs = vm["config"].as < std::vector<std::string> >() ;
+ configs = vm["config"].as<std::vector<std::string> >();
else if (!vm.count("no-config"))
configs.push_back(Application::GetSysconfDir() + "/icinga2/icinga2.conf");
bool TroubleshootCommand::CheckConfig(void)
{
- std::vector<std::string> configs;
- configs.push_back(Application::GetSysconfDir() + "/icinga2/icinga2.conf");
-
- return DaemonUtility::ValidateConfigFiles(configs, Application::GetObjectsPath());
+ return DaemonUtility::ValidateConfigFiles({ Application::GetSysconfDir() + "/icinga2/icinga2.conf" }, Application::GetObjectsPath());
}
//print is supposed allow the user to print the object file
for (const Service::Ptr& service : sg->GetMembers()) {
Host::Ptr host = service->GetHost();
- sglist.push_back(host->GetName());
- sglist.push_back(service->GetShortName());
+ sglist.emplace_back(host->GetName());
+ sglist.emplace_back(service->GetShortName());
}
DumpStringList(tempobjectfp, sglist);
int state_filter = dep->GetStateFilter();
std::vector<String> failure_criteria;
if (state_filter & StateFilterOK || state_filter & StateFilterUp)
- failure_criteria.push_back("o");
+ failure_criteria.emplace_back("o");
if (state_filter & StateFilterWarning)
- failure_criteria.push_back("w");
+ failure_criteria.emplace_back("w");
if (state_filter & StateFilterCritical)
- failure_criteria.push_back("c");
+ failure_criteria.emplace_back("c");
if (state_filter & StateFilterUnknown)
- failure_criteria.push_back("u");
+ failure_criteria.emplace_back("u");
if (state_filter & StateFilterDown)
- failure_criteria.push_back("d");
+ failure_criteria.emplace_back("d");
String criteria = boost::algorithm::join(failure_criteria, ",");
{
$$ = new std::vector<std::pair<Expression *, EItemInfo> >();
EItemInfo info = { true, @1 };
- $$->push_back(std::make_pair($1, info));
+ $$->emplace_back($1, info);
}
| rterm_no_side_effect
{
$$ = new std::vector<std::pair<Expression *, EItemInfo> >();
EItemInfo info = { false, @1 };
- $$->push_back(std::make_pair($1, info));
+ $$->emplace_back($1, info);
}
| lterm_items_inner sep lterm %dprec 1
{
if ($3) {
EItemInfo info = { true, @3 };
- $$->push_back(std::make_pair($3, info));
+ $$->emplace_back($3, info);
}
}
| lterm_items_inner sep rterm_no_side_effect %dprec 1
if ($3) {
EItemInfo info = { false, @3 };
- $$->push_back(std::make_pair($3, info));
+ $$->emplace_back($3, info);
}
}
;
if (kv2.second->m_ActivationContext != context)
continue;
- items.push_back(std::make_pair(kv2.second, false));
+ items.emplace_back(kv2.second, false);
}
}
if (item->m_Abstract || item->m_Object)
continue;
- items.push_back(std::make_pair(item, true));
+ items.emplace_back(item, true);
}
m_UnnamedItems.swap(newUnnamedItems);
static inline Value FunctionCall(ScriptFrame& frame, const Value& self, const Function::Ptr& func, const std::vector<Value>& arguments)
{
if (!self.IsEmpty() || self.IsString())
- return func->Invoke(self, arguments);
+ return func->InvokeThis(self, arguments);
else
return func->Invoke(arguments);
query1.Fields->Set("process_performance_data", (IcingaApplication::GetInstance()->GetEnablePerfdata() ? 1 : 0));
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
-
query1.Priority = PriorityHigh;
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
DbQuery query2;
query2.Type = DbQueryNewTransaction;
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
DbObject::OnMultipleQueries(queries);
}
query1.Category = DbCatComment;
query1.Fields = fields1;
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
}
void DbEvents::RemoveComment(const Comment::Ptr& comment)
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time));
query1.WhereCriteria->Set("name", comment->GetName());
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
/* History - update deletion time for service/host */
double now = Utility::GetTime();
query2.WhereCriteria->Set("object_id", checkable);
query2.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time));
query2.WhereCriteria->Set("name", comment->GetName());
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
}
/* downtimes */
query1.Category = DbCatDowntime;
query1.Fields = fields1;
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
/* host/service status */
if (!historical) {
query2.WhereCriteria->Set("host_object_id", host);
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
}
}
query1.WhereCriteria->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
query1.WhereCriteria->Set("scheduled_end_time", DbValue::FromTimestamp(downtime->GetEndTime()));
query1.WhereCriteria->Set("name", downtime->GetName());
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
/* History - update actual_end_time, was_cancelled for service (and host in case) */
double now = Utility::GetTime();
query3.WhereCriteria->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
query3.WhereCriteria->Set("scheduled_end_time", DbValue::FromTimestamp(downtime->GetEndTime()));
query3.WhereCriteria->Set("name", downtime->GetName());
-
- queries.push_back(query3);
+ queries.emplace_back(std::move(query3));
/* host/service status */
Host::Ptr host;
query4.WhereCriteria->Set("host_object_id", host);
query4.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
-
- queries.push_back(query4);
+ queries.emplace_back(std::move(query4));
}
void DbEvents::TriggerDowntime(const Downtime::Ptr& downtime)
fields2->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.Fields = fields2;
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
}
DbObject::OnMultipleQueries(queries);
query1.Category = DbCatConfig;
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", obj);
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
DbQuery query2;
query2.Table = "customvariablestatus";
query2.Category = DbCatConfig;
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("object_id", obj);
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
Dictionary::Ptr vars = CompatUtility::GetCustomAttributeConfig(custom_var_object);
query3.Type = DbQueryInsert;
query3.Category = DbCatConfig;
query3.Fields = fields;
-
- queries.push_back(query3);
+ queries.emplace_back(std::move(query3));
}
}
query.WhereCriteria = new Dictionary();
query.WhereCriteria->Set("object_id", obj);
query.WhereCriteria->Set("varname", kv.first);
-
- queries.push_back(query);
+ queries.emplace_back(std::move(query));
}
OnMultipleQueries(queries);
query1.Category = DbCatConfig;
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("host_object_id", host);
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
if (groups) {
ObjectLock olock(groups);
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.WhereCriteria->Set("hostgroup_id", DbValue::FromObjectInsertID(group));
query2.WhereCriteria->Set("host_object_id", host);
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
}
}
query2.Category = DbCatConfig;
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set(GetType()->GetTable() + "_id", DbValue::FromObjectInsertID(GetObject()));
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
/* parents */
for (const Checkable::Ptr& checkable : host->GetParents()) {
query1.Type = DbQueryInsert;
query1.Category = DbCatConfig;
query1.Fields = fields1;
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
}
DbObject::OnMultipleQueries(queries);
query3.Category = DbCatConfig;
query3.WhereCriteria = new Dictionary();
query3.WhereCriteria->Set("dependent_host_object_id", host);
-
- queries.push_back(query3);
+ queries.emplace_back(std::move(query3));
for (const Dependency::Ptr& dep : host->GetDependencies()) {
Checkable::Ptr parent = dep->GetParent();
query2.Type = DbQueryInsert;
query2.Category = DbCatConfig;
query2.Fields = fields2;
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
}
DbObject::OnMultipleQueries(queries);
query4.Category = DbCatConfig;
query4.WhereCriteria = new Dictionary();
query4.WhereCriteria->Set("host_id", DbValue::FromObjectInsertID(host));
-
- queries.push_back(query4);
+ queries.emplace_back(std::move(query4));
for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(host)) {
Log(LogDebug, "HostDbObject")
query_contact.Type = DbQueryInsert;
query_contact.Category = DbCatConfig;
query_contact.Fields = fields_contact;
-
- queries.push_back(query_contact);
+ queries.emplace_back(std::move(query_contact));
}
DbObject::OnMultipleQueries(queries);
query5.Category = DbCatConfig;
query5.WhereCriteria = new Dictionary();
query5.WhereCriteria->Set("host_id", DbValue::FromObjectInsertID(host));
-
- queries.push_back(query5);
+ queries.emplace_back(std::move(query5));
for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(host)) {
Log(LogDebug, "HostDbObject")
query_contact.Type = DbQueryInsert;
query_contact.Category = DbCatConfig;
query_contact.Fields = fields_contact;
-
- queries.push_back(query_contact);
+ queries.emplace_back(std::move(query_contact));
}
DbObject::OnMultipleQueries(queries);
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("command", commandObj));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("command", commandObj);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
String idoType = MacroProcessor::ResolveMacros("$ido_type$", resolvers, checkable->GetLastCheckResult(),
NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
query1.Category = DbCatConfig;
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("service_object_id", service);
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
if (groups) {
ObjectLock olock(groups);
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.WhereCriteria->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
query2.WhereCriteria->Set("service_object_id", service);
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
}
}
query2.Category = DbCatConfig;
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("dependent_service_object_id", service);
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
for (const Dependency::Ptr& dep : service->GetDependencies()) {
Checkable::Ptr parent = dep->GetParent();
query1.Type = DbQueryInsert;
query1.Category = DbCatConfig;
query1.Fields = fields1;
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
}
DbObject::OnMultipleQueries(queries);
query3.Category = DbCatConfig;
query3.WhereCriteria = new Dictionary();
query3.WhereCriteria->Set("service_id", DbValue::FromObjectInsertID(service));
-
- queries.push_back(query3);
+ queries.emplace_back(std::move(query3));
for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) {
Log(LogDebug, "ServiceDbObject")
query_contact.Type = DbQueryInsert;
query_contact.Category = DbCatConfig;
query_contact.Fields = fields_contact;
-
- queries.push_back(query_contact);
+ queries.emplace_back(std::move(query_contact));
}
DbObject::OnMultipleQueries(queries);
query4.Category = DbCatConfig;
query4.WhereCriteria = new Dictionary();
query4.WhereCriteria->Set("service_id", DbValue::FromObjectInsertID(service));
-
- queries.push_back(query4);
+ queries.emplace_back(std::move(query4));
for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) {
Log(LogDebug, "ServiceDbObject")
query_contact.Type = DbQueryInsert;
query_contact.Category = DbCatConfig;
query_contact.Fields = fields_contact;
-
- queries.push_back(query_contact);
+ queries.emplace_back(std::move(query_contact));
}
DbObject::OnMultipleQueries(queries);
query1.Category = DbCatConfig;
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("contact_object_id", user);
-
- queries.push_back(query1);
+ queries.emplace_back(std::move(query1));
if (groups) {
ObjectLock olock(groups);
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
query2.WhereCriteria->Set("contact_object_id", user);
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
}
}
query2.Category = DbCatConfig;
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("contact_id", DbValue::FromObjectInsertID(user));
-
- queries.push_back(query2);
+ queries.emplace_back(std::move(query2));
Dictionary::Ptr vars = user->GetVars();
query.Table = "contact_addresses";
query.Category = DbCatConfig;
query.Fields = fields;
-
- queries.push_back(query);
+ queries.emplace_back(std::move(query));
}
}
SetObjectActive(dbobj, active);
if (active)
- activeDbObjs.push_back(dbobj);
+ activeDbObjs.emplace_back(std::move(dbobj));
}
SetIDCacheValid(true);
* See https://github.com/Icinga/icinga2/issues/4603 for details.
*/
aq.Callback = callback;
- m_AsyncQueries.push_back(aq);
+ m_AsyncQueries.emplace_back(std::move(aq));
if (m_AsyncQueries.size() > 25000) {
FinishAsyncQueries();
void CheckCommand::Execute(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
- std::vector<Value> arguments;
- arguments.push_back(checkable);
- arguments.push_back(cr);
- arguments.push_back(resolvedMacros);
- arguments.push_back(useResolvedMacros);
- GetExecute()->Invoke(arguments);
+ GetExecute()->Invoke({
+ checkable,
+ cr,
+ resolvedMacros,
+ useResolvedMacros
+ });
}
void EventCommand::Execute(const Checkable::Ptr& checkable,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
- std::vector<Value> arguments;
- arguments.push_back(checkable);
- arguments.push_back(resolvedMacros);
- arguments.push_back(useResolvedMacros);
- GetExecute()->Invoke(arguments);
+ GetExecute()->Invoke({
+ checkable,
+ resolvedMacros,
+ useResolvedMacros
+ });
}
_1, std::cref(resolvers), cr, resolvedMacros, useResolvedMacros,
recursionLevel + 1)));
- std::vector<Value> args;
- return func->Invoke(resolvers_this, args);
+ return func->InvokeThis(resolvers_this);
}
Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverList& resolvers,
continue;
}
- args.push_back(arg);
+ args.emplace_back(std::move(arg));
}
std::sort(args.begin(), args.end());
const String& author, const String& comment, const Dictionary::Ptr& resolvedMacros,
bool useResolvedMacros)
{
- std::vector<Value> arguments;
- arguments.push_back(notification);
- arguments.push_back(user);
- arguments.push_back(cr);
- arguments.push_back(type);
- arguments.push_back(author);
- arguments.push_back(comment);
- arguments.push_back(resolvedMacros);
- arguments.push_back(useResolvedMacros);
- return GetExecute()->Invoke(arguments);
+ return GetExecute()->Invoke({
+ notification,
+ user,
+ cr,
+ type,
+ author,
+ comment,
+ resolvedMacros,
+ useResolvedMacros,
+ });
}
return;
}
- std::vector<Value> arguments;
- arguments.push_back(this);
- arguments.push_back(begin);
- arguments.push_back(end);
-
- Array::Ptr segments = GetUpdate()->Invoke(arguments);
+ Array::Ptr segments = GetUpdate()->Invoke({ this, begin, end });
{
ObjectLock olock(this);
if (!host)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "host", host },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(host->GetNotes(), resolvers, CheckResult::Ptr());
}
if (!host)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "host", host },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(host->GetNotesUrl(), resolvers);
}
if (!host)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "host", host },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(host->GetActionUrl(), resolvers);
}
if (!host)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "host", host },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(host->GetIconImage(), resolvers);
}
break;
}
- tokens.push_back(temp_buffer.SubStr(0, sp_index));
+ tokens.emplace_back(temp_buffer.SubStr(0, sp_index));
temp_buffer = temp_buffer.SubStr(sp_index + 1);
}
/* add the rest as value */
- tokens.push_back(temp_buffer);
+ tokens.emplace_back(std::move(temp_buffer));
if (tokens.size() == 2)
tokens.push_back("");
column_objs.reserve(columns.size());
for (const String& columnName : columns)
- column_objs.push_back(std::make_pair(columnName, table->GetColumn(columnName)));
+ column_objs.emplace_back(columnName, table->GetColumn(columnName));
for (const LivestatusRowValue& object : objects) {
Array::Ptr row = new Array();
for (const String& columnName : m_Columns) {
Column column = table->GetColumn(columnName);
- statsKey.push_back(column.ExtractValue(object.Row, object.GroupByType, object.GroupByObject));
+ statsKey.emplace_back(column.ExtractValue(object.Row, object.GroupByType, object.GroupByObject));
}
auto it = allStats.find(statsKey);
if (!service)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", service->GetHost()));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "service", service },
+ { "host", service->GetHost() },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(service->GetNotes(), resolvers);
}
if (!service)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", service->GetHost()));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "service", service },
+ { "host", service->GetHost() },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(service->GetNotesUrl(), resolvers);
}
if (!service)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", service->GetHost()));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "service", service },
+ { "host", service->GetHost() },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(service->GetActionUrl(), resolvers);
}
if (!service)
return Empty;
- MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", service->GetHost()));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ MacroProcessor::ResolverList resolvers {
+ { "service", service },
+ { "host", service->GetHost() },
+ { "icinga", IcingaApplication::GetInstance() }
+ };
return MacroProcessor::ResolveMacros(service->GetIconImage(), resolvers);
}
rval.GroupByType = groupByType;
rval.GroupByObject = groupByObject;
- rs.push_back(rval);
-
+ rs.emplace_back(std::move(rval));
}
return true;
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("command", commandObj));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("command", commandObj);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
Dictionary::Ptr envMacros = new Dictionary();
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("command", commandObj));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("command", commandObj);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult(),
NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("command", commandObj));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("command", commandObj);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
int dummyState = MacroProcessor::ResolveMacros("$dummy_state$", resolvers, checkable->GetLastCheckResult(),
NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("command", commandObj));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("command", commandObj);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(),
resolvers, resolvedMacros, useResolvedMacros,
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("command", commandObj));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("command", commandObj);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(),
resolvers, resolvedMacros, useResolvedMacros,
tie(host, service) = GetHostService(checkable);
MacroProcessor::ResolverList resolvers;
- resolvers.push_back(std::make_pair("user", user));
- resolvers.push_back(std::make_pair("notification", notificationExtra));
- resolvers.push_back(std::make_pair("notification", notification));
+ resolvers.emplace_back("user", user);
+ resolvers.emplace_back("notification", notificationExtra);
+ resolvers.emplace_back("notification", notification);
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("command", commandObj));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("command", commandObj);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
PluginUtility::ExecuteCommand(commandObj, checkable, cr, resolvers,
resolvedMacros, useResolvedMacros,
Log(LogDebug, "ElasticsearchWriter")
<< "Add to fields to message list: '" << fieldsBody << "'.";
- m_DataBuffer.push_back(indexBody + fieldsBody);
+ m_DataBuffer.emplace_back(indexBody + fieldsBody);
/* Flush if we've buffered too much to prevent excessive memory use. */
if (static_cast<int>(m_DataBuffer.size()) >= GetFlushThreshold()) {
/* Specify the index path. Best practice is a daily rotation.
* Example: http://localhost:9200/icinga2-2017.09.11?pretty=1
*/
- path.push_back(GetIndex() + "-" + Utility::FormatDateTime("%Y.%m.%d", Utility::GetTime()));
+ path.emplace_back(GetIndex() + "-" + Utility::FormatDateTime("%Y.%m.%d", Utility::GetTime()));
/* Use the bulk message format. */
- path.push_back("_bulk");
+ path.emplace_back("_bulk");
url->SetPath(path);
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
String prefix;
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
String prefix;
MacroProcessor::ResolverList resolvers;
if (service)
- resolvers.push_back(std::make_pair("service", service));
- resolvers.push_back(std::make_pair("host", host));
- resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+ resolvers.emplace_back("service", service);
+ resolvers.emplace_back("host", host);
+ resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
if (service) {
String line = MacroProcessor::ResolveMacros(GetServiceFormatTemplate(), resolvers, cr, NULL, &PerfdataWriter::EscapeMacroMetric);
type->Name = typeInfo->Get("name");
type->PluralName = typeInfo->Get("plural_name");
// TODO: attributes
- types.push_back(type);
+ types.emplace_back(std::move(type));
}
callback(boost::exception_ptr(), types);
ApiObjectReference ref;
ref.Name = refInfo->Get("name");
ref.Type = refInfo->Get("type");
- object->UsedBy.push_back(ref);
+ object->UsedBy.emplace_back(std::move(ref));
}
}
std::vector<String> names;
for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType<Endpoint>())
if (endpoint->GetConnected())
- names.push_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")");
+ names.emplace_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")");
Log(LogNotice, "ApiListener")
<< "Connected endpoints: " << Utility::NaturalJoin(names);
void ConfigPackageUtility::CollectDirNames(const String& path, std::vector<String>& dirs)
{
- String name = Utility::BaseName(path);
- dirs.push_back(name);
+ dirs.emplace_back(Utility::BaseName(path));
}
bool ConfigPackageUtility::PackageExists(const String& name)
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(path));
- paths.push_back(std::make_pair(path, S_ISDIR(statbuf.st_mode)));
+ paths.emplace_back(path, S_ISDIR(statbuf.st_mode));
#else /* _WIN32 */
struct _stat statbuf;
int rc = _stat(path.CStr(), &statbuf);
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(path));
- paths.push_back(std::make_pair(path, ((statbuf.st_mode & S_IFMT) == S_IFDIR)));
+ paths.emplace_back(path, ((statbuf.st_mode & S_IFMT) == S_IFDIR));
#endif /* _WIN32 */
}
if (!FilterUtility::EvaluateFilter(permissionFrame, permissionFilter, target, variableName))
BOOST_THROW_EXCEPTION(ScriptError("Access denied to object '" + name + "' of type '" + type + "'"));
- result.push_back(target);
+ result.emplace_back(std::move(target));
}
attr = provider->GetPluralName(type);
if (!FilterUtility::EvaluateFilter(permissionFrame, permissionFilter, target, variableName))
BOOST_THROW_EXCEPTION(ScriptError("Access denied to object '" + name + "' of type '" + type + "'"));
- result.push_back(target);
+ result.emplace_back(std::move(target));
}
}
}
void HttpClientConnection::SubmitRequest(const std::shared_ptr<HttpRequest>& request,
const HttpCompletionCallback& callback)
{
- m_Requests.push_back(std::make_pair(request, callback));
+ m_Requests.emplace_back(request, callback);
request->Finish();
}
if (current_handlers) {
ObjectLock olock(current_handlers);
- for (const HttpHandler::Ptr current_handler : current_handlers) {
+ for (const HttpHandler::Ptr& current_handler : current_handlers) {
handlers.push_back(current_handler);
}
}
void HttpResponse::AddHeader(const String& key, const String& value)
{
- m_Headers.push_back(key + ": " + value + "\r\n");
+ m_Headers.emplace_back(key + ": " + value + "\r\n");
}
void HttpResponse::FinishHeaders(void)
if (hasFilter)
name += " (filtered)";
- permInfo.push_back(name);
+ permInfo.emplace_back(std::move(name));
}
}
{
auto it = m_Query.find(name);
if (it == m_Query.end()) {
- m_Query[name] = std::vector<String>();
- m_Query[name].push_back(value);
+ m_Query[name] = std::vector<String> { value };
} else
m_Query[name].push_back(value);
}
if (!ValidateToken(token, ACPATHSEGMENT))
return false;
- String decodedToken = Utility::UnescapeString(token);
-
- m_Path.push_back(decodedToken);
+ m_Path.emplace_back(Utility::UnescapeString(token));
}
return true;
auto it = m_Query.find(key);
if (it == m_Query.end()) {
- m_Query[key] = std::vector<String>();
- m_Query[key].push_back(value);
+ m_Query[key] = std::vector<String> { std::move(value) };
} else
- m_Query[key].push_back(value);
-
+ m_Query[key].emplace_back(std::move(value));
}
return true;