tools: replace boost::any usage with ndn::any
Change-Id: I7048a64b7c17353037ea9a64a11366d2fae6fd49
diff --git a/tools/nfdc/command-arguments.hpp b/tools/nfdc/command-arguments.hpp
index a949f99..164a672 100644
--- a/tools/nfdc/command-arguments.hpp
+++ b/tools/nfdc/command-arguments.hpp
@@ -31,7 +31,6 @@
#include <ndn-cxx/encoding/nfd-constants.hpp>
-#include <boost/any.hpp>
#include <boost/logic/tribool.hpp>
namespace nfd {
@@ -43,19 +42,9 @@
/** \brief contains named command arguments
*/
-class CommandArguments : public std::map<std::string, boost::any>
+class CommandArguments : public std::map<std::string, ndn::any>
{
public:
- /** \return the argument value, or a default value if the argument is omitted on command line
- */
- template<typename T>
- T
- get(const std::string& key, const T& defaultValue = T()) const
- {
- auto i = find(key);
- return i == end() ? defaultValue : boost::any_cast<T>(i->second);
- }
-
/** \return the argument value, or nullopt if the argument is omitted on command line
*/
template<typename T>
@@ -63,10 +52,16 @@
getOptional(const std::string& key) const
{
auto i = find(key);
- if (i == end()) {
- return nullopt;
- }
- return boost::any_cast<T>(i->second);
+ return i == end() ? nullopt : ndn::make_optional(ndn::any_cast<T>(i->second));
+ }
+
+ /** \return the argument value, or a default value if the argument is omitted on command line
+ */
+ template<typename T>
+ T
+ get(const std::string& key, const T& defaultValue = T()) const
+ {
+ return getOptional<T>(key).value_or(defaultValue);
}
/** \brief get an optional boolean argument as tribool
@@ -76,10 +71,7 @@
getTribool(const std::string& key) const
{
auto value = getOptional<bool>(key);
- if (value) {
- return *value;
- }
- return boost::logic::indeterminate;
+ return value ? boost::logic::tribool(*value) : boost::logic::indeterminate;
}
};