summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-10-12 12:34:20 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-10-12 17:26:10 (GMT)
commit4cca867c9d89beb484164ef6e9a67ac0abab4ba8 (patch)
tree6ecf5788fa6e47fe9be28601e8fb9e2d1d892c06
parent9dac631ad7d1528d5cfc6faf5b0b06811d6ec717 (diff)
Port away from boost in public API
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/kleo/defaultkeyfilter.cpp2
-rw-r--r--src/kleo/defaultkeyfilter.h2
-rw-r--r--src/kleo/kconfigbasedkeyfilter.cpp3
-rw-r--r--src/kleo/keyfilter.h2
-rw-r--r--src/kleo/keyfiltermanager.cpp121
-rw-r--r--src/kleo/keyfiltermanager.h13
-rw-r--r--src/kleo/predicates.h41
-rw-r--r--src/kleo/stl_util.h543
-rw-r--r--src/models/keycache.cpp160
-rw-r--r--src/models/keycache.h9
-rw-r--r--src/models/keylistmodel.cpp28
-rw-r--r--src/models/keylistsortfilterproxymodel.cpp19
-rw-r--r--src/models/keylistsortfilterproxymodel.h6
-rw-r--r--src/models/subkeylistmodel.cpp14
-rw-r--r--src/tests/test_keyselectioncombo.cpp2
-rw-r--r--src/ui/directoryserviceswidget.cpp29
-rw-r--r--src/ui/keyselectioncombo.cpp6
-rw-r--r--src/ui/keyselectioncombo.h6
-rw-r--r--src/utils/classify.cpp32
-rw-r--r--src/utils/filesystemwatcher.cpp21
22 files changed, 341 insertions, 724 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa7d16f..42b5ec2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,6 @@ find_package(Boost 1.34.0)
set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ Libraries" URL "http://www.boost.org" TYPE REQUIRED PURPOSE "Boost is required for building most KDEPIM applications")
-
set_package_properties(KF5PimTextEdit PROPERTIES DESCRIPTION
"A textedit with PIM-specific features."
URL "https://projects.kde.org/projects/kde/pim/kpimtextedit"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 052020a..e796294 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,9 +10,6 @@ add_definitions(-DTRANSLATION_DOMAIN=\"libkleopatra\")
kde_enable_exceptions()
add_definitions( -DGPGMEPP_ERR_SOURCE_DEFAULT=13 ) # 13 is GPG_ERR_SOURCE_KLEO, even if gpg-error's too old to know about
-#parts of Boost don't build with the gcc pedantic option, so remove that option
-string(REPLACE "-pedantic" "" FOO "${CMAKE_CXX_FLAGS}")
-set(CMAKE_CXX_FLAGS "${FOO}")
add_subdirectory( pics )
if (BUILD_TESTING)
@@ -108,7 +105,7 @@ install(TARGETS
-target_include_directories(KF5Libkleo PUBLIC "$<BUILD_INTERFACE:${libkleo_SOURCE_DIR}/src;${libkleo_BINARY_DIR}/src;${Boost_INCLUDE_DIR}>")
+target_include_directories(KF5Libkleo PUBLIC "$<BUILD_INTERFACE:${libkleo_SOURCE_DIR}/src;${libkleo_BINARY_DIR}/src>")
target_include_directories(KF5Libkleo INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/Libkleo/;${KDE_INSTALL_INCLUDEDIR_KF5}/libkleo>")
ecm_generate_headers(libkleo_CamelCase_HEADERS
diff --git a/src/kleo/defaultkeyfilter.cpp b/src/kleo/defaultkeyfilter.cpp
index 2292ff3..0ce36ea 100644
--- a/src/kleo/defaultkeyfilter.cpp
+++ b/src/kleo/defaultkeyfilter.cpp
@@ -206,7 +206,7 @@ bool DefaultKeyFilter::matches(const Key &key, MatchContexts contexts) const
return true;
}
-KeyFilter::FontDescription DefaultKeyFilter::fontDesription() const
+KeyFilter::FontDescription DefaultKeyFilter::fontDescription() const
{
if (d_ptr->mUseFullFont) {
return FontDescription::create(font(), bold(), italic(), strikeOut());
diff --git a/src/kleo/defaultkeyfilter.h b/src/kleo/defaultkeyfilter.h
index 197b9df..80cb927 100644
--- a/src/kleo/defaultkeyfilter.h
+++ b/src/kleo/defaultkeyfilter.h
@@ -86,7 +86,7 @@ public:
QColor bgColor() const Q_DECL_OVERRIDE;
void setBgColor(const QColor &value) const;
- FontDescription fontDesription() const Q_DECL_OVERRIDE;
+ FontDescription fontDescription() const Q_DECL_OVERRIDE;
QString name() const Q_DECL_OVERRIDE;
void setName(const QString &value) const;
QString icon() const Q_DECL_OVERRIDE;
diff --git a/src/kleo/kconfigbasedkeyfilter.cpp b/src/kleo/kconfigbasedkeyfilter.cpp
index 1bace19..c4cc237 100644
--- a/src/kleo/kconfigbasedkeyfilter.cpp
+++ b/src/kleo/kconfigbasedkeyfilter.cpp
@@ -35,12 +35,11 @@
#include <kconfigbase.h>
#include <kconfiggroup.h>
-#include <boost/mem_fn.hpp>
#include <algorithm>
#include <QDebug>
+
using namespace Kleo;
using namespace GpgME;
-using namespace boost;
//
//
diff --git a/src/kleo/keyfilter.h b/src/kleo/keyfilter.h
index c8953f2..de7afec 100644
--- a/src/kleo/keyfilter.h
+++ b/src/kleo/keyfilter.h
@@ -111,7 +111,7 @@ public:
Private *d;
};
- virtual FontDescription fontDesription() const = 0;
+ virtual FontDescription fontDescription() const = 0;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KeyFilter::MatchContexts)
diff --git a/src/kleo/keyfiltermanager.cpp b/src/kleo/keyfiltermanager.cpp
index 0305745..41a4efb 100644
--- a/src/kleo/keyfiltermanager.cpp
+++ b/src/kleo/keyfiltermanager.cpp
@@ -51,15 +51,12 @@
#include <QAbstractListModel>
#include <QModelIndex>
-#include <boost/bind.hpp>
-#include <boost/iterator/filter_iterator.hpp>
-
#include <algorithm>
#include <vector>
#include <climits>
+#include <functional>
using namespace Kleo;
-using namespace boost;
using namespace GpgME;
namespace
@@ -141,14 +138,14 @@ public:
};
}
-static std::vector< shared_ptr<KeyFilter> > defaultFilters()
+static std::vector<std::shared_ptr<KeyFilter>> defaultFilters()
{
- std::vector<shared_ptr<KeyFilter> > result;
+ std::vector<std::shared_ptr<KeyFilter> > result;
result.reserve(3);
- result.push_back(shared_ptr<KeyFilter>(new MyCertificatesKeyFilter));
- result.push_back(shared_ptr<KeyFilter>(new TrustedCertificatesKeyFilter));
- result.push_back(shared_ptr<KeyFilter>(new OtherCertificatesKeyFilter));
- result.push_back(shared_ptr<KeyFilter>(new AllCertificatesKeyFilter));
+ result.push_back(std::shared_ptr<KeyFilter>(new MyCertificatesKeyFilter));
+ result.push_back(std::shared_ptr<KeyFilter>(new TrustedCertificatesKeyFilter));
+ result.push_back(std::shared_ptr<KeyFilter>(new OtherCertificatesKeyFilter));
+ result.push_back(std::shared_ptr<KeyFilter>(new AllCertificatesKeyFilter));
return result;
}
@@ -162,7 +159,7 @@ public:
model.reset();
}
- std::vector< shared_ptr<KeyFilter> > filters;
+ std::vector<std::shared_ptr<KeyFilter>> filters;
Model model;
};
@@ -196,32 +193,35 @@ KeyFilterManager *KeyFilterManager::instance()
return mSelf;
}
-const shared_ptr<KeyFilter> &KeyFilterManager::filterMatching(const Key &key, KeyFilter::MatchContexts contexts) const
+const std::shared_ptr<KeyFilter> &KeyFilterManager::filterMatching(const Key &key, KeyFilter::MatchContexts contexts) const
{
- const std::vector< shared_ptr<KeyFilter> >::const_iterator it
- = std::find_if(d->filters.begin(), d->filters.end(),
- bind(&KeyFilter::matches, _1, cref(key), contexts));
- if (it != d->filters.end()) {
+ const auto it = std::find_if(d->filters.cbegin(), d->filters.cend(),
+ [&key, contexts](const std::shared_ptr<KeyFilter> &filter) {
+ return filter->matches(key, contexts);
+ });
+ if (it != d->filters.cend()) {
return *it;
}
- static const shared_ptr<KeyFilter> null;
+ static const std::shared_ptr<KeyFilter> null;
return null;
}
-std::vector< shared_ptr<KeyFilter> > KeyFilterManager::filtersMatching(const Key &key, KeyFilter::MatchContexts contexts) const
+std::vector<std::shared_ptr<KeyFilter>> KeyFilterManager::filtersMatching(const Key &key, KeyFilter::MatchContexts contexts) const
{
- std::vector< shared_ptr<KeyFilter> > result;
+ std::vector<std::shared_ptr<KeyFilter>> result;
result.reserve(d->filters.size());
std::remove_copy_if(d->filters.begin(), d->filters.end(),
std::back_inserter(result),
- !bind(&KeyFilter::matches, _1, cref(key), contexts));
+ [&key, contexts](const std::shared_ptr<KeyFilter> &filter) {
+ return !filter->matches(key, contexts);
+ });
return result;
}
namespace
{
-struct ByDecreasingSpecificity : std::binary_function<shared_ptr<KeyFilter>, shared_ptr<KeyFilter>, bool> {
- bool operator()(const shared_ptr<KeyFilter> &lhs, const shared_ptr<KeyFilter> &rhs) const
+struct ByDecreasingSpecificity : std::binary_function<std::shared_ptr<KeyFilter>, std::shared_ptr<KeyFilter>, bool> {
+ bool operator()(const std::shared_ptr<KeyFilter> &lhs, const std::shared_ptr<KeyFilter> &rhs) const
{
return lhs->specificity() > rhs->specificity();
}
@@ -238,7 +238,7 @@ void KeyFilterManager::reload()
const QStringList groups = config->groupList().filter(QRegularExpression(QStringLiteral("^Key Filter #\\d+$")));
for (QStringList::const_iterator it = groups.begin(); it != groups.end(); ++it) {
const KConfigGroup cfg(config, *it);
- d->filters.push_back(shared_ptr<KeyFilter>(new KConfigBasedKeyFilter(cfg)));
+ d->filters.push_back(std::shared_ptr<KeyFilter>(new KConfigBasedKeyFilter(cfg)));
}
std::stable_sort(d->filters.begin(), d->filters.end(), ByDecreasingSpecificity());
qCDebug(LIBKLEO_LOG) << "final filter count is" << d->filters.size();
@@ -249,39 +249,36 @@ QAbstractItemModel *KeyFilterManager::model() const
return &d->model;
}
-const shared_ptr<KeyFilter> &KeyFilterManager::keyFilterByID(const QString &id) const
+const std::shared_ptr<KeyFilter> &KeyFilterManager::keyFilterByID(const QString &id) const
{
- const std::vector< shared_ptr<KeyFilter> >::const_iterator it
- = std::find_if(d->filters.begin(), d->filters.end(),
- bind(&KeyFilter::id, _1) == id);
+ const auto it = std::find_if(d->filters.begin(), d->filters.end(),
+ [id](const std::shared_ptr<KeyFilter> &filter) {
+ return filter->id() == id;
+ });
if (it != d->filters.end()) {
return *it;
}
- static const shared_ptr<KeyFilter> null;
+ static const std::shared_ptr<KeyFilter> null;
return null;
}
-const shared_ptr<KeyFilter> &KeyFilterManager::fromModelIndex(const QModelIndex &idx) const
+const std::shared_ptr<KeyFilter> &KeyFilterManager::fromModelIndex(const QModelIndex &idx) const
{
if (!idx.isValid() || idx.model() != &d->model || idx.row() < 0 ||
static_cast<unsigned>(idx.row()) >= d->filters.size()) {
- static const shared_ptr<KeyFilter> null;
+ static const std::shared_ptr<KeyFilter> null;
return null;
}
return d->filters[idx.row()];
}
-QModelIndex KeyFilterManager::toModelIndex(const shared_ptr<KeyFilter> &kf) const
+QModelIndex KeyFilterManager::toModelIndex(const std::shared_ptr<KeyFilter> &kf) const
{
if (!kf) {
return QModelIndex();
}
- const std::pair <
- std::vector<shared_ptr<KeyFilter> >::const_iterator,
- std::vector<shared_ptr<KeyFilter> >::const_iterator
- > pair = std::equal_range(d->filters.begin(), d->filters.end(), kf, ByDecreasingSpecificity());
- const std::vector<shared_ptr<KeyFilter> >::const_iterator it
- = std::find(pair.first, pair.second, kf);
+ const auto pair = std::equal_range(d->filters.cbegin(), d->filters.cend(), kf, ByDecreasingSpecificity());
+ const auto it = std::find(pair.first, pair.second, kf);
if (it != pair.second) {
return d->model.index(it - d->filters.begin());
} else {
@@ -309,45 +306,41 @@ QVariant Model::data(const QModelIndex &idx, int role) const
}
}
-namespace
-{
-template <typename C, typename P1, typename P2>
-typename C::const_iterator find_if_and(const C &c, P1 p1, P2 p2)
-{
- return std::find_if(boost::make_filter_iterator(p1, boost::begin(c), boost::end(c)),
- boost::make_filter_iterator(p1, boost::end(c), boost::end(c)),
- p2).base();
-}
-}
-
QFont KeyFilterManager::font(const Key &key, const QFont &baseFont) const
{
- return kdtools::accumulate_transform_if(d->filters, mem_fn(&KeyFilter::fontDesription),
- bind(&KeyFilter::matches, _1, key, KeyFilter::Appearance),
- KeyFilter::FontDescription(),
- bind(&KeyFilter::FontDescription::resolve, _1, _2)).font(baseFont);
+ return kdtools::accumulate_if(d->filters.begin(), d->filters.end(),
+ [&key](const std::shared_ptr<KeyFilter> &filter) {
+ return filter->matches(key, KeyFilter::Appearance);
+ },
+ KeyFilter::FontDescription(),
+ [](const KeyFilter::FontDescription &lhs,
+ const std::shared_ptr<KeyFilter> &rhs) {
+ return lhs.resolve(rhs->fontDescription());
+ }).font(baseFont);
}
-static QColor get_color(const std::vector< shared_ptr<KeyFilter> > &filters, const Key &key, QColor(KeyFilter::*fun)() const)
+static QColor get_color(const std::vector<std::shared_ptr<KeyFilter>> &filters, const Key &key, QColor(KeyFilter::*fun)() const)
{
- const std::vector< shared_ptr<KeyFilter> >::const_iterator it
- = find_if_and(filters,
- bind(&KeyFilter::matches, _1, key, KeyFilter::Appearance),
- bind(&QColor::isValid, bind(fun, _1)));
- if (it == filters.end()) {
+ const auto it = std::find_if(filters.cbegin(), filters.cend(),
+ [&fun, &key](const std::shared_ptr<KeyFilter> &filter) {
+ return filter->matches(key, KeyFilter::Appearance)
+ && !(filter.get()->*fun)().isValid();
+ });
+ if (it == filters.cend()) {
return QColor();
} else {
return (it->get()->*fun)();
}
}
-static QString get_string(const std::vector< shared_ptr<KeyFilter> > &filters, const Key &key, QString(KeyFilter::*fun)() const)
+static QString get_string(const std::vector<std::shared_ptr<KeyFilter>> &filters, const Key &key, QString(KeyFilter::*fun)() const)
{
- const std::vector< shared_ptr<KeyFilter> >::const_iterator it
- = find_if_and(filters,
- bind(&KeyFilter::matches, _1, key, KeyFilter::Appearance),
- !bind(&QString::isEmpty, bind(fun, _1)));
- if (it == filters.end()) {
+ const auto it = std::find_if(filters.cbegin(), filters.cend(),
+ [&fun, &key](const std::shared_ptr<KeyFilter> &filter) {
+ return filter->matches(key, KeyFilter::Appearance)
+ && !(filter.get()->*fun)().isEmpty();
+ });
+ if (it == filters.cend()) {
return QString();
} else {
return (*it)->icon();
diff --git a/src/kleo/keyfiltermanager.h b/src/kleo/keyfiltermanager.h
index 6da1a47..0fc8515 100644
--- a/src/kleo/keyfiltermanager.h
+++ b/src/kleo/keyfiltermanager.h
@@ -36,10 +36,9 @@
#include "kleo_export.h"
#include <QObject>
-#include <boost/shared_ptr.hpp>
-
#include <libkleo/keyfilter.h>
+#include <memory>
#include <vector>
namespace GpgME
@@ -66,14 +65,14 @@ protected:
public:
static KeyFilterManager *instance();
- const boost::shared_ptr<KeyFilter> &filterMatching(const GpgME::Key &key, KeyFilter::MatchContexts contexts) const;
- std::vector< boost::shared_ptr<KeyFilter> > filtersMatching(const GpgME::Key &key, KeyFilter::MatchContexts contexts) const;
+ const std::shared_ptr<KeyFilter> &filterMatching(const GpgME::Key &key, KeyFilter::MatchContexts contexts) const;
+ std::vector<std::shared_ptr<KeyFilter>> filtersMatching(const GpgME::Key &key, KeyFilter::MatchContexts contexts) const;
QAbstractItemModel *model() const;
- const boost::shared_ptr<KeyFilter> &keyFilterByID(const QString &id) const;
- const boost::shared_ptr<KeyFilter> &fromModelIndex(const QModelIndex &mi) const;
- QModelIndex toModelIndex(const boost::shared_ptr<KeyFilter> &kf) const;
+ const std::shared_ptr<KeyFilter> &keyFilterByID(const QString &id) const;
+ const std::shared_ptr<KeyFilter> &fromModelIndex(const QModelIndex &mi) const;
+ QModelIndex toModelIndex(const std::shared_ptr<KeyFilter> &kf) const;
void reload();
diff --git a/src/kleo/predicates.h b/src/kleo/predicates.h
index cb4496a..2714c53 100644
--- a/src/kleo/predicates.h
+++ b/src/kleo/predicates.h
@@ -33,17 +33,13 @@
#ifndef __KLEOPATRA_MODELS_PREDICATES_H__
#define __KLEOPATRA_MODELS_PREDICATES_H__
-#include <libkleo/stl_util.h>
-
-#include <string>
-
#include <gpgme++/key.h>
-#include <boost/bind.hpp>
-
+#include <string>
#include <cstring>
#include <algorithm>
#include <iterator>
+#include <functional>
namespace Kleo
{
@@ -143,55 +139,70 @@ T union_by_fpr_dirty(const T &t1, const T &t2)
template <typename T>
void grep_protocol(T &t, GpgME::Protocol proto)
{
- t.erase(std::remove_if(t.begin(), t.end(), boost::bind(&GpgME::Key::protocol, _1) != proto), t.end());
+ t.erase(std::remove_if(t.begin(), t.end(),
+ [proto](const GpgME::Key &key) {
+ return key.protocol() != proto;
+ }), t.end());
}
template <typename T>
bool any_protocol(const T &t, GpgME::Protocol proto)
{
- return kdtools::any(t, boost::bind(&GpgME::Key::protocol, _1) == proto);
+ return std::any_of(t.cbegin(), t.cend(),
+ [proto](const GpgME::Key &key) {
+ return key.protocol() == proto;
+ });
}
template <typename T>
bool all_protocol(const T &t, GpgME::Protocol proto)
{
- return kdtools::all(t, boost::bind(&GpgME::Key::protocol, _1) == proto);
+ return std::all_of(t.cbegin(), t.cend(),
+ [proto](const GpgME::Key &key) {
+ return key.protocol() == proto;
+ });
}
template <typename T>
bool none_of_protocol(const T &t, GpgME::Protocol proto)
{
- return kdtools::none_of(t, boost::bind(&GpgME::Key::protocol, _1) == proto);
+ return std::none_of(t.cbegin(), t.cend(),
+ [proto](const GpgME::Key &key) {
+ return key.protocol() == proto;
+ });
}
template <typename T>
void grep_secret(T &t)
{
- t.erase(std::remove_if(t.begin(), t.end(), boost::mem_fn(&GpgME::Key::hasSecret)), t.end());
+ t.erase(std::remove_if(t.begin(), t.end(), std::mem_fn(&GpgME::Key::hasSecret)), t.end());
}
template <typename T>
bool any_secret(const T &t)
{
- return kdtools::any(t, boost::mem_fn(&GpgME::Key::hasSecret));
+ return std::any_of(t.cbegin(), t.cend(), std::mem_fn(&GpgME::Key::hasSecret));
}
template <typename T>
bool all_secret(const T &t)
{
- return kdtools::all(t, boost::mem_fn(&GpgME::Key::hasSecret));
+ return std::all_of(t.cbegin(), t.cend(), std::mem_fn(&GpgME::Key::hasSecret));
}
template <typename T>
bool none_of_secret(const T &t)
{
- return kdtools::none_of(t, boost::mem_fn(&GpgME::Key::hasSecret));
+ return std::none_of(t.cbegin(), t.cend(), std::mem_fn(&GpgME::Key::hasSecret));
}
template <typename T>
void grep_can_encrypt(T &t)
{
- t.erase(std::remove_if(t.begin(), t.end(), !boost::bind(&GpgME::Key::canEncrypt, _1)), t.end());
+ t.erase(std::remove_if(t.begin(), t.end(),
+ [](const GpgME::Key &key) {
+ return !key.canEncrypt();
+ }), t.end());
}
}
diff --git a/src/kleo/stl_util.h b/src/kleo/stl_util.h
index 388d5bb..a3f9b31 100644
--- a/src/kleo/stl_util.h
+++ b/src/kleo/stl_util.h
@@ -22,12 +22,6 @@
#ifndef __KDTOOLSCORE_STL_UTIL_H__
#define __KDTOOLSCORE_STL_UTIL_H__
-#include <boost/range.hpp>
-#include <boost/iterator/filter_iterator.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/call_traits.hpp>
-#include <boost/version.hpp>
-
#include <algorithm>
#include <numeric>
#include <utility>
@@ -36,60 +30,38 @@
namespace kdtools
{
-
-struct nodelete {
- template <typename T>
- void operator()(const T *) const {}
-};
-
-struct identity {
- template <typename T>
- T *operator()(T *t) const
- {
- return t;
- }
- template <typename T>
- const T *operator()(const T *t) const
- {
- return t;
- }
- template <typename T>
- T &operator()(T &t) const
- {
- return t;
- }
- template <typename T>
- const T &operator()(const T &t) const
- {
- return t;
- }
+template<typename _Iterator, typename UnaryPredicate>
+struct filter_iterator
+{
+ using value_type = typename std::iterator_traits<_Iterator>::value_type;
+ using reference = typename std::iterator_traits<_Iterator>::reference;
+ using pointer = typename std::iterator_traits<_Iterator>::pointer;
+ using difference_type = typename std::iterator_traits<_Iterator>::difference_type;
+
+ filter_iterator(UnaryPredicate pred, _Iterator it, _Iterator last) : it(it), last(last), pred(pred) {}
+ template<typename _OtherIter>
+ filter_iterator(const filter_iterator<_OtherIter, UnaryPredicate> &other) : it(other.it), last(other.last), pred(other.pred) {}
+ filter_iterator &operator++() { while (it != last && !pred(*(++it))){} return *this; }
+ filter_iterator operator++(int) { auto retval = *this; while(it != last && !pred(++it)){} return retval; }
+ bool operator==(filter_iterator other) const { return it == other.it; }
+ bool operator!=(filter_iterator other) const { return it != other.it; }
+ typename _Iterator::reference operator*() const { return *it; }
+private:
+ _Iterator it, last;
+ UnaryPredicate pred;
};
-template <typename Pair>
-struct select1st;
-
-template <typename U, typename V>
-struct select1st< std::pair<U, V> >
- : std::unary_function<std::pair<U, V>, U> {
- typename boost::call_traits<U>::param_type
- operator()(const std::pair<U, V> &pair) const
- {
- return pair.first;
- }
-};
-
-template <typename Pair>
-struct select2nd;
-
-template <typename U, typename V>
-struct select2nd< std::pair<U, V> >
- : std::unary_function<std::pair<U, V>, V> {
- typename boost::call_traits<V>::param_type
- operator()(const std::pair<U, V> &pair) const
- {
- return pair.second;
- }
-};
+template<typename _Iterator, typename UnaryPredicate>
+filter_iterator<typename std::decay<_Iterator>::type,
+ UnaryPredicate>
+make_filter_iterator(UnaryPredicate &&pred, _Iterator &&it, _Iterator &&last)
+{
+ return filter_iterator<typename std::decay<_Iterator>::type,
+ UnaryPredicate>(
+ std::forward<UnaryPredicate>(pred),
+ std::forward<_Iterator>(it),
+ std::forward<_Iterator>(last));
+}
template <typename InputIterator, typename OutputIterator, typename UnaryPredicate>
OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator dest, UnaryPredicate pred)
@@ -105,178 +77,103 @@ OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator d
}
template <typename OutputIterator, typename InputIterator, typename UnaryFunction, typename UnaryPredicate>
-OutputIterator transform_if(InputIterator first, InputIterator last, OutputIterator dest, UnaryPredicate pred, UnaryFunction filter)
+void transform_if(InputIterator first, InputIterator last, OutputIterator dest, UnaryPredicate pred, UnaryFunction filter)
{
- return std::transform(boost::make_filter_iterator(filter, first, last),
- boost::make_filter_iterator(filter, last, last),
- dest, pred);
-}
-
-template <typename InputIterator, typename OutputIterator>
-OutputIterator copy_1st(InputIterator first, InputIterator last, OutputIterator dest)
-{
- return std::copy(boost::make_transform_iterator(first, select1st<typename std::iterator_traits<InputIterator>::value_type>()),
- boost::make_transform_iterator(last, select1st<typename std::iterator_traits<InputIterator>::value_type>()),
- dest);
-}
-
-template <typename InputIterator, typename OutputIterator>
-OutputIterator copy_2nd(InputIterator first, InputIterator last, OutputIterator dest)
-{
- return std::copy(boost::make_transform_iterator(first, select2nd<typename std::iterator_traits<InputIterator>::value_type>()),
- boost::make_transform_iterator(last, select2nd<typename std::iterator_traits<InputIterator>::value_type>()),
- dest);
+ for (; first != last; ++first) {
+ if (filter(*first)) {
+ *dest++ = pred(*first);
+ }
+ }
}
template <typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator copy_1st_if(InputIterator first, InputIterator last, OutputIterator dest, Predicate pred)
{
- return kdtools::copy_if(boost::make_transform_iterator(first, select1st<typename std::iterator_traits<InputIterator>::value_type>()),
- boost::make_transform_iterator(last, select1st<typename std::iterator_traits<InputIterator>::value_type>()),
- dest, pred);
+ const auto trans = [](typename std::iterator_traits<InputIterator>::reference v) {
+ return std::get<0>(v);
+ };
+ kdtools::transform_if(first, last, dest, trans,
+ [&pred, &trans](typename std::iterator_traits<InputIterator>::reference v) {
+ return pred(trans(v));
+ });
+ return dest;
}
template <typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator copy_2nd_if(InputIterator first, InputIterator last, OutputIterator dest, Predicate pred)
{
- return kdtools::copy_if(boost::make_transform_iterator(first, select2nd<typename std::iterator_traits<InputIterator>::value_type>()),
- boost::make_transform_iterator(last, select2nd<typename std::iterator_traits<InputIterator>::value_type>()),
- dest, pred);
+ const auto trans = [](typename std::iterator_traits<InputIterator>::reference v) {
+ return std::get<1>(v);
+ };
+ kdtools::transform_if(first, last, dest, trans,
+ [&pred, &trans](typename std::iterator_traits<InputIterator>::reference v) {
+ return pred(trans(v));
+ });
+ return dest;
}
+
template <typename OutputIterator, typename InputIterator, typename UnaryFunction>
OutputIterator transform_1st(InputIterator first, InputIterator last, OutputIterator dest, UnaryFunction func)
{
- return std::transform(boost::make_transform_iterator(first, select1st<typename std::iterator_traits<InputIterator>::value_type>()),
- boost::make_transform_iterator(last, select1st<typename std::iterator_traits<InputIterator>::value_type>()),
- dest, func);
+ return std::transform(first, last, dest,
+ [func](typename std::iterator_traits<InputIterator>::reference v) {
+ return func(std::get<0>(v));
+ });
}
template <typename OutputIterator, typename InputIterator, typename UnaryFunction>
OutputIterator transform_2nd(InputIterator first, InputIterator last, OutputIterator dest, UnaryFunction func)
{
- return std::transform(boost::make_transform_iterator(first, select2nd<typename std::iterator_traits<InputIterator>::value_type>()),
- boost::make_transform_iterator(last, select2nd<typename std::iterator_traits<InputIterator>::value_type>()),
- dest, func);
+ return std::transform(first, last, dest,
+ [func](typename std::iterator_traits<InputIterator>::reference v) {
+ return func(std::get<1>(v));
+ });
}
template <typename Value, typename InputIterator, typename UnaryPredicate>
Value accumulate_if(InputIterator first, InputIterator last, UnaryPredicate filter, const Value &value = Value())
{
- return std::accumulate(boost::make_filter_iterator(filter, first, last),
- boost::make_filter_iterator(filter, last, last), value);
+ return std::accumulate(make_filter_iterator(filter, first, last),
+ make_filter_iterator(filter, last, last), value);
}
template <typename Value, typename InputIterator, typename UnaryPredicate, typename BinaryOperation>
Value accumulate_if(InputIterator first, InputIterator last, UnaryPredicate filter, const Value &value, BinaryOperation op)
{
- return std::accumulate(boost::make_filter_iterator(filter, first, last),
- boost::make_filter_iterator(filter, last, last), value, op);
+ return std::accumulate(make_filter_iterator(filter, first, last),
+ make_filter_iterator(filter, last, last), value, op);
}
template <typename Value, typename InputIterator, typename UnaryFunction>
Value accumulate_transform(InputIterator first, InputIterator last, UnaryFunction map, const Value &value = Value())
{
- return std::accumulate(boost::make_transform_iterator(first, map),
- boost::make_transform_iterator(last, map), value);
+ return std::accumulate(first, last, value,
+ [map](Value lhs,
+ typename std::iterator_traits<InputIterator>::reference rhs)
+ {
+ return lhs + map(rhs);
+ });
}
template <typename Value, typename InputIterator, typename UnaryFunction, typename BinaryOperation>
Value accumulate_transform(InputIterator first, InputIterator last, UnaryFunction map, const Value &value, BinaryOperation op)
{
- return std::accumulate(boost::make_transform_iterator(first, map),
- boost::make_transform_iterator(last, map), value, op);
-}
-
-template <typename Value, typename InputIterator, typename UnaryFunction, typename UnaryPredicate>
-Value accumulate_transform_if(InputIterator first, InputIterator last, UnaryFunction map, UnaryPredicate pred, const Value &value = Value())
-{
- return std::accumulate(boost::make_transform_iterator(first, map),
- boost::make_transform_iterator(last, map), value);
+ return std::accumulate(first, last, value,
+ [map, op](typename InputIterator::reference lhs,
+ typename InputIterator::reference rhs) {
+ return op(map(lhs), map(rhs));
+ });
}
template <typename Value, typename InputIterator, typename UnaryFunction, typename UnaryPredicate, typename BinaryOperation>
Value accumulate_transform_if(InputIterator first, InputIterator last, UnaryFunction map, UnaryPredicate filter, const Value &value, BinaryOperation op)
{
- return std::accumulate(boost::make_transform_iterator(boost::make_filter_iterator(filter, first, last), map),
- boost::make_transform_iterator(boost::make_filter_iterator(filter, last, last), map), value, op);
-}
-
-template <typename InputIterator, typename OutputIterator1, typename OutputIterator2, typename UnaryPredicate>
-std::pair<OutputIterator1, OutputIterator2> separate_if(InputIterator first, InputIterator last, OutputIterator1 dest1, OutputIterator2 dest2, UnaryPredicate pred)
-{
- while (first != last) {
- if (pred(*first)) {
- *dest1 = *first;
- ++dest1;
- } else {
- *dest2 = *first;
- ++dest2;
- }
- ++first;
- }
- return std::make_pair(dest1, dest2);
-}
-
-template <typename InputIterator>
-bool any(InputIterator first, InputIterator last)
-{
- while (first != last)
- if (*first) {
- return true;
- } else {
- ++first;
- }
- return false;
-}
-
-template <typename InputIterator, typename UnaryPredicate>
-bool any(InputIterator first, InputIterator last, UnaryPredicate pred)
-{
- while (first != last)
- if (pred(*first)) {
- return true;
- } else {
- ++first;
- }
- return false;
+ return accumulate_transform(make_filter_iterator(filter, first, last),
+ make_filter_iterator(filter, last, last),
+ map, value, op);
}
-template <typename InputIterator>
-bool all(InputIterator first, InputIterator last)
-{
- while (first != last)
- if (*first) {
- ++first;
- } else {
- return false;
- }
- return true;
-}
-
-template <typename InputIterator, typename UnaryPredicate>
-bool all(InputIterator first, InputIterator last, UnaryPredicate pred)
-{
- while (first != last)
- if (pred(*first)) {
- ++first;
- } else {
- return false;
- }
- return true;
-}
-
-template <typename InputIterator>
-bool none_of(InputIterator first, InputIterator last)
-{
- return !any(first, last);
-}
-
-template <typename InputIterator, typename UnaryPredicate>
-bool none_of(InputIterator first, InputIterator last, UnaryPredicate pred)
-{
- return !any(first, last, pred);
-}
template <typename InputIterator, typename BinaryOperation>
BinaryOperation for_each_adjacent_pair(InputIterator first, InputIterator last, BinaryOperation op)
@@ -294,12 +191,21 @@ BinaryOperation for_each_adjacent_pair(InputIterator first, InputIterator last,
return op;
}
-template <typename ForwardIterator, typename UnaryPredicate, typename UnaryFunction>
-UnaryFunction for_each_if(ForwardIterator first, ForwardIterator last, UnaryPredicate pred, UnaryFunction func)
+
+template <typename InputIterator, typename OutputIterator1, typename OutputIterator2, typename UnaryPredicate>
+std::pair<OutputIterator1, OutputIterator2> separate_if(InputIterator first, InputIterator last, OutputIterator1 dest1, OutputIterator2 dest2, UnaryPredicate pred)
{
- return std::for_each(boost::make_filter_iterator(pred, first, last),
- boost::make_filter_iterator(pred, last, last),
- func);
+ while (first != last) {
+ if (pred(*first)) {
+ *dest1 = *first;
+ ++dest1;
+ } else {
+ *dest2 = *first;
+ ++dest2;
+ }
+ ++first;
+ }
+ return std::make_pair(dest1, dest2);
}
//@{
@@ -361,269 +267,6 @@ bool set_intersects(ForwardIterator first1, ForwardIterator last1,
}
//@{
-/*! Versions of std algorithms that take ranges */
-
-template <typename C, typename V>
-typename boost::range_iterator<C>::type
-find(C &c, const V &v)
-{
- return std::find(boost::begin(c), boost::end(c), v);
-}
-
-#if BOOST_VERSION < 103500
-template <typename C, typename V>
-typename boost::range_const_iterator<C>::type
-find(const C &c, const V &v)
-{
- return std::find(boost::begin(c), boost::end(c), v);
-}
-#endif
-
-template <typename C, typename P>
-typename boost::range_iterator<C>::type
-find_if(C &c, P p)
-{
- return std::find_if(boost::begin(c), boost::end(c), p);
-}
-
-#if BOOST_VERSION < 103500
-template <typename C, typename P>
-typename boost::range_const_iterator<C>::type
-find_if(const C &c, P p)
-{
- return std::find_if(boost::begin(c), boost::end(c), p);
-}
-#endif
-
-template <typename C, typename V>
-bool contains(const C &c, const V &v)
-{
- return find(c, v) != boost::end(c);
-}
-
-template <typename C, typename P>
-bool contains_if(const C &c, P p)
-{
- return find_if(c, p) != boost::end(c);
-}
-
-template <typename C, typename V>
-bool binary_search(const C &c, const V &v)
-{
- return std::binary_search(boost::begin(c), boost::end(c), v);
-}
-
-template <typename C, typename V>
-size_t count(const C &c, const V &v)
-{
- return std::count(boost::begin(c), boost::end(c), v);
-}
-
-template <typename C, typename P>
-size_t count_if(const C &c, P p)
-{
- return std::count_if(boost::begin(c), boost::end(c), p);
-}
-
-template <typename O, typename I, typename P>
-O transform(const I &i, P p)
-{
- O o;
- std::transform(boost::begin(i), boost::end(i),
- std::back_inserter(o), p);
- return o;
-}
-
-template <typename I, typename OutputIterator, typename P>
-OutputIterator transform(const I &i, OutputIterator out, P p)
-{
- return std::transform(boost::begin(i), boost::end(i), out, p);
-}
-
-template <typename O, typename I, typename P, typename F>
-O transform_if(const I &i, P p, F f)
-{
- O o;
- transform_if(boost::begin(i), boost::end(i),
- std::back_inserter(o), p, f);
- return o;
-}
-
-template <typename V, typename I, typename F>
-V accumulate_if(const I &i, F f, V v = V())
-{
- return accumulate_if(boost::begin(i), boost::end(i), f, v);
-}
-
-template <typename V, typename I, typename F, typename B>
-V accumulate_if(const I &i, F f, V v, B b)
-{
- return accumulate_if(boost::begin(i), boost::end(i), f, v, b);
-}
-
-template <typename V, typename I, typename F>
-V accumulate_transform(const I &i, F f, V v = V())
-{
- return accumulate_transform(boost::begin(i), boost::end(i), f, v);
-}
-
-template <typename V, typename I, typename F, typename B>
-V accumulate_transform(const I &i, F f, V v, B b)
-{
- return accumulate_transform(boost::begin(i), boost::end(i), f, v, b);
-}
-
-template <typename V, typename I, typename F, typename P>
-V accumulate_transform_if(const I &i, F f, P p, V v = V())
-{
- return accumulate_transform_if(boost::begin(i), boost::end(i), f, p, v);
-}
-
-template <typename V, typename I, typename F, typename P, typename B>
-V accumulate_transform_if(const I &i, F f, P p, V v, B b)
-{
- return accumulate_transform_if(boost::begin(i), boost::end(i), f, p, v, b);
-}
-
-template <typename O, typename I>
-O copy(const I &i)
-{
- O o;
- std::copy(boost::begin(i), boost::end(i), std::back_inserter(o));
- return o;
-}
-
-template <typename O, typename I, typename P>
-O copy_if(const I &i, P p)
-{
- O o;
- kdtools::copy_if(boost::begin(i), boost::end(i), std::back_inserter(o), p);
- return o;
-}
-
-template <typename I, typename P>
-P for_each(const I &i, P p)
-{
- return std::for_each(boost::begin(i), boost::end(i), p);
-}
-
-template <typename I, typename P>
-P for_each(I &i, P p)
-{
- return std::for_each(boost::begin(i), boost::end(i), p);
-}
-
-template <typename C1, typename C2>
-bool equal(const C1 &c1, const C2 &c2)
-{
- return boost::size(c1) == boost::size(c2)
- && std::equal(boost::begin(c1), boost::end(c1),
- boost::begin(c2));
-}
-
-template <typename C1, typename C2, typename P>
-bool equal(const C1 &c1, const C2 &c2, P p)
-{
- return boost::size(c1) == boost::size(c2)
- && std::equal(boost::begin(c1), boost::end(c1),
- boost::begin(c2), p);
-}
-
-template <typename C, typename O1, typename O2, typename P>
-std::pair<O1, O2> separate_if(const C &c, O1 o1, O2 o2, P p)
-{
- return separate_if(boost::begin(c), boost::end(c), o1, o2, p);
-}
-
-//@}
-
-template <typename C>
-bool any(const C &c)
-{
- return any(boost::begin(c), boost::end(c));
-}
-
-template <typename C, typename P>
-bool any(const C &c, P p)
-{
- return any(boost::begin(c), boost::end(c), p);
-}
-
-template <typename C>
-bool all(const C &c)
-{
- return all(boost::begin(c), boost::end(c));
-}
-
-template <typename C, typename P>
-bool all(const C &c, P p)
-{
- return all(boost::begin(c), boost::end(c), p);
-}
-
-template <typename C>
-bool none_of(const C &c)
-{
- return none_of(boost::begin(c), boost::end(c));
-}
-
-template <typename C, typename P>
-bool none_of(const C &c, P p)
-{
- return kdtools::none_of(boost::begin(c), boost::end(c), p);
-}
-
-template <typename C, typename B>
-B for_each_adjacent_pair(const C &c, B b)
-{
- return for_each_adjacent_pair(boost::begin(c), boost::end(c), b);
-}
-
-template <typename C, typename B>
-B for_each_adjacent_pair(C &c, B b)
-{
- return for_each_adjacent_pair(boost::begin(c), boost::end(c), b);
-}
-
-template <typename C, typename P, typename F>
-P for_each_if(const C &c, P p, F f)
-{
- return for_each_if(boost::begin(c), boost::end(c), p, f);
-}
-
-template <typename C, typename P, typename F>
-P for_each_if(C &c, P p, F f)
-{
- return for_each_if(boost::begin(c), boost::end(c), p, f);
-}
-
-template <typename C>
-void sort(C &c)
-{
- return std::sort(boost::begin(c), boost::end(c));
-}
-
-template <typename C, typename P>
-void sort(C &c, P p)
-{
- return std::sort(boost::begin(c), boost::end(c), p);
-}
-
-template <typename C>
-C sorted(const C &c)
-{
- C copy(c);
- kdtools::sort(copy);
- return copy;
-}
-
-template <typename C, typename P>
-C sorted(const C &c, P p)
-{
- C copy(c);
- kdtools::sort(copy, p);
- return copy;
-}
}
diff --git a/src/models/keycache.cpp b/src/models/keycache.cpp
index f1dd39d..7a9d20d 100644
--- a/src/models/keycache.cpp
+++ b/src/models/keycache.cpp
@@ -59,12 +59,6 @@
#include <QTimer>
#include <QEventLoop>
-#include <boost/bind.hpp>
-#include <boost/mem_fn.hpp>
-#include <boost/range.hpp>
-#include <boost/weak_ptr.hpp>
-#include <boost/iterator/filter_iterator.hpp>
-
#include <utility>
#include <algorithm>
#include <functional>
@@ -72,7 +66,6 @@
using namespace Kleo;
using namespace GpgME;
-using namespace boost;
using namespace KMime::Types;
static const unsigned int hours2ms = 1000 * 60 * 60;
@@ -88,13 +81,6 @@ namespace
make_comparator_str(ByEMail, .first.c_str());
-struct is_string_empty : std::unary_function<const char *, bool> {
- bool operator()(const char *s) const
- {
- return !s || !*s;
- }
-};
-
}
class KeyCache::Private
@@ -205,7 +191,7 @@ public:
private:
QPointer<RefreshKeysJob> m_refreshJob;
- std::vector<shared_ptr<FileSystemWatcher> > m_fsWatchers;
+ std::vector<std::shared_ptr<FileSystemWatcher> > m_fsWatchers;
QTimer m_autoKeyListingTimer;
int m_refreshInterval;
@@ -217,18 +203,18 @@ private:
bool m_initalized;
};
-shared_ptr<const KeyCache> KeyCache::instance()
+std::shared_ptr<const KeyCache> KeyCache::instance()
{
return mutableInstance();
}
-shared_ptr<KeyCache> KeyCache::mutableInstance()
+std::shared_ptr<KeyCache> KeyCache::mutableInstance()
{
- static weak_ptr<KeyCache> self;
+ static std::weak_ptr<KeyCache> self;
try {
- return shared_ptr<KeyCache>(self);
- } catch (const bad_weak_ptr &) {
- const shared_ptr<KeyCache> s(new KeyCache);
+ return std::shared_ptr<KeyCache>(self);
+ } catch (const std::bad_weak_ptr &) {
+ const std::shared_ptr<KeyCache> s(new KeyCache);
self = s;
return s;
}
@@ -244,7 +230,7 @@ KeyCache::~KeyCache() {}
void KeyCache::enableFileSystemWatcher(bool enable)
{
- Q_FOREACH (const shared_ptr<FileSystemWatcher> &i, d->m_fsWatchers) {
+ Q_FOREACH (const auto &i, d->m_fsWatchers) {
i->setEnabled(enable);
}
}
@@ -281,7 +267,7 @@ void KeyCache::cancelKeyListing()
d->m_refreshJob->cancel();
}
-void KeyCache::addFileSystemWatcher(const shared_ptr<FileSystemWatcher> &watcher)
+void KeyCache::addFileSystemWatcher(const std::shared_ptr<FileSystemWatcher> &watcher)
{
if (!watcher) {
return;
@@ -320,15 +306,14 @@ const Key &KeyCache::findByFingerprint(const std::string &fpr) const
std::vector<Key> KeyCache::findByEMailAddress(const char *email) const
{
- const std::pair <
- std::vector< std::pair<std::string, Key> >::const_iterator,
- std::vector< std::pair<std::string, Key> >::const_iterator
- > pair = d->find_email(email);
+ const auto pair = d->find_email(email);
std::vector<Key> result;
result.reserve(std::distance(pair.first, pair.second));
std::transform(pair.first, pair.second,
std::back_inserter(result),
- boost::bind(&std::pair<std::string, Key>::second, _1));
+ [](const std::pair<std::string, Key> &pair) {
+ return pair.second;
+ });
return result;
}
@@ -381,7 +366,9 @@ std::vector<Key> KeyCache::findByKeyIDOrFingerprint(const std::vector<std::strin
std::vector<std::string> keyids;
std::remove_copy_if(ids.begin(), ids.end(), std::back_inserter(keyids),
- boost::bind(is_string_empty(), boost::bind(&std::string::c_str, _1)));
+ [](const std::string &str) {
+ return !str.c_str() || !*str.c_str();
+ });
// this is just case-insensitive string search:
std::sort(keyids.begin(), keyids.end(), _detail::ByFingerprint<std::less>());
@@ -417,7 +404,9 @@ std::vector<Subkey> KeyCache::findSubkeysByKeyID(const std::vector<std::string>
std::vector<std::string> sorted;
sorted.reserve(ids.size());
std::remove_copy_if(ids.begin(), ids.end(), std::back_inserter(sorted),
- boost::bind(is_string_empty(), boost::bind(&std::string::c_str, _1)));
+ [](const std::string &str) {
+ return !str.c_str() || !*str.c_str();
+ });
std::sort(sorted.begin(), sorted.end(), _detail::ByKeyID<std::less>());
@@ -440,7 +429,8 @@ std::vector<Key> KeyCache::findRecipients(const DecryptionResult &res) const
const std::vector<Subkey> subkeys = findSubkeysByKeyID(keyids);
std::vector<Key> result;
result.reserve(subkeys.size());
- std::transform(subkeys.begin(), subkeys.end(), std::back_inserter(result), boost::bind(&Subkey::parent, _1));
+ std::transform(subkeys.begin(), subkeys.end(), std::back_inserter(result),
+ std::mem_fn(&Subkey::parent));
std::sort(result.begin(), result.end(), _detail::ByFingerprint<std::less>());
result.erase(std::unique(result.begin(), result.end(), _detail::ByFingerprint<std::equal_to>()), result.end());
@@ -519,11 +509,7 @@ std::vector<Key> KeyCache::Private::find_mailbox(const QString &email, bool sign
return std::vector<Key>();
}
- const std::pair <
- std::vector< std::pair<std::string, Key> >::const_iterator,
- std::vector< std::pair<std::string, Key> >::const_iterator
- > pair = find_email(email.toUtf8().constData());
-
+ const auto pair = find_email(email.toUtf8().constData());
std::vector<Key> result;
result.reserve(std::distance(pair.first, pair.second));
if (sign)
@@ -534,6 +520,7 @@ std::vector<Key> KeyCache::Private::find_mailbox(const QString &email, bool sign
kdtools::copy_2nd_if(pair.first, pair.second,
std::back_inserter(result),
ready_for_encryption());
+
return result;
}
@@ -556,10 +543,7 @@ std::vector<Key> KeyCache::findSubjects(std::vector<Key>::const_iterator first,
std::vector<Key> result;
while (first != last) {
- const std::pair <
- std::vector<Key>::const_iterator,
- std::vector<Key>::const_iterator
- > pair = d->find_subjects(first->primaryFingerprint());
+ const auto pair = d->find_subjects(first->primaryFingerprint());
result.insert(result.end(), pair.first, pair.second);
++first;
}
@@ -636,13 +620,12 @@ std::vector<Key> KeyCache::findIssuers(std::vector<Key>::const_iterator first, s
// extract chain-ids, identifying issuers:
std::vector<const char *> chainIDs;
chainIDs.reserve(last - first);
- std::transform(boost::make_filter_iterator(!boost::bind(&Key::isRoot, _1), first, last),
- boost::make_filter_iterator(!boost::bind(&Key::isRoot, _1), last, last),
- std::back_inserter(chainIDs),
- boost::bind(&Key::chainID, _1));
+ kdtools::transform_if(first, last, std::back_inserter(chainIDs),
+ std::mem_fn(&Key::chainID),
+ [](const Key &key) { return !key.isRoot(); });
std::sort(chainIDs.begin(), chainIDs.end(), _detail::ByFingerprint<std::less>());
- const std::vector<const char *>::iterator lastUniqueChainID = std::unique(chainIDs.begin(), chainIDs.end(), _detail::ByFingerprint<std::less>());
+ const auto lastUniqueChainID = std::unique(chainIDs.begin(), chainIDs.end(), _detail::ByFingerprint<std::less>());
std::vector<Key> result;
result.reserve(lastUniqueChainID - chainIDs.begin());
@@ -715,55 +698,53 @@ void KeyCache::remove(const Key &key)
Q_EMIT aboutToRemove(key);
{
- const std::pair<std::vector<Key>::iterator, std::vector<Key>::iterator> range
- = std::equal_range(d->by.fpr.begin(), d->by.fpr.end(), fpr,
- _detail::ByFingerprint<std::less>());
+ const auto range = std::equal_range(d->by.fpr.cbegin(), d->by.fpr.cend(), fpr,
+ _detail::ByFingerprint<std::less>());
d->by.fpr.erase(range.first, range.second);
}
if (const char *keyid = key.keyID()) {
- const std::pair<std::vector<Key>::iterator, std::vector<Key>::iterator> range
- = std::equal_range(d->by.keyid.begin(), d->by.keyid.end(), keyid,
- _detail::ByKeyID<std::less>());
- const std::vector<Key>::iterator it
- = std::remove_if(begin(range), end(range), boost::bind(_detail::ByFingerprint<std::equal_to>(), fpr, _1));
- d->by.keyid.erase(it, end(range));
+ const auto range = std::equal_range(d->by.keyid.begin(), d->by.keyid.end(), keyid,
+ _detail::ByKeyID<std::less>());
+ const auto it = std::remove_if(range.first, range.second,
+ [fpr](const GpgME::Key &key) {
+ return _detail::ByFingerprint<std::equal_to>()(fpr, key);
+ });
+ d->by.keyid.erase(it, range.second);
}
if (const char *shortkeyid = key.shortKeyID()) {
- const std::pair<std::vector<Key>::iterator, std::vector<Key>::iterator> range
- = std::equal_range(d->by.shortkeyid.begin(), d->by.shortkeyid.end(), shortkeyid,
- _detail::ByShortKeyID<std::less>());
- const std::vector<Key>::iterator it
- = std::remove_if(begin(range), end(range), boost::bind(_detail::ByFingerprint<std::equal_to>(), fpr, _1));
- d->by.shortkeyid.erase(it, end(range));
+ const auto range = std::equal_range(d->by.shortkeyid.begin(), d->by.shortkeyid.end(), shortkeyid,
+ _detail::ByShortKeyID<std::less>());
+ const auto it = std::remove_if(range.first, range.second,
+ [fpr](const GpgME::Key &key) {
+ return _detail::ByFingerprint<std::equal_to>()(fpr, key);
+ });
+ d->by.shortkeyid.erase(it, range.second);
}
if (const char *chainid = key.chainID()) {
- const std::pair<std::vector<Key>::iterator, std::vector<Key>::iterator> range
- = std::equal_range(d->by.chainid.begin(), d->by.chainid.end(), chainid,
- _detail::ByChainID<std::less>());
- const std::pair< std::vector<Key>::iterator, std::vector<Key>::iterator > range2
- = std::equal_range(begin(range), end(range), fpr, _detail::ByFingerprint<std::less>());
- d->by.chainid.erase(begin(range2), end(range2));
+ const auto range = std::equal_range(d->by.chainid.cbegin(), d->by.chainid.cend(), chainid,
+ _detail::ByChainID<std::less>());
+ const auto range2 = std::equal_range(range.first, range.second, fpr, _detail::ByFingerprint<std::less>());
+ d->by.chainid.erase(range2.first, range2.second);
}
Q_FOREACH (const std::string &email, emails(key)) {
- const std::pair<std::vector<std::pair<std::string, Key> >::iterator, std::vector<std::pair<std::string, Key> >::iterator> range
- = std::equal_range(d->by.email.begin(), d->by.email.end(), email, ByEMail<std::less>());
- const std::vector< std::pair<std::string, Key> >::iterator it
- = std::remove_if(begin(range), end(range), boost::bind(qstricmp, fpr, boost::bind(&Key::primaryFingerprint, boost::bind(&std::pair<std::string, Key>::second, _1))) == 0);
- d->by.email.erase(it, end(range));
+ const auto range = std::equal_range(d->by.email.begin(), d->by.email.end(), email, ByEMail<std::less>());
+ const auto it = std::remove_if(range.first, range.second,
+ [fpr](const std::pair<std::string, Key> &pair) {
+ return qstricmp(fpr, pair.second.primaryFingerprint()) == 0;
+ });
+ d->by.email.erase(it, range.second);
}
Q_FOREACH (const Subkey &subkey, key.subkeys()) {
if (const char *keyid = subkey.keyID()) {
- const std::pair<std::vector<Subkey>::iterator, std::vector<Subkey>::iterator> range
- = std::equal_range(d->by.subkeyid.begin(), d->by.subkeyid.end(), keyid,
- _detail::ByKeyID<std::less>());
- const std::pair< std::vector<Subkey>::iterator, std::vector<Subkey>::iterator > range2
- = std::equal_range(begin(range), end(range), fpr, _detail::ByKeyID<std::less>());
- d->by.subkeyid.erase(begin(range2), end(range2));
+ const auto range = std::equal_range(d->by.subkeyid.cbegin(), d->by.subkeyid.cend(), keyid,
+ _detail::ByKeyID<std::less>());
+ const auto range2 = std::equal_range(range.first, range.second, fpr, _detail::ByKeyID<std::less>());
+ d->by.subkeyid.erase(range2.first, range2.second);
}
}
}
@@ -784,7 +765,9 @@ const std::vector<GpgME::Key> &KeyCache::keys() const
std::vector<Key> KeyCache::secretKeys() const
{
std::vector<Key> keys = this->keys();
- keys.erase(std::remove_if(keys.begin(), keys.end(), !boost::bind(&Key::hasSecret, _1)), keys.end());
+ keys.erase(std::remove_if(keys.begin(), keys.end(),
+ [](const Key &key) { return !key.hasSecret(); }),
+ keys.end());
return keys;
}
@@ -831,7 +814,10 @@ void KeyCache::insert(const std::vector<Key> &keys)
sorted.reserve(keys.size());
std::remove_copy_if(keys.begin(), keys.end(),
std::back_inserter(sorted),
- boost::bind(is_string_empty(), boost::bind(&Key::primaryFingerprint, _1)));
+ [](const Key &key) {
+ auto fp = key.primaryFingerprint();
+ return !fp|| !*fp;
+ });
Q_FOREACH (const Key &key, sorted) {
remove(key); // this is sub-optimal, but makes implementation from here on much easier
@@ -871,11 +857,15 @@ void KeyCache::insert(const std::vector<Key> &keys)
std::stable_sort(sorted.begin(), sorted.end(), _detail::ByChainID<std::less>());
// 3.5a: insert into chain-id index:
+ std::vector<Key> nonroot;
+ nonroot.reserve(sorted.size());
std::vector<Key> by_chainid;
by_chainid.reserve(sorted.size() + d->by.chainid.size());
- std::merge(boost::make_filter_iterator(!boost::bind(&Key::isRoot, _1), sorted.begin(), sorted.end()),
- boost::make_filter_iterator(!boost::bind(&Key::isRoot, _1), sorted.end(), sorted.end()),
- d->by.chainid.begin(), d->by.chainid.end(),
+ std::copy_if(sorted.cbegin(), sorted.cend(),
+ std::back_inserter(nonroot),
+ [](const Key &key) { return !key.isRoot(); });
+ std::merge(nonroot.cbegin(), nonroot.cend(),
+ d->by.chainid.cbegin(), d->by.chainid.cend(),
std::back_inserter(by_chainid),
lexicographically<_detail::ByChainID, _detail::ByFingerprint>());
@@ -981,7 +971,7 @@ private:
KeyCache::RefreshKeysJob::Private::Private(KeyCache *cache, RefreshKeysJob *qq) : q(qq), m_cache(cache), m_jobsPending(0)
{
- assert(m_cache);
+ Q_ASSERT(m_cache);
}
void KeyCache::RefreshKeysJob::Private::jobDone(const KeyListResult &result)
@@ -990,7 +980,7 @@ void KeyCache::RefreshKeysJob::Private::jobDone(const KeyListResult &result)
if (sender) {
sender->disconnect(q);
}
- assert(m_jobsPending > 0);
+ Q_ASSERT(m_jobsPending > 0);
--m_jobsPending;
m_mergedResult.mergeWith(result);
if (m_jobsPending > 0) {
@@ -1024,7 +1014,7 @@ void KeyCache::RefreshKeysJob::cancel()
void KeyCache::RefreshKeysJob::Private::doStart()
{
- assert(m_jobsPending == 0);
+ Q_ASSERT(m_jobsPending == 0);
m_mergedResult.mergeWith(KeyListResult(startKeyListing(GpgME::OpenPGP)));
m_mergedResult.mergeWith(KeyListResult(startKeyListing(GpgME::CMS)));
diff --git a/src/models/keycache.h b/src/models/keycache.h
index a181995..6f9b535 100644
--- a/src/models/keycache.h
+++ b/src/models/keycache.h
@@ -39,8 +39,7 @@
#include <gpgme++/global.h>
-#include <boost/shared_ptr.hpp>
-
+#include <memory>
#include <string>
#include <vector>
@@ -72,8 +71,8 @@ class KLEO_EXPORT KeyCache : public QObject
protected:
explicit KeyCache();
public:
- static boost::shared_ptr<const KeyCache> instance();
- static boost::shared_ptr<KeyCache> mutableInstance();
+ static std::shared_ptr<const KeyCache> instance();
+ static std::shared_ptr<KeyCache> mutableInstance();
~KeyCache();
@@ -85,7 +84,7 @@ public:
void remove(const GpgME::Key &key);
void remove(const std::vector<GpgME::Key> &keys);
- void addFileSystemWatcher(const boost::shared_ptr<FileSystemWatcher> &watcher);
+ void addFileSystemWatcher(const std::shared_ptr<FileSystemWatcher> &watcher);
void enableFileSystemWatcher(bool enable);
diff --git a/src/models/keylistmodel.cpp b/src/models/keylistmodel.cpp
index cfa8b2b..ceb636b 100644
--- a/src/models/keylistmodel.cpp
+++ b/src/models/keylistmodel.cpp
@@ -54,7 +54,6 @@
#include <gpgme++/key.h>
#ifndef Q_MOC_RUN // QTBUG-22829
-#include <boost/bind.hpp>
#include <boost/graph/topological_sort.hpp>
#include <boost/graph/adjacency_list.hpp>
#endif
@@ -66,10 +65,6 @@
#include <iterator>
#include <cassert>
-#ifdef __GLIBCXX__
-#include <ext/algorithm> // for is_sorted
-#endif
-
using namespace GpgME;
using namespace Kleo;
@@ -193,7 +188,9 @@ std::vector<Key> AbstractKeyListModel::keys(const QList<QModelIndex> &indexes) c
result.reserve(indexes.size());
std::transform(indexes.begin(), indexes.end(),
std::back_inserter(result),
- boost::bind(&AbstractKeyListModel::key, this, _1));
+ [this](const QModelIndex &idx) {
+ return this->key(idx);
+ });
result.erase(std::unique(result.begin(), result.end(), _detail::ByFingerprint<std::equal_to>()), result.end());
return result;
}
@@ -210,11 +207,12 @@ QModelIndex AbstractKeyListModel::index(const Key &key, int col) const
QList<QModelIndex> AbstractKeyListModel::indexes(const std::vector<Key> &keys) const
{
QList<QModelIndex> result;
+ result.reserve(keys.size());
std::transform(keys.begin(), keys.end(),
std::back_inserter(result),
- // if some compilers are complaining about ambiguous overloads, use this line instead:
- //bind( static_cast<QModelIndex(AbstractKeyListModel::*)(const Key&,int)const>( &AbstractKeyListModel::index ), this, _1, 0 ) );
- boost::bind(&AbstractKeyListModel::index, this, _1, 0));
+ [this](const Key &key) {
+ return this->index(key);
+ });
return result;
}
@@ -246,7 +244,7 @@ QList<QModelIndex> AbstractKeyListModel::addKeys(const std::vector<Key> &keys)
sorted.reserve(keys.size());
std::remove_copy_if(keys.begin(), keys.end(),
std::back_inserter(sorted),
- boost::bind(&Key::isNull, _1));
+ std::mem_fn(&Key::isNull));
std::sort(sorted.begin(), sorted.end(), _detail::ByFingerprint<std::less>());
return doAddKeys(sorted);
}
@@ -505,9 +503,8 @@ QModelIndex FlatKeyListModel::doMapFromKey(const Key &key, int col) const
QList<QModelIndex> FlatKeyListModel::doAddKeys(const std::vector<Key> &keys)
{
-#ifdef __GLIBCXX__
- assert(__gnu_cxx::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
-#endif
+ assert(std::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
+
if (keys.empty()) {
return QList<QModelIndex>();
}
@@ -788,9 +785,8 @@ static std::vector<Key> topological_sort(const std::vector<Key> &keys)
QList<QModelIndex> HierarchicalKeyListModel::doAddKeys(const std::vector<Key> &keys)
{
-#ifdef __GLIBCXX__
- assert(__gnu_cxx::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
-#endif
+ assert(std::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
+
if (keys.empty()) {
return QList<QModelIndex>();
}
diff --git a/src/models/keylistsortfilterproxymodel.cpp b/src/models/keylistsortfilterproxymodel.cpp
index 4aab2fa..e6f8902 100644
--- a/src/models/keylistsortfilterproxymodel.cpp
+++ b/src/models/keylistsortfilterproxymodel.cpp
@@ -40,12 +40,9 @@
#include <gpgme++/key.h>
-#include <boost/bind.hpp>
-
#include <cassert>
using namespace Kleo;
-using namespace boost;
using namespace GpgME;
AbstractKeyListSortFilterProxyModel::AbstractKeyListSortFilterProxyModel(QObject *p)
@@ -88,9 +85,12 @@ std::vector<Key> AbstractKeyListSortFilterProxyModel::keys(const QList<QModelInd
return std::vector<Key>();
}
QList<QModelIndex> mapped;
+ mapped.reserve(indexes.size());
std::transform(indexes.begin(), indexes.end(),
std::back_inserter(mapped),
- boost::bind(&QAbstractProxyModel::mapToSource, this, _1));
+ [this](const QModelIndex &idx) {
+ return mapToSource(idx);
+ });
return klmi->keys(mapped);
}
@@ -108,9 +108,12 @@ QList<QModelIndex> AbstractKeyListSortFilterProxyModel::indexes(const std::vecto
if (const KeyListModelInterface *const klmi = dynamic_cast<KeyListModelInterface *>(sourceModel())) {
const QList<QModelIndex> source = klmi->indexes(keys);
QList<QModelIndex> mapped;
+ mapped.reserve(source.size());
std::transform(source.begin(), source.end(),
std::back_inserter(mapped),
- boost::bind(&QAbstractProxyModel::mapFromSource, this, _1));
+ [this](const QModelIndex &idx) {
+ return mapFromSource(idx);
+ });
return mapped;
} else {
return QList<QModelIndex>();
@@ -126,7 +129,7 @@ public:
~Private() {}
private:
- shared_ptr<const KeyFilter> keyFilter;
+ std::shared_ptr<const KeyFilter> keyFilter;
};
KeyListSortFilterProxyModel::KeyListSortFilterProxyModel(QObject *p)
@@ -148,12 +151,12 @@ KeyListSortFilterProxyModel *KeyListSortFilterProxyModel::clone() const
return new KeyListSortFilterProxyModel(*this);
}
-shared_ptr<const KeyFilter> KeyListSortFilterProxyModel::keyFilter() const
+std::shared_ptr<const KeyFilter> KeyListSortFilterProxyModel::keyFilter() const
{
return d->keyFilter;
}
-void KeyListSortFilterProxyModel::setKeyFilter(const shared_ptr<const KeyFilter> &kf)
+void KeyListSortFilterProxyModel::setKeyFilter(const std::shared_ptr<const KeyFilter> &kf)
{
if (kf == d->keyFilter) {
return;
diff --git a/src/models/keylistsortfilterproxymodel.h b/src/models/keylistsortfilterproxymodel.h
index b9e279e..3feb2cb 100644
--- a/src/models/keylistsortfilterproxymodel.h
+++ b/src/models/keylistsortfilterproxymodel.h
@@ -38,7 +38,7 @@
#include <kleo_export.h>
-#include <boost/shared_ptr.hpp>
+#include <memory>
namespace GpgME
{
@@ -82,8 +82,8 @@ public:
explicit KeyListSortFilterProxyModel(QObject *parent = Q_NULLPTR);
~KeyListSortFilterProxyModel();
- boost::shared_ptr<const KeyFilter> keyFilter() const;
- void setKeyFilter(const boost::shared_ptr<const KeyFilter> &kf);
+ std::shared_ptr<const KeyFilter> keyFilter() const;
+ void setKeyFilter(const std::shared_ptr<const KeyFilter> &kf);
KeyListSortFilterProxyModel *clone() const Q_DECL_OVERRIDE;
diff --git a/src/models/subkeylistmodel.cpp b/src/models/subkeylistmodel.cpp
index 024e9eb..1321407 100644
--- a/src/models/subkeylistmodel.cpp
+++ b/src/models/subkeylistmodel.cpp
@@ -40,14 +40,11 @@
#include <QVariant>
#include <QDate>
-#include <boost/bind.hpp>
-
#include <algorithm>
#include <iterator>
using namespace GpgME;
using namespace Kleo;
-using namespace boost;
class SubkeyListModel::Private
{
@@ -116,7 +113,9 @@ std::vector<Subkey> SubkeyListModel::subkeys(const QList<QModelIndex> &indexes)
result.reserve(indexes.size());
std::transform(indexes.begin(), indexes.end(),
std::back_inserter(result),
- boost::bind(&SubkeyListModel::subkey, this, _1));
+ [this](const QModelIndex &idx) {
+ return subkey(idx);
+ });
return result;
}
@@ -133,12 +132,13 @@ QModelIndex SubkeyListModel::index(const Subkey &subkey, int col) const
QList<QModelIndex> SubkeyListModel::indexes(const std::vector<Subkey> &subkeys) const
{
QList<QModelIndex> result;
+ result.reserve(subkeys.size());
// O(N*M), but who cares...?
std::transform(subkeys.begin(), subkeys.end(),
std::back_inserter(result),
- // if some compilers are complaining about ambiguous overloads, use this line instead:
- //bind( static_cast<QModelIndex(SubKeyListModel::*)(const Subkey&,int)const>( &SubkeyListModel::index ), this, _1, 0 ) );
- boost::bind(&SubkeyListModel::index, this, _1, 0));
+ [this](const Subkey &key) {
+ return index(key);
+ });
return result;
}
diff --git a/src/tests/test_keyselectioncombo.cpp b/src/tests/test_keyselectioncombo.cpp
index 0308fea..b6b050b 100644
--- a/src/tests/test_keyselectioncombo.cpp
+++ b/src/tests/test_keyselectioncombo.cpp
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
Kleo::KeySelectionCombo combo;
layout.addWidget(&combo);
- boost::shared_ptr<const Kleo::DefaultKeyFilter> filter(new Kleo::DefaultKeyFilter);
+ std::shared_ptr<const Kleo::DefaultKeyFilter> filter(new Kleo::DefaultKeyFilter);
filter->setCanSign(parser.isSet(signingOption) ? Kleo::DefaultKeyFilter::Set : Kleo::DefaultKeyFilter::DoesNotMatter);
filter->setCanEncrypt(parser.isSet(encryptOption) ? Kleo::DefaultKeyFilter::Set : Kleo::DefaultKeyFilter::DoesNotMatter);
filter->setIsOpenPGP(parser.isSet(openpgpOption) ? Kleo::DefaultKeyFilter::Set : Kleo::DefaultKeyFilter::NotSet);
diff --git a/src/ui/directoryserviceswidget.cpp b/src/ui/directoryserviceswidget.cpp
index 827ce1a..c61e550 100644
--- a/src/ui/directoryserviceswidget.cpp
+++ b/src/ui/directoryserviceswidget.cpp
@@ -44,8 +44,6 @@
#include <QMenu>
#include <QAction>
-#include <boost/bind.hpp>
-
#include <vector>
#include <climits>
@@ -54,7 +52,6 @@
#include <functional>
using namespace Kleo;
-using namespace boost;
namespace
{
@@ -145,20 +142,6 @@ static QRect calculate_geometry(const QRect &cell, const QSize &sizeHint)
cell.width(), height);
}
-struct QUrl_compare : std::binary_function<QUrl, QUrl, bool> {
- bool operator()(const QUrl &lhs, const QUrl &rhs) const
- {
- return QString::compare(display_scheme(lhs), display_scheme(rhs), Qt::CaseInsensitive) == 0
- && QString::compare(display_host(lhs), display_host(rhs), Qt::CaseInsensitive) == 0
- && lhs.port() == rhs.port()
- && lhs.userName() == rhs.userName()
- // ... ignore password...
- && (!is_ldap_scheme(lhs)
- || lhs.query()
- == rhs.query());
- }
-};
-
class Model : public QAbstractTableModel
{
Q_OBJECT
@@ -339,7 +322,17 @@ private:
std::vector<Item>::iterator findExistingUrl(const QUrl &url)
{
return std::find_if(m_items.begin(), m_items.end(),
- boost::bind(QUrl_compare(), url, boost::bind(&Item::url, _1)));
+ [&url](const Item &item) {
+ const QUrl &lhs = url;
+ const QUrl &rhs = item.url;
+ return QString::compare(display_scheme(lhs), display_scheme(rhs), Qt::CaseInsensitive) == 0
+ && QString::compare(display_host(lhs), display_host(rhs), Qt::CaseInsensitive) == 0
+ && lhs.port() == rhs.port()
+ && lhs.userName() == rhs.userName()
+ // ... ignore password...
+ && (!is_ldap_scheme(lhs)
+ || lhs.query() == rhs.query());
+ });
}
};
diff --git a/src/ui/keyselectioncombo.cpp b/src/ui/keyselectioncombo.cpp
index 1eb1c08..45898f8 100644
--- a/src/ui/keyselectioncombo.cpp
+++ b/src/ui/keyselectioncombo.cpp
@@ -228,7 +228,7 @@ public:
Kleo::AbstractKeyListModel *model;
Kleo::KeyListSortFilterProxyModel *sortFilterProxy;
ProxyModel *proxyModel;
- boost::shared_ptr<Kleo::KeyCache> cache;
+ std::shared_ptr<Kleo::KeyCache> cache;
QString defaultKey;
bool wasEnabled;
@@ -302,13 +302,13 @@ void KeySelectionCombo::init()
}
-void KeySelectionCombo::setKeyFilter(const boost::shared_ptr<const KeyFilter> &kf)
+void KeySelectionCombo::setKeyFilter(const std::shared_ptr<const KeyFilter> &kf)
{
d->sortFilterProxy->setKeyFilter(kf);
setCurrentKey(d->defaultKey);
}
-boost::shared_ptr<const KeyFilter> KeySelectionCombo::keyFilter() const
+std::shared_ptr<const KeyFilter> KeySelectionCombo::keyFilter() const
{
return d->sortFilterProxy->keyFilter();
}
diff --git a/src/ui/keyselectioncombo.h b/src/ui/keyselectioncombo.h
index 402e81f..81683e7 100644
--- a/src/ui/keyselectioncombo.h
+++ b/src/ui/keyselectioncombo.h
@@ -26,7 +26,7 @@
#include <kleo_export.h>
#include <libkleo/enum.h>
-#include <boost/shared_ptr.hpp>
+#include <memory>
namespace GpgME
{
@@ -46,8 +46,8 @@ public:
explicit KeySelectionCombo(QWidget *parent = Q_NULLPTR);
virtual ~KeySelectionCombo();
- void setKeyFilter(const boost::shared_ptr<const KeyFilter> &kf);
- boost::shared_ptr<const KeyFilter> keyFilter() const;
+ void setKeyFilter(const std::shared_ptr<const KeyFilter> &kf);
+ std::shared_ptr<const KeyFilter> keyFilter() const;
void setIdFilter(const QString &id);
QString idFilter() const;
diff --git a/src/utils/classify.cpp b/src/utils/classify.cpp
index aba8bbe..1ea878e 100644
--- a/src/utils/classify.cpp
+++ b/src/utils/classify.cpp
@@ -44,19 +44,13 @@
#include <QMap>
#include <QRegularExpression>
-#include <boost/range.hpp>
-
#include <gpgme++/data.h>
#include <qgpgme/dataprovider.h>
-#ifdef __GLIBCXX__
-# include <ext/algorithm>
-#endif
-
#include <cassert>
+#include <iterator>
#include <functional>
-using namespace boost;
using namespace Kleo::Class;
namespace
@@ -188,23 +182,21 @@ unsigned int Kleo::classify(const QStringList &fileNames)
static unsigned int classifyExtension(const QFileInfo fi)
{
- const _classification *const it = qBinaryFind(begin(classifications), end(classifications),
+ const _classification *const it = qBinaryFind(std::begin(classifications), std::end(classifications),
fi.suffix().toLatin1().constData(),
ByExtension<std::less>());
- if (it != end(classifications))
+ if (it != std::end(classifications))
if (!(it->classification & ExamineContentHint)) {
return it->classification;
}
- return it == end(classifications) ? defaultClassification
+ return it == std::end(classifications) ? defaultClassification
: it->classification;
}
unsigned int Kleo::classify(const QString &filename)
{
-#ifdef __GLIBCXX__
- assert(__gnu_cxx::is_sorted(begin(classifications), end(classifications), ByExtension<std::less>()));
-#endif
+ assert(std::is_sorted(std::begin(classifications), std::end(classifications), ByExtension<std::less>()));
const QFileInfo fi(filename);
@@ -244,9 +236,7 @@ unsigned int Kleo::classify(const QString &filename)
static unsigned int classifyContentInteral(const QByteArray &data)
{
-#ifdef __GLIBCXX__
- assert(__gnu_cxx::is_sorted(begin(content_classifications), end(content_classifications), ByContent<std::less>(100)));
-#endif
+ assert(std::is_sorted(std::begin(content_classifications), std::end(content_classifications), ByContent<std::less>(100)));
static const char beginString[] = "-----BEGIN ";
static const QByteArrayMatcher beginMatcher(beginString);
@@ -267,10 +257,10 @@ static unsigned int classifyContentInteral(const QByteArray &data)
}
const _content_classification *const cit
- = qBinaryFind(begin(content_classifications), end(content_classifications),
+ = qBinaryFind(std::begin(content_classifications), std::end(content_classifications),
data.data() + pos, ByContent<std::less>(epos - pos));
- if (cit != end(content_classifications)) {
+ if (cit != std::end(content_classifications)) {
return cit->classification | (pgp ? OpenPGP : CMS);
}
return defaultClassification;
@@ -366,7 +356,7 @@ QString Kleo::findSignedData(const QString &signatureFileName)
QStringList Kleo::findSignatures(const QString &signedDataFileName)
{
QStringList result;
- for (unsigned int i = 0, end = size(classifications); i < end; ++i)
+ for (unsigned int i = 0, end = sizeof(classifications) / sizeof(_classification); i < end; ++i)
if (classifications[i].classification & DetachedSignature) {
const QString candiate = signedDataFileName + QLatin1Char('.') + QLatin1String(classifications[i].extension);
if (QFile::exists(candiate)) {
@@ -384,9 +374,9 @@ QString Kleo::outputFileName(const QString &inputFileName)
{
const QFileInfo fi(inputFileName);
- if (qBinaryFind(begin(classifications), end(classifications),
+ if (qBinaryFind(std::begin(classifications), std::end(classifications),
fi.suffix().toLatin1().constData(),
- ByExtension<std::less>()) == end(classifications)) {
+ ByExtension<std::less>()) == std::end(classifications)) {
return inputFileName + QLatin1String(".out");
} else {
return chopped(inputFileName, 4);
diff --git a/src/utils/filesystemwatcher.cpp b/src/utils/filesystemwatcher.cpp
index cbee718..6492307 100644
--- a/src/utils/filesystemwatcher.cpp
+++ b/src/utils/filesystemwatcher.cpp
@@ -41,13 +41,10 @@
#include <QTimer>
#include <QDir>
-#include <boost/bind.hpp>
-
#include <set>
#include <cassert>
using namespace Kleo;
-using namespace boost;
class FileSystemWatcher::Private
{
@@ -126,15 +123,21 @@ static QStringList list_dir_absolute(const QString &path, const QStringList &bla
QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
QStringList::iterator end =
std::remove_if(entries.begin(), entries.end(),
- boost::bind(is_blacklisted, _1, cref(blacklist)));
+ [&blacklist](const QString &entry) {
+ return is_blacklisted(entry, blacklist);
+ });
if (!whitelist.empty())
end = std::remove_if(entries.begin(), end,
- !boost::bind(is_whitelisted, _1, cref(whitelist)));
+ [&whitelist](const QString &entry) {
+ return !is_whitelisted(entry, whitelist);
+ });
entries.erase(end, entries.end());
- kdtools::sort(entries);
+ std::sort(entries.begin(), entries.end());
std::transform(entries.begin(), entries.end(), entries.begin(),
- boost::bind(&QDir::absoluteFilePath, &dir, _1));
+ [&dir](const QString &entry) {
+ return dir.absoluteFilePath(entry);
+ });
return entries;
}
@@ -261,7 +264,9 @@ void FileSystemWatcher::blacklistFiles(const QStringList &paths)
QStringList blacklisted;
d->m_paths.erase(kdtools::separate_if(d->m_paths.begin(), d->m_paths.end(),
std::back_inserter(blacklisted), d->m_paths.begin(),
- boost::bind(is_blacklisted, _1, cref(d->m_blacklist))).second, d->m_paths.end());
+ [this](const QString &path) {
+ return is_blacklisted(path, d->m_blacklist);
+ }).second, d->m_paths.end());
if (d->m_watcher && !blacklisted.empty()) {
d->m_watcher->removePaths(blacklisted);
}