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.hpp b/src/security/pib/key.hpp
index 90f4f5c..fbbed24 100644
--- a/src/security/pib/key.hpp
+++ b/src/security/pib/key.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -125,6 +125,7 @@
/**
* @brief Check if the Key instance is valid.
*/
+ explicit
operator bool() const;
/**
@@ -181,8 +182,21 @@
weak_ptr<detail::KeyImpl> m_impl;
friend class v2::KeyChain;
+ friend bool operator!=(const Key&, const Key&);
};
+bool
+operator!=(const Key& lhs, const Key& rhs);
+
+inline bool
+operator==(const Key& lhs, const Key& rhs)
+{
+ return !(lhs != rhs);
+}
+
+std::ostream&
+operator<<(std::ostream& os, const Key& key);
+
} // namespace pib
using pib::Key;