From 1bb162a54ba480413c4da07f2578efe6860494c0 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Mon, 11 Apr 2016 17:02:04 +0200 Subject: [PATCH] Cpp: Add string comparators for keys * lang/cpp/src/global.h (GPGMEPP_MAKE_STRCMP): New. (_gpgmepp_strcmp): NULL save wrapper around std::strcmp. * lang/cpp/src/key.h: Add comparators for various attributes. -- This was taken from libkleo predicates.h. Appears generally useful. --- lang/cpp/src/global.h | 51 +++++++++++++++++++++++++++++++++++++++++++ lang/cpp/src/key.h | 5 +++++ 2 files changed, 56 insertions(+) diff --git a/lang/cpp/src/global.h b/lang/cpp/src/global.h index b48ec074..9be5202c 100644 --- a/lang/cpp/src/global.h +++ b/lang/cpp/src/global.h @@ -28,6 +28,7 @@ #include "gpgmepp_export.h" #include +#include namespace GpgME { @@ -152,4 +153,54 @@ GPGMEPP_EXPORT bool hasFeature(unsigned long feature, unsigned long feature2); operator unspecified_bool_type() const { return ( Cond ) ? &__safe_bool_dummy__::nonnull : 0 ; } # endif +inline int _gpgmepp_strcmp(const char *s1, const char *s2) +{ + return s1 ? s2 ? std::strcmp(s1, s2) : 1 : s2 ? -1 : 0; +} + +#define _GPGMEPP_MAKE_STRCMP( Name, expr, cmp ) \ + template