Replace boost::ref/boost::cref with std::ref/std::cref

This commit is contained in:
Gunnar Beutner 2017-11-23 06:51:48 +01:00
parent df8266631d
commit 9ce950b0f1
18 changed files with 38 additions and 39 deletions

View File

@ -477,7 +477,7 @@ Value ScriptUtils::Glob(const std::vector<Value>& args)
type = args[1];
std::vector<String> paths;
Utility::Glob(pathSpec, std::bind(&GlobCallbackHelper, boost::ref(paths), _1), type);
Utility::Glob(pathSpec, std::bind(&GlobCallbackHelper, std::ref(paths), _1), type);
return Array::FromVector(paths);
}
@ -496,7 +496,7 @@ Value ScriptUtils::GlobRecursive(const std::vector<Value>& args)
type = args[2];
std::vector<String> paths;
Utility::GlobRecursive(path, pattern, std::bind(&GlobCallbackHelper, boost::ref(paths), _1), type);
Utility::GlobRecursive(path, pattern, std::bind(&GlobCallbackHelper, std::ref(paths), _1), type);
return Array::FromVector(paths);
}

View File

@ -23,7 +23,6 @@
#include "base/utility.hpp"
#include "base/exception.hpp"
#include "base/application.hpp"
#include <boost/bind.hpp>
#include <iostream>
using namespace icinga;
@ -337,7 +336,7 @@ void ThreadPool::Queue::SpawnWorker(boost::thread_group& group)
Log(LogDebug, "ThreadPool", "Spawning worker thread.");
Threads[i] = WorkerThread(ThreadIdle);
Threads[i].Thread = group.create_thread(boost::bind(&ThreadPool::WorkerThread::ThreadProc, boost::ref(Threads[i]), boost::ref(*this)));
Threads[i].Thread = group.create_thread(std::bind(&ThreadPool::WorkerThread::ThreadProc, std::ref(Threads[i]), std::ref(*this)));
break;
}

View File

@ -770,7 +770,7 @@ void Utility::MkDirP(const String& path, int mode)
void Utility::RemoveDirRecursive(const String& path)
{
std::vector<String> paths;
Utility::GlobRecursive(path, "*", std::bind(&Utility::CollectPaths, _1, boost::ref(paths)), GlobFile | GlobDirectory);
Utility::GlobRecursive(path, "*", std::bind(&Utility::CollectPaths, _1, std::ref(paths)), GlobFile | GlobDirectory);
/* This relies on the fact that GlobRecursive lists the parent directory
first before recursing into subdirectories. */

View File

@ -196,9 +196,9 @@ char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state)
l_ApiClient->AutocompleteScript(l_Session, word, l_ScriptFrame->Sandboxed,
std::bind(&ConsoleCommand::AutocompleteScriptCompletionHandler,
boost::ref(mutex), boost::ref(cv), boost::ref(ready),
std::ref(mutex), std::ref(cv), std::ref(ready),
_1, _2,
boost::ref(suggestions)));
std::ref(suggestions)));
{
boost::mutex::scoped_lock lock(mutex);
@ -426,9 +426,9 @@ incomplete:
l_ApiClient->ExecuteScript(l_Session, command, scriptFrame.Sandboxed,
std::bind(&ConsoleCommand::ExecuteScriptCompletionHandler,
boost::ref(mutex), boost::ref(cv), boost::ref(ready),
std::ref(mutex), std::ref(cv), std::ref(ready),
_1, _2,
boost::ref(result), boost::ref(eptr)));
std::ref(result), std::ref(eptr)));
{
boost::mutex::scoped_lock lock(mutex);

View File

@ -52,7 +52,7 @@ static void IncludeZoneDirRecursive(const String& path, const String& package, b
ConfigCompiler::RegisterZoneDir("_etc", path, zoneName);
std::vector<Expression *> expressions;
Utility::GlobRecursive(path, "*.conf", std::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, package), GlobFile);
Utility::GlobRecursive(path, "*.conf", std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zoneName, package), GlobFile);
DictExpression expr(expressions);
if (!ExecuteExpression(&expr))
success = false;
@ -75,7 +75,7 @@ static void IncludeNonLocalZone(const String& zonePath, const String& package, b
}
std::vector<Expression *> expressions;
Utility::GlobRecursive(zonePath, "*.conf", std::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, package), GlobFile);
Utility::GlobRecursive(zonePath, "*.conf", std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zoneName, package), GlobFile);
DictExpression expr(expressions);
if (!ExecuteExpression(&expr))
success = false;
@ -126,7 +126,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
String zonesEtcDir = Application::GetZonesDir();
if (!zonesEtcDir.IsEmpty() && Utility::PathExists(zonesEtcDir))
Utility::Glob(zonesEtcDir + "/*", std::bind(&IncludeZoneDirRecursive, _1, "_etc", boost::ref(success)), GlobDirectory);
Utility::Glob(zonesEtcDir + "/*", std::bind(&IncludeZoneDirRecursive, _1, "_etc", std::ref(success)), GlobDirectory);
if (!success)
return false;
@ -135,7 +135,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
* are authoritative on this node and are checked in HasZoneConfigAuthority(). */
String packagesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
if (Utility::PathExists(packagesVarDir))
Utility::Glob(packagesVarDir + "/*", std::bind(&IncludePackage, _1, boost::ref(success)), GlobDirectory);
Utility::Glob(packagesVarDir + "/*", std::bind(&IncludePackage, _1, std::ref(success)), GlobDirectory);
if (!success)
return false;
@ -143,7 +143,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
/* Load cluster synchronized configuration files */
String zonesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
if (Utility::PathExists(zonesVarDir))
Utility::Glob(zonesVarDir + "/*", std::bind(&IncludeNonLocalZone, _1, "_cluster", boost::ref(success)), GlobDirectory);
Utility::Glob(zonesVarDir + "/*", std::bind(&IncludeNonLocalZone, _1, "_cluster", std::ref(success)), GlobDirectory);
if (!success)
return false;

View File

@ -200,11 +200,11 @@ bool FeatureUtility::GetFeatures(std::vector<String>& features, bool get_disable
/* disable = available-enabled */
String available_pattern = GetFeaturesAvailablePath() + "/*.conf";
std::vector<String> available;
Utility::Glob(available_pattern, std::bind(&FeatureUtility::CollectFeatures, _1, boost::ref(available)), GlobFile);
Utility::Glob(available_pattern, std::bind(&FeatureUtility::CollectFeatures, _1, std::ref(available)), GlobFile);
String enabled_pattern = GetFeaturesEnabledPath() + "/*.conf";
std::vector<String> enabled;
Utility::Glob(enabled_pattern, std::bind(&FeatureUtility::CollectFeatures, _1, boost::ref(enabled)), GlobFile);
Utility::Glob(enabled_pattern, std::bind(&FeatureUtility::CollectFeatures, _1, std::ref(enabled)), GlobFile);
std::sort(available.begin(), available.end());
std::sort(enabled.begin(), enabled.end());
@ -217,7 +217,7 @@ bool FeatureUtility::GetFeatures(std::vector<String>& features, bool get_disable
/* all enabled features */
String enabled_pattern = GetFeaturesEnabledPath() + "/*.conf";
Utility::Glob(enabled_pattern, std::bind(&FeatureUtility::CollectFeatures, _1, boost::ref(features)), GlobFile);
Utility::Glob(enabled_pattern, std::bind(&FeatureUtility::CollectFeatures, _1, std::ref(features)), GlobFile);
}
return true;

View File

@ -375,8 +375,8 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
String bestFilename;
try {
Utility::Glob(spath, std::bind(&GetLatestReport, _1, boost::ref(bestTimestamp),
boost::ref(bestFilename)), GlobFile);
Utility::Glob(spath, std::bind(&GetLatestReport, _1, std::ref(bestTimestamp),
std::ref(bestFilename)), GlobFile);
}
#ifdef _WIN32
catch (win32_error &ex) {

View File

@ -155,7 +155,7 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri
std::vector<Expression *> expressions;
if (!Utility::Glob(includePath, std::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zone, package), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
if (!Utility::Glob(includePath, std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zone, package), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
std::ostringstream msgbuf;
msgbuf << "Include file '" + path + "' does not exist";
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debuginfo));
@ -185,7 +185,7 @@ Expression *ConfigCompiler::HandleIncludeRecursive(const String& relativeBase, c
ppath = relativeBase + "/" + path;
std::vector<Expression *> expressions;
Utility::GlobRecursive(ppath, pattern, std::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zone, package), GlobFile);
Utility::GlobRecursive(ppath, pattern, std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zone, package), GlobFile);
DictExpression *dict = new DictExpression(expressions);
dict->MakeInline();
@ -205,7 +205,7 @@ void ConfigCompiler::HandleIncludeZone(const String& relativeBase, const String&
RegisterZoneDir(tag, ppath, zoneName);
Utility::GlobRecursive(ppath, pattern, std::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, package), GlobFile);
Utility::GlobRecursive(ppath, pattern, std::bind(&ConfigCompiler::CollectIncludes, std::ref(expressions), _1, zoneName, package), GlobFile);
}
/**
@ -231,7 +231,7 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& relativeBase, const
}
std::vector<Expression *> expressions;
Utility::Glob(ppath + "/*", std::bind(&ConfigCompiler::HandleIncludeZone, newRelativeBase, tag, _1, pattern, package, boost::ref(expressions)), GlobDirectory);
Utility::Glob(ppath + "/*", std::bind(&ConfigCompiler::HandleIncludeZone, newRelativeBase, tag, _1, pattern, package, std::ref(expressions)), GlobDirectory);
return new DictExpression(expressions);
}

View File

@ -166,7 +166,7 @@ void IcingaApplication::DumpModifiedAttributes(void)
fp.exceptions(std::ofstream::failbit | std::ofstream::badbit);
ConfigObject::Ptr previousObject;
ConfigObject::DumpModifiedAttributes(std::bind(&PersistModAttrHelper, boost::ref(fp), boost::ref(previousObject), _1, _2, _3));
ConfigObject::DumpModifiedAttributes(std::bind(&PersistModAttrHelper, std::ref(fp), std::ref(previousObject), _1, _2, _3));
if (previousObject) {
ConfigWriter::EmitRaw(fp, "\tobj.version = ");

View File

@ -216,10 +216,10 @@ Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const Resolver
}
resolvers_this->Set("macro", new Function("macro (temporary)", std::bind(&MacroProcessor::InternalResolveMacrosShim,
_1, boost::cref(resolvers), cr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros,
_1, std::cref(resolvers), cr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros,
recursionLevel + 1), { "str" }));
resolvers_this->Set("resolve_arguments", new Function("resolve_arguments (temporary)", std::bind(&MacroProcessor::InternalResolveArgumentsShim,
_1, boost::cref(resolvers), cr, resolvedMacros, useResolvedMacros,
_1, std::cref(resolvers), cr, resolvedMacros, useResolvedMacros,
recursionLevel + 1)));
std::vector<Value> args;

View File

@ -39,8 +39,8 @@ using namespace icinga;
void LivestatusLogUtility::CreateLogIndex(const String& path, std::map<time_t, String>& index)
{
Utility::Glob(path + "/icinga.log", std::bind(&LivestatusLogUtility::CreateLogIndexFileHandler, _1, boost::ref(index)), GlobFile);
Utility::Glob(path + "/archives/*.log", std::bind(&LivestatusLogUtility::CreateLogIndexFileHandler, _1, boost::ref(index)), GlobFile);
Utility::Glob(path + "/icinga.log", std::bind(&LivestatusLogUtility::CreateLogIndexFileHandler, _1, std::ref(index)), GlobFile);
Utility::Glob(path + "/archives/*.log", std::bind(&LivestatusLogUtility::CreateLogIndexFileHandler, _1, std::ref(index)), GlobFile);
}
void LivestatusLogUtility::CreateLogIndexFileHandler(const String& path, std::map<time_t, String>& index)

View File

@ -128,7 +128,7 @@ std::vector<LivestatusRowValue> Table::FilterRows(const Filter::Ptr& filter, int
{
std::vector<LivestatusRowValue> rs;
FetchRows(std::bind(&Table::FilteredAddRow, this, boost::ref(rs), filter, limit, _1, _2, _3));
FetchRows(std::bind(&Table::FilteredAddRow, this, std::ref(rs), filter, limit, _1, _2, _3));
return rs;
}

View File

@ -72,7 +72,7 @@ ConfigDirInformation ApiListener::LoadConfigDir(const String& dir)
ConfigDirInformation config;
config.UpdateV1 = new Dictionary();
config.UpdateV2 = new Dictionary();
Utility::GlobRecursive(dir, "*", std::bind(&ApiListener::ConfigGlobHandler, boost::ref(config), dir, _1), GlobFile);
Utility::GlobRecursive(dir, "*", std::bind(&ApiListener::ConfigGlobHandler, std::ref(config), dir, _1), GlobFile);
return config;
}

View File

@ -631,7 +631,7 @@ void ApiListener::ApiTimerHandler(void)
double now = Utility::GetTime();
std::vector<int> files;
Utility::Glob(GetApiDir() + "log/*", std::bind(&ApiListener::LogGlobHandler, boost::ref(files), _1), GlobFile);
Utility::Glob(GetApiDir() + "log/*", std::bind(&ApiListener::LogGlobHandler, std::ref(files), _1), GlobFile);
std::sort(files.begin(), files.end());
for (int ts : files) {
@ -1090,7 +1090,7 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
count = 0;
std::vector<int> files;
Utility::Glob(GetApiDir() + "log/*", std::bind(&ApiListener::LogGlobHandler, boost::ref(files), _1), GlobFile);
Utility::Glob(GetApiDir() + "log/*", std::bind(&ApiListener::LogGlobHandler, std::ref(files), _1), GlobFile);
std::sort(files.begin(), files.end());
for (int ts : files) {

View File

@ -60,7 +60,7 @@ std::vector<String> ConfigPackageUtility::GetPackages(void)
{
std::vector<String> packages;
Utility::Glob(GetPackageDir() + "/*", std::bind(&ConfigPackageUtility::CollectDirNames,
_1, boost::ref(packages)), GlobDirectory);
_1, std::ref(packages)), GlobDirectory);
return packages;
}
@ -237,7 +237,7 @@ void ConfigPackageUtility::DeleteStage(const String& packageName, const String&
std::vector<String> ConfigPackageUtility::GetStages(const String& packageName)
{
std::vector<String> stages;
Utility::Glob(GetPackageDir() + "/" + packageName + "/*", std::bind(&ConfigPackageUtility::CollectDirNames, _1, boost::ref(stages)), GlobDirectory);
Utility::Glob(GetPackageDir() + "/" + packageName + "/*", std::bind(&ConfigPackageUtility::CollectDirNames, _1, std::ref(stages)), GlobDirectory);
return stages;
}
@ -263,7 +263,7 @@ String ConfigPackageUtility::GetActiveStage(const String& packageName)
std::vector<std::pair<String, bool> > ConfigPackageUtility::GetFiles(const String& packageName, const String& stageName)
{
std::vector<std::pair<String, bool> > paths;
Utility::GlobRecursive(GetPackageDir() + "/" + packageName + "/" + stageName, "*", std::bind(&ConfigPackageUtility::CollectPaths, _1, boost::ref(paths)), GlobDirectory | GlobFile);
Utility::GlobRecursive(GetPackageDir() + "/" + packageName + "/" + stageName, "*", std::bind(&ConfigPackageUtility::CollectPaths, _1, std::ref(paths)), GlobDirectory | GlobFile);
return paths;
}

View File

@ -269,8 +269,8 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
try {
provider->FindTargets(type, std::bind(&FilteredAddTarget,
boost::ref(permissionFrame), permissionFilter,
boost::ref(frame), ufilter, boost::ref(result), variableName, _1));
std::ref(permissionFrame), permissionFilter,
std::ref(frame), ufilter, std::ref(result), variableName, _1));
} catch (const std::exception& ex) {
delete ufilter;
throw;

View File

@ -100,7 +100,7 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait)
} else if (m_State == HttpRequestBody) {
if (Headers->Get("transfer-encoding") == "chunked") {
if (!m_ChunkContext)
m_ChunkContext = std::make_shared<ChunkReadContext>(boost::ref(src));
m_ChunkContext = std::make_shared<ChunkReadContext>(std::ref(src));
char *data;
size_t size;

View File

@ -182,7 +182,7 @@ bool HttpResponse::Parse(StreamReadContext& src, bool may_wait)
} else if (m_State == HttpResponseBody) {
if (Headers->Get("transfer-encoding") == "chunked") {
if (!m_ChunkContext)
m_ChunkContext = std::make_shared<ChunkReadContext>(boost::ref(src));
m_ChunkContext = std::make_shared<ChunkReadContext>(std::ref(src));
char *data;
size_t size;