12#include <gpgme++/key.h>
25inline int mystrcmp(
const char *s1,
const char *s2)
28 return s1 ? s2 ? strcmp(s1, s2) : 1 : s2 ? -1 : 0;
31#define make_comparator_str_impl(Name, expr, cmp) \
32 template<template<typename U> class Op> \
34 typedef bool result_type; \
36 bool operator()(const char *lhs, const char *rhs) const \
38 return Op<int>()(cmp, 0); \
41 bool operator()(const std::string &lhs, const std::string &rhs) const \
43 return operator()(lhs.c_str(), rhs.c_str()); \
45 bool operator()(const char *lhs, const std::string &rhs) const \
47 return operator()(lhs, rhs.c_str()); \
49 bool operator()(const std::string &lhs, const char *rhs) const \
51 return operator()(lhs.c_str(), rhs); \
54 template<typename T> \
55 bool operator()(const T &lhs, const T &rhs) const \
57 return operator()((lhs expr), (rhs expr)); \
59 template<typename T> \
60 bool operator()(const T &lhs, const char *rhs) const \
62 return operator()((lhs expr), rhs); \
64 template<typename T> \
65 bool operator()(const char *lhs, const T &rhs) const \
67 return operator()(lhs, (rhs expr)); \
69 template<typename T> \
70 bool operator()(const T &lhs, const std::string &rhs) const \
72 return operator()((lhs expr), rhs); \
74 template<typename T> \
75 bool operator()(const std::string &lhs, const T &rhs) const \
77 return operator()(lhs, (rhs expr)); \
81#define make_comparator_str_fast(Name, expr) make_comparator_str_impl(Name, expr, _detail::mystrcmp(lhs, rhs))
82#define make_comparator_str(Name, expr) make_comparator_str_impl(Name, expr, qstricmp(lhs, rhs))
84make_comparator_str_fast(ByFingerprint, .primaryFingerprint());
85make_comparator_str_fast(BySubkeyFingerprint, .fingerprint());
86make_comparator_str_fast(ByKeyID, .keyID());
87make_comparator_str_fast(ByChainID, .chainID());
88make_comparator_str_fast(ByKeyGrip, .keyGrip());
93 std::sort(t.begin(), t.end(), ByFingerprint<std::less>());
97void remove_duplicates_by_fpr(T &t)
99 t.erase(std::unique(t.begin(), t.end(), ByFingerprint<std::equal_to>()), t.end());
103T union_by_fpr(
const T &t1,
const T &t2)
106 result.reserve(t1.size() + t2.size());
107 std::set_union(t1.begin(),
111 std::back_inserter(result),
112 ByFingerprint<std::less>());
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:14 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.