aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp/src/key.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lang/cpp/src/key.cpp')
-rw-r--r--lang/cpp/src/key.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 6f40f666..204eeca2 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