[Pkg-gnupg-commit] [gpgme] 322/412: cpp: Add ostream operators for key and uid
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Sep 22 21:27:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gpgme.
commit 444d85ace0dddff5c511961927052d9946035b00
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Sep 5 11:57:09 2016 +0200
cpp: Add ostream operators for key and uid
* lang/cpp/src/key.cpp (Key, UserID): Add ostream operator.
* lang/cpp/src/key.h: Update accordingly.
--
This is helpful debugging / showing the state of a key / uid and
tofuinfo.
---
lang/cpp/src/key.cpp | 39 +++++++++++++++++++++++++++++++++++++++
lang/cpp/src/key.h | 3 +++
2 files changed, 42 insertions(+)
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 6f40f66..204eeca 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -28,6 +28,8 @@
#include <gpgme.h>
#include <string.h>
+#include <istream>
+#include <iterator>
const GpgME::Key::Null GpgME::Key::null;
@@ -848,4 +850,41 @@ const char *UserID::Signature::policyURL() const
return 0;
}
+std::ostream &operator<<(std::ostream &os, const UserID &uid)
+{
+ os << "GpgME::UserID(";
+ if (!uid.isNull()) {
+ os << "\n name: " << protect(uid.name())
+ << "\n email: " << protect(uid.email())
+ << "\n comment: " << protect(uid.comment())
+ << "\n validity: " << uid.validityAsString()
+ << "\n revoked: " << uid.isRevoked()
+ << "\n invalid: " << uid.isInvalid()
+ << "\n numsigs: " << uid.numSignatures()
+ << "\n tofuinfo:\n" << uid.tofuInfo();
+ }
+ return os << ')';
+}
+
+std::ostream &operator<<(std::ostream &os, const Key &key)
+{
+ os << "GpgME::Key(";
+ if (!key.isNull()) {
+ os << "\n protocol: " << protect(key.protocolAsString())
+ << "\n ownertrust: " << key.ownerTrustAsString()
+ << "\n issuer: " << protect(key.issuerName())
+ << "\n fingerprint:" << protect(key.primaryFingerprint())
+ << "\n listmode: " << key.keyListMode()
+ << "\n canSign: " << key.canReallySign()
+ << "\n canEncrypt: " << key.canEncrypt()
+ << "\n canCertify: " << key.canCertify()
+ << "\n canAuth: " << key.canAuthenticate()
+ << "\n uids:\n";
+ const std::vector<UserID> uids = key.userIDs();
+ std::copy(uids.begin(), uids.end(),
+ std::ostream_iterator<UserID>(os, "\n"));
+ }
+ return os << ')';
+}
+
} // namespace GpgME
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index e8d7ee2..85b16df 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -391,6 +391,9 @@ private:
gpgme_key_sig_t sig;
};
+GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const UserID &uid);
+GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Key &key);
+
} // namespace GpgME
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Key)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list