Merge pull request #5825 from Icinga/feature/boost-assign

Replace boost::assign::list_of with initializer lists
This commit is contained in:
Michael Friedrich 2017-11-30 21:20:46 +01:00 committed by GitHub
commit a238613fdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 46 additions and 49 deletions

View File

@ -1565,5 +1565,5 @@ void Application::ValidateName(const String& value, const ValidationUtils& utils
ObjectImpl<Application>::ValidateName(value, utils); ObjectImpl<Application>::ValidateName(value, utils);
if (value != "app") if (value != "app")
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("name"), "Application object must be named 'app'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "name" }, "Application object must be named 'app'."));
} }

View File

@ -220,6 +220,6 @@ void Logger::ValidateSeverity(const String& value, const ValidationUtils& utils)
try { try {
StringToSeverity(value); StringToSeverity(value);
} catch (...) { } catch (...) {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("severity"), "Invalid severity specified: " + value)); BOOST_THROW_EXCEPTION(ValidationError(this, { "severity" }, "Invalid severity specified: " + value));
} }
} }

View File

@ -111,7 +111,7 @@ void SyslogLogger::ValidateFacility(const String& value, const ValidationUtils&
try { try {
Convert::ToLong(value); Convert::ToLong(value);
} catch (const std::exception&) { } catch (const std::exception&) {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("facility"), "Invalid facility specified.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "facility" }, "Invalid facility specified."));
} }
} }
} }

View File

@ -604,6 +604,6 @@ void CompatLogger::ValidateRotationMethod(const String& value, const ValidationU
if (value != "HOURLY" && value != "DAILY" && if (value != "HOURLY" && value != "DAILY" &&
value != "WEEKLY" && value != "MONTHLY" && value != "NONE") { value != "WEEKLY" && value != "MONTHLY" && value != "NONE") {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("rotation_method"), "Rotation method '" + value + "' is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "rotation_method" }, "Rotation method '" + value + "' is invalid."));
} }
} }

View File

@ -449,7 +449,7 @@ void DbConnection::ValidateFailoverTimeout(double value, const ValidationUtils&
ObjectImpl<DbConnection>::ValidateFailoverTimeout(value, utils); ObjectImpl<DbConnection>::ValidateFailoverTimeout(value, utils);
if (value < 60) if (value < 60)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("failover_timeout"), "Failover timeout minimum is 60s.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "failover_timeout" }, "Failover timeout minimum is 60s."));
} }
void DbConnection::ValidateCategories(const Array::Ptr& value, const ValidationUtils& utils) void DbConnection::ValidateCategories(const Array::Ptr& value, const ValidationUtils& utils)
@ -462,7 +462,7 @@ void DbConnection::ValidateCategories(const Array::Ptr& value, const ValidationU
DbCatAcknowledgement | DbCatComment | DbCatDowntime | DbCatEventHandler | DbCatExternalCommand | DbCatAcknowledgement | DbCatComment | DbCatDowntime | DbCatEventHandler | DbCatExternalCommand |
DbCatFlapping | DbCatLog | DbCatNotification | DbCatProgramStatus | DbCatRetention | DbCatFlapping | DbCatLog | DbCatNotification | DbCatProgramStatus | DbCatRetention |
DbCatStateHistory)) != 0) DbCatStateHistory)) != 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("categories"), "categories filter is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "categories" }, "categories filter is invalid."));
} }
void DbConnection::IncreaseQueryCount(void) void DbConnection::IncreaseQueryCount(void)

View File

@ -64,7 +64,7 @@ void Checkable::OnAllConfigLoaded(void)
Zone::Ptr cmdZone = endpoint->GetZone(); Zone::Ptr cmdZone = endpoint->GetZone();
if (checkableZone && cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) { if (checkableZone && cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("command_endpoint"), BOOST_THROW_EXCEPTION(ValidationError(this, { "command_endpoint" },
"Command endpoint must be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof.")); "Command endpoint must be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof."));
} }
} }
@ -193,7 +193,7 @@ void Checkable::ValidateCheckInterval(double value, const ValidationUtils& utils
ObjectImpl<Checkable>::ValidateCheckInterval(value, utils); ObjectImpl<Checkable>::ValidateCheckInterval(value, utils);
if (value <= 0) if (value <= 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("check_interval"), "Interval must be greater than 0.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "check_interval" }, "Interval must be greater than 0."));
} }
void Checkable::ValidateMaxCheckAttempts(int value, const ValidationUtils& utils) void Checkable::ValidateMaxCheckAttempts(int value, const ValidationUtils& utils)
@ -201,5 +201,5 @@ void Checkable::ValidateMaxCheckAttempts(int value, const ValidationUtils& utils
ObjectImpl<Checkable>::ValidateMaxCheckAttempts(value, utils); ObjectImpl<Checkable>::ValidateMaxCheckAttempts(value, utils);
if (value <= 0) if (value <= 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("max_check_attempts"), "Value must be greater than 0.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "max_check_attempts" }, "Value must be greater than 0."));
} }

View File

@ -38,7 +38,7 @@ void Command::Validate(int types, const ValidationUtils& utils)
if (arguments) { if (arguments) {
if (!GetCommandLine().IsObjectType<Array>()) if (!GetCommandLine().IsObjectType<Array>())
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("command"), "Attribute 'command' must be an array if the 'arguments' attribute is set.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "command" }, "Attribute 'command' must be an array if the 'arguments' attribute is set."));
ObjectLock olock(arguments); ObjectLock olock(arguments);
for (const Dictionary::Pair& kv : arguments) { for (const Dictionary::Pair& kv : arguments) {
@ -52,18 +52,18 @@ void Command::Validate(int types, const ValidationUtils& utils)
Value argvalue = argdict->Get("value"); Value argvalue = argdict->Get("value");
if (argvalue.IsString() && !MacroProcessor::ValidateMacroString(argvalue)) if (argvalue.IsString() && !MacroProcessor::ValidateMacroString(argvalue))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of<String>("arguments")(kv.first)("value"), "Validation failed: Closing $ not found in macro format string '" + argvalue + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "arguments", kv.first, "value" }, "Validation failed: Closing $ not found in macro format string '" + argvalue + "'."));
} }
if (argdict->Contains("set_if")) { if (argdict->Contains("set_if")) {
Value argsetif = argdict->Get("set_if"); Value argsetif = argdict->Get("set_if");
if (argsetif.IsString() && !MacroProcessor::ValidateMacroString(argsetif)) if (argsetif.IsString() && !MacroProcessor::ValidateMacroString(argsetif))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of<String>("arguments")(kv.first)("set_if"), "Closing $ not found in macro format string '" + argsetif + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "arguments", kv.first, "set_if" }, "Closing $ not found in macro format string '" + argsetif + "'."));
} }
} else if (arginfo.IsString()) { } else if (arginfo.IsString()) {
if (!MacroProcessor::ValidateMacroString(arginfo)) if (!MacroProcessor::ValidateMacroString(arginfo))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of<String>("arguments")(kv.first), "Closing $ not found in macro format string '" + arginfo + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "arguments", kv.first }, "Closing $ not found in macro format string '" + arginfo + "'."));
} }
} }
} }
@ -79,7 +79,7 @@ void Command::Validate(int types, const ValidationUtils& utils)
continue; continue;
if (!MacroProcessor::ValidateMacroString(envval)) if (!MacroProcessor::ValidateMacroString(envval))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of<String>("env")(kv.first), "Closing $ not found in macro format string '" + envval + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "env", kv.first }, "Closing $ not found in macro format string '" + envval + "'."));
} }
} }
} }

View File

@ -216,9 +216,9 @@ void Dependency::ValidateStates(const Array::Ptr& value, const ValidationUtils&
int sfilter = FilterArrayToInt(value, Notification::GetStateFilterMap(), 0); int sfilter = FilterArrayToInt(value, Notification::GetStateFilterMap(), 0);
if (GetParentServiceName().IsEmpty() && (sfilter & ~(StateFilterUp | StateFilterDown)) != 0) if (GetParentServiceName().IsEmpty() && (sfilter & ~(StateFilterUp | StateFilterDown)) != 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("states"), "State filter is invalid for host dependency.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "states" }, "State filter is invalid for host dependency."));
if (!GetParentServiceName().IsEmpty() && (sfilter & ~(StateFilterOK | StateFilterWarning | StateFilterCritical | StateFilterUnknown)) != 0) if (!GetParentServiceName().IsEmpty() && (sfilter & ~(StateFilterOK | StateFilterWarning | StateFilterCritical | StateFilterUnknown)) != 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("states"), "State filter is invalid for service dependency.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "states" }, "State filter is invalid for service dependency."));
} }

View File

@ -414,7 +414,7 @@ void Downtime::ValidateStartTime(const Timestamp& value, const ValidationUtils&
ObjectImpl<Downtime>::ValidateStartTime(value, utils); ObjectImpl<Downtime>::ValidateStartTime(value, utils);
if (value <= 0) if (value <= 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("start_time"), "Start time must be greater than 0.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "start_time" }, "Start time must be greater than 0."));
} }
void Downtime::ValidateEndTime(const Timestamp& value, const ValidationUtils& utils) void Downtime::ValidateEndTime(const Timestamp& value, const ValidationUtils& utils)
@ -422,5 +422,5 @@ void Downtime::ValidateEndTime(const Timestamp& value, const ValidationUtils& ut
ObjectImpl<Downtime>::ValidateEndTime(value, utils); ObjectImpl<Downtime>::ValidateEndTime(value, utils);
if (value <= 0) if (value <= 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("end_time"), "End time must be greater than 0.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "end_time" }, "End time must be greater than 0."));
} }

View File

@ -28,7 +28,6 @@
#include "base/scriptframe.hpp" #include "base/scriptframe.hpp"
#include "base/convert.hpp" #include "base/convert.hpp"
#include "base/exception.hpp" #include "base/exception.hpp"
#include <boost/assign.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
@ -375,7 +374,7 @@ void MacroProcessor::ValidateCustomVars(const ConfigObject::Ptr& object, const D
continue; continue;
if (!ValidateMacroString(kv_var.second)) if (!ValidateMacroString(kv_var.second))
BOOST_THROW_EXCEPTION(ValidationError(object.get(), boost::assign::list_of<String>("vars")(kv.first)(kv_var.first), "Closing $ not found in macro format string '" + kv_var.second + "'.")); BOOST_THROW_EXCEPTION(ValidationError(object.get(), { "vars", kv.first, kv_var.first }, "Closing $ not found in macro format string '" + kv_var.second + "'."));
} }
} else if (varval.IsObjectType<Array>()) { } else if (varval.IsObjectType<Array>()) {
/* check all array entries */ /* check all array entries */
@ -387,7 +386,7 @@ void MacroProcessor::ValidateCustomVars(const ConfigObject::Ptr& object, const D
continue; continue;
if (!ValidateMacroString(arrval)) { if (!ValidateMacroString(arrval)) {
BOOST_THROW_EXCEPTION(ValidationError(object.get(), boost::assign::list_of<String>("vars")(kv.first), "Closing $ not found in macro format string '" + arrval + "'.")); BOOST_THROW_EXCEPTION(ValidationError(object.get(), { "vars", kv.first }, "Closing $ not found in macro format string '" + arrval + "'."));
} }
} }
} else { } else {
@ -395,7 +394,7 @@ void MacroProcessor::ValidateCustomVars(const ConfigObject::Ptr& object, const D
continue; continue;
if (!ValidateMacroString(varval)) if (!ValidateMacroString(varval))
BOOST_THROW_EXCEPTION(ValidationError(object.get(), boost::assign::list_of<String>("vars")(kv.first), "Closing $ not found in macro format string '" + varval + "'.")); BOOST_THROW_EXCEPTION(ValidationError(object.get(), { "vars", kv.first }, "Closing $ not found in macro format string '" + varval + "'."));
} }
} }
} }

View File

@ -649,10 +649,10 @@ void Notification::ValidateStates(const Array::Ptr& value, const ValidationUtils
int filter = FilterArrayToInt(value, GetStateFilterMap(), 0); int filter = FilterArrayToInt(value, GetStateFilterMap(), 0);
if (GetServiceName().IsEmpty() && (filter == -1 || (filter & ~(StateFilterUp | StateFilterDown)) != 0)) if (GetServiceName().IsEmpty() && (filter == -1 || (filter & ~(StateFilterUp | StateFilterDown)) != 0))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("states"), "State filter is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "states" }, "State filter is invalid."));
if (!GetServiceName().IsEmpty() && (filter == -1 || (filter & ~(StateFilterOK | StateFilterWarning | StateFilterCritical | StateFilterUnknown)) != 0)) if (!GetServiceName().IsEmpty() && (filter == -1 || (filter & ~(StateFilterOK | StateFilterWarning | StateFilterCritical | StateFilterUnknown)) != 0))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("states"), "State filter is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "states" }, "State filter is invalid."));
} }
void Notification::ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils) void Notification::ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils)
@ -664,7 +664,7 @@ void Notification::ValidateTypes(const Array::Ptr& value, const ValidationUtils&
if (filter == -1 || (filter & ~(NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved | if (filter == -1 || (filter & ~(NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved |
NotificationCustom | NotificationAcknowledgement | NotificationProblem | NotificationRecovery | NotificationCustom | NotificationAcknowledgement | NotificationProblem | NotificationRecovery |
NotificationFlappingStart | NotificationFlappingEnd)) != 0) NotificationFlappingStart | NotificationFlappingEnd)) != 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("types"), "Type filter is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "types" }, "Type filter is invalid."));
} }
Endpoint::Ptr Notification::GetCommandEndpoint(void) const Endpoint::Ptr Notification::GetCommandEndpoint(void) const

View File

@ -215,13 +215,13 @@ void ScheduledDowntime::ValidateRanges(const Dictionary::Ptr& value, const Valid
int stride; int stride;
LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference); LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("ranges"), "Invalid time specification '" + kv.first + "': " + ex.what())); BOOST_THROW_EXCEPTION(ValidationError(this, { "ranges" }, "Invalid time specification '" + kv.first + "': " + ex.what()));
} }
try { try {
LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments); LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("ranges"), "Invalid time range definition '" + kv.second + "': " + ex.what())); BOOST_THROW_EXCEPTION(ValidationError(this, { "ranges" }, "Invalid time range definition '" + kv.second + "': " + ex.what()));
} }
} }
} }

View File

@ -398,13 +398,13 @@ void TimePeriod::ValidateRanges(const Dictionary::Ptr& value, const ValidationUt
int stride; int stride;
LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference); LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("ranges"), "Invalid time specification '" + kv.first + "': " + ex.what())); BOOST_THROW_EXCEPTION(ValidationError(this, { "ranges" }, "Invalid time specification '" + kv.first + "': " + ex.what()));
} }
try { try {
LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments); LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("ranges"), "Invalid time range definition '" + kv.second + "': " + ex.what())); BOOST_THROW_EXCEPTION(ValidationError(this, { "ranges" }, "Invalid time range definition '" + kv.second + "': " + ex.what()));
} }
} }
} }

View File

@ -104,7 +104,7 @@ void User::ValidateStates(const Array::Ptr& value, const ValidationUtils& utils)
int filter = FilterArrayToInt(value, Notification::GetStateFilterMap(), 0); int filter = FilterArrayToInt(value, Notification::GetStateFilterMap(), 0);
if (filter == -1 || (filter & ~(StateFilterUp | StateFilterDown | StateFilterOK | StateFilterWarning | StateFilterCritical | StateFilterUnknown)) != 0) if (filter == -1 || (filter & ~(StateFilterUp | StateFilterDown | StateFilterOK | StateFilterWarning | StateFilterCritical | StateFilterUnknown)) != 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("states"), "State filter is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "states" }, "State filter is invalid."));
} }
void User::ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils) void User::ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils)
@ -116,5 +116,5 @@ void User::ValidateTypes(const Array::Ptr& value, const ValidationUtils& utils)
if (filter == -1 || (filter & ~(NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved | if (filter == -1 || (filter & ~(NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved |
NotificationCustom | NotificationAcknowledgement | NotificationProblem | NotificationRecovery | NotificationCustom | NotificationAcknowledgement | NotificationProblem | NotificationRecovery |
NotificationFlappingStart | NotificationFlappingEnd)) != 0) NotificationFlappingStart | NotificationFlappingEnd)) != 0)
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("types"), "Type filter is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "types" }, "Type filter is invalid."));
} }

View File

@ -225,5 +225,5 @@ void LivestatusListener::ValidateSocketType(const String& value, const Validatio
ObjectImpl<LivestatusListener>::ValidateSocketType(value, utils); ObjectImpl<LivestatusListener>::ValidateSocketType(value, utils);
if (value != "unix" && value != "tcp") if (value != "unix" && value != "tcp")
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("socket_type"), "Socket type '" + value + "' is invalid.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "socket_type" }, "Socket type '" + value + "' is invalid."));
} }

View File

@ -350,7 +350,7 @@ void GraphiteWriter::ValidateHostNameTemplate(const String& value, const Validat
ObjectImpl<GraphiteWriter>::ValidateHostNameTemplate(value, utils); ObjectImpl<GraphiteWriter>::ValidateHostNameTemplate(value, utils);
if (!MacroProcessor::ValidateMacroString(value)) if (!MacroProcessor::ValidateMacroString(value))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("host_name_template"), "Closing $ not found in macro format string '" + value + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "host_name_template" }, "Closing $ not found in macro format string '" + value + "'."));
} }
void GraphiteWriter::ValidateServiceNameTemplate(const String& value, const ValidationUtils& utils) void GraphiteWriter::ValidateServiceNameTemplate(const String& value, const ValidationUtils& utils)
@ -358,5 +358,5 @@ void GraphiteWriter::ValidateServiceNameTemplate(const String& value, const Vali
ObjectImpl<GraphiteWriter>::ValidateServiceNameTemplate(value, utils); ObjectImpl<GraphiteWriter>::ValidateServiceNameTemplate(value, utils);
if (!MacroProcessor::ValidateMacroString(value)) if (!MacroProcessor::ValidateMacroString(value))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("service_name_template"), "Closing $ not found in macro format string '" + value + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "service_name_template" }, "Closing $ not found in macro format string '" + value + "'."));
} }

View File

@ -514,14 +514,14 @@ void InfluxdbWriter::ValidateHostTemplate(const Dictionary::Ptr& value, const Va
String measurement = value->Get("measurement"); String measurement = value->Get("measurement");
if (!MacroProcessor::ValidateMacroString(measurement)) if (!MacroProcessor::ValidateMacroString(measurement))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("host_template")("measurement"), "Closing $ not found in macro format string '" + measurement + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "host_template", "measurement" }, "Closing $ not found in macro format string '" + measurement + "'."));
Dictionary::Ptr tags = value->Get("tags"); Dictionary::Ptr tags = value->Get("tags");
if (tags) { if (tags) {
ObjectLock olock(tags); ObjectLock olock(tags);
for (const Dictionary::Pair& pair : tags) { for (const Dictionary::Pair& pair : tags) {
if (!MacroProcessor::ValidateMacroString(pair.second)) if (!MacroProcessor::ValidateMacroString(pair.second))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of<String>("host_template")("tags")(pair.first), "Closing $ not found in macro format string '" + pair.second)); BOOST_THROW_EXCEPTION(ValidationError(this, { "host_template", "tags", pair.first }, "Closing $ not found in macro format string '" + pair.second));
} }
} }
} }
@ -532,14 +532,14 @@ void InfluxdbWriter::ValidateServiceTemplate(const Dictionary::Ptr& value, const
String measurement = value->Get("measurement"); String measurement = value->Get("measurement");
if (!MacroProcessor::ValidateMacroString(measurement)) if (!MacroProcessor::ValidateMacroString(measurement))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("service_template")("measurement"), "Closing $ not found in macro format string '" + measurement + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "service_template", "measurement" }, "Closing $ not found in macro format string '" + measurement + "'."));
Dictionary::Ptr tags = value->Get("tags"); Dictionary::Ptr tags = value->Get("tags");
if (tags) { if (tags) {
ObjectLock olock(tags); ObjectLock olock(tags);
for (const Dictionary::Pair& pair : tags) { for (const Dictionary::Pair& pair : tags) {
if (!MacroProcessor::ValidateMacroString(pair.second)) if (!MacroProcessor::ValidateMacroString(pair.second))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of<String>("service_template")("tags")(pair.first), "Closing $ not found in macro format string '" + pair.second)); BOOST_THROW_EXCEPTION(ValidationError(this, { "service_template", "tags", pair.first }, "Closing $ not found in macro format string '" + pair.second));
} }
} }
} }

View File

@ -163,7 +163,7 @@ void PerfdataWriter::ValidateHostFormatTemplate(const String& value, const Valid
ObjectImpl<PerfdataWriter>::ValidateHostFormatTemplate(value, utils); ObjectImpl<PerfdataWriter>::ValidateHostFormatTemplate(value, utils);
if (!MacroProcessor::ValidateMacroString(value)) if (!MacroProcessor::ValidateMacroString(value))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("host_format_template"), "Closing $ not found in macro format string '" + value + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "host_format_template" }, "Closing $ not found in macro format string '" + value + "'."));
} }
void PerfdataWriter::ValidateServiceFormatTemplate(const String& value, const ValidationUtils& utils) void PerfdataWriter::ValidateServiceFormatTemplate(const String& value, const ValidationUtils& utils)
@ -171,5 +171,5 @@ void PerfdataWriter::ValidateServiceFormatTemplate(const String& value, const Va
ObjectImpl<PerfdataWriter>::ValidateServiceFormatTemplate(value, utils); ObjectImpl<PerfdataWriter>::ValidateServiceFormatTemplate(value, utils);
if (!MacroProcessor::ValidateMacroString(value)) if (!MacroProcessor::ValidateMacroString(value))
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("service_format_template"), "Closing $ not found in macro format string '" + value + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "service_format_template" }, "Closing $ not found in macro format string '" + value + "'."));
} }

View File

@ -1413,7 +1413,7 @@ void ApiListener::ValidateTlsProtocolmin(const String& value, const ValidationUt
message += ", '" SSL_TXT_TLSV1_1 "' or '" SSL_TXT_TLSV1_2 "'"; message += ", '" SSL_TXT_TLSV1_1 "' or '" SSL_TXT_TLSV1_2 "'";
#endif /* SSL_TXT_TLSV1_1 */ #endif /* SSL_TXT_TLSV1_1 */
BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("tls_protocolmin"), message)); BOOST_THROW_EXCEPTION(ValidationError(this, { "tls_protocolmin" }, message));
} }
} }

View File

@ -20,7 +20,6 @@
#include "base/array.hpp" #include "base/array.hpp"
#include "remote/url.hpp" #include "remote/url.hpp"
#include <BoostTestTargetConfig.h> #include <BoostTestTargetConfig.h>
#include <boost/assign/list_of.hpp>
using namespace icinga; using namespace icinga;
@ -50,17 +49,16 @@ BOOST_AUTO_TEST_CASE(get_and_set)
url->SetPassword("Seehofer"); url->SetPassword("Seehofer");
url->SetHost("koenigreich.bayern"); url->SetHost("koenigreich.bayern");
url->SetPort("1918"); url->SetPort("1918");
std::vector<String> p = boost::assign::list_of("path")("to")("münchen"); url->SetPath({ "path", "to", "münchen" });
url->SetPath(p);
BOOST_CHECK(url->Format(false, true) == "ftp://Horst:Seehofer@koenigreich.bayern:1918/path/to/m%C3%BCnchen"); BOOST_CHECK(url->Format(false, true) == "ftp://Horst:Seehofer@koenigreich.bayern:1918/path/to/m%C3%BCnchen");
std::map<String, std::vector<String> > m; std::map<String, std::vector<String> > m;
std::vector<String> v1 = boost::assign::list_of("hip")("hip")("hurra"); std::vector<String> v1 { "hip", "hip", "hurra" };
std::vector<String> v2 = boost::assign::list_of("äü^ä+#ül-"); std::vector<String> v2 { "äü^ä+#ül-" };
std::vector<String> v3 = boost::assign::list_of("1")("2"); std::vector<String> v3 { "1", "2" };
m.insert(std::pair<String, std::vector<String> >("shout", v1)); m.emplace("shout", v1);
m.insert(std::pair<String, std::vector<String> >("sonderzeichen", v2)); m.emplace("sonderzeichen", v2);
url->SetQuery(m); url->SetQuery(m);
url->SetQueryElements("count", v3); url->SetQueryElements("count", v3);
url->AddQueryElement("count", "3"); url->AddQueryElement("count", "3");