security: Identity/Key comparison operators
This commit adds ==, !=, and stream insertion operators to
Identity and Key types, so that `ndnsec list` can display
default identity and key properly.
Also, a missing assignment is added to `ndnsec list` routine.
refs #4085
Change-Id: I025af1d6281acb9e9261461520bbd74af53b811e
diff --git a/src/security/pib/key.cpp b/src/security/pib/key.cpp
index 3d7b83c..7396a5a 100644
--- a/src/security/pib/key.cpp
+++ b/src/security/pib/key.cpp
@@ -123,6 +123,24 @@
return impl;
}
+bool
+operator!=(const Key& lhs, const Key& rhs)
+{
+ return lhs.m_impl.owner_before(rhs.m_impl) || rhs.m_impl.owner_before(lhs.m_impl);
+}
+
+std::ostream&
+operator<<(std::ostream& os, const Key& key)
+{
+ if (key) {
+ os << key.getName();
+ }
+ else {
+ os << "(empty)";
+ }
+ return os;
+}
+
} // namespace pib
namespace v2 {