DER: In visitor code, use ndnboost::any. We can use ndnboost::any because this is an internal header and will not conflict with the application if it uses boost::any.
diff --git a/include/Makefile.am b/include/Makefile.am
index 8ea2630..fa88f74 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -75,6 +75,7 @@
ndnboost/algorithm/string/sequence_traits.hpp \
ndnboost/algorithm/string/yes_no_type.hpp \
ndnboost/aligned_storage.hpp \
+ ndnboost/any.hpp \
ndnboost/array.hpp \
ndnboost/assert.hpp \
ndnboost/bind/apply.hpp \
diff --git a/include/Makefile.in b/include/Makefile.in
index 82fc5c2..18313c0 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -392,6 +392,7 @@
ndnboost/algorithm/string/sequence_traits.hpp \
ndnboost/algorithm/string/yes_no_type.hpp \
ndnboost/aligned_storage.hpp \
+ ndnboost/any.hpp \
ndnboost/array.hpp \
ndnboost/assert.hpp \
ndnboost/bind/apply.hpp \
diff --git a/include/ndn-cpp/common.hpp b/include/ndn-cpp/common.hpp
index a4ced37..2d47c30 100644
--- a/include/ndn-cpp/common.hpp
+++ b/include/ndn-cpp/common.hpp
@@ -23,8 +23,8 @@
namespace ndn { namespace ptr_lib = boost; }
#else
// Use the boost header files in this distribution that were extracted with:
-// cd <INCLUDE DIRECTORY WITH boost SUBDIRECTORY>
-// dist/bin/bcp --namespace=ndnboost shared_ptr make_shared weak_ptr function bind <NDN-CPP ROOT>/include
+// cd <BOOST DEVELOPMENT DIRECTORY WITH boost SUBDIRECTORY>
+// dist/bin/bcp --namespace=ndnboost shared_ptr make_shared weak_ptr function bind any <NDN-CPP ROOT>/include
// cd <NDN-CPP ROOT>/include
// mv boost ndnboost
// cd ndnboost
diff --git a/include/ndnboost/any.hpp b/include/ndnboost/any.hpp
new file mode 100644
index 0000000..2419c6d
--- /dev/null
+++ b/include/ndnboost/any.hpp
@@ -0,0 +1,312 @@
+// See http://www.boost.org/libs/any for Documentation.
+
+#ifndef BOOST_ANY_INCLUDED
+#define BOOST_ANY_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+// what: variant type ndnboost::any
+// who: contributed by Kevlin Henney,
+// with features contributed and bugs found by
+// Antony Polukhin, Ed Brey, Mark Rodgers,
+// Peter Dimov, and James Curran
+// when: July 2001, Aplril 2013
+
+#include <algorithm>
+#include <typeinfo>
+
+#include "ndnboost/config.hpp"
+#include <ndnboost/type_traits/remove_reference.hpp>
+#include <ndnboost/type_traits/is_reference.hpp>
+#include <ndnboost/throw_exception.hpp>
+#include <ndnboost/static_assert.hpp>
+#include <ndnboost/utility/enable_if.hpp>
+#include <ndnboost/type_traits/is_same.hpp>
+
+// See boost/python/type_id.hpp
+// TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp
+# if (defined(__GNUC__) && __GNUC__ >= 3) \
+ || defined(_AIX) \
+ || ( defined(__sgi) && defined(__host_mips)) \
+ || (defined(__hpux) && defined(__HP_aCC)) \
+ || (defined(linux) && defined(__INTEL_COMPILER) && defined(__ICC))
+# define BOOST_AUX_ANY_TYPE_ID_NAME
+#include <cstring>
+# endif
+
+namespace ndnboost
+{
+ class any
+ {
+ public: // structors
+
+ any() BOOST_NOEXCEPT
+ : content(0)
+ {
+ }
+
+ template<typename ValueType>
+ any(const ValueType & value)
+ : content(new holder<ValueType>(value))
+ {
+ }
+
+ any(const any & other)
+ : content(other.content ? other.content->clone() : 0)
+ {
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ // Move constructor
+ any(any&& other) BOOST_NOEXCEPT
+ : content(other.content)
+ {
+ other.content = 0;
+ }
+
+ // Perfect forwarding of ValueType
+ template<typename ValueType>
+ any(ValueType&& value, typename ndnboost::disable_if<ndnboost::is_same<any&, ValueType> >::type* = 0)
+ : content(new holder< typename remove_reference<ValueType>::type >(static_cast<ValueType&&>(value)))
+ {
+ }
+#endif
+
+ ~any() BOOST_NOEXCEPT
+ {
+ delete content;
+ }
+
+ public: // modifiers
+
+ any & swap(any & rhs) BOOST_NOEXCEPT
+ {
+ std::swap(content, rhs.content);
+ return *this;
+ }
+
+
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+ template<typename ValueType>
+ any & operator=(const ValueType & rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+ any & operator=(any rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+#else
+ any & operator=(const any& rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+ // move assignement
+ any & operator=(any&& rhs) BOOST_NOEXCEPT
+ {
+ rhs.swap(*this);
+ any().swap(rhs);
+ return *this;
+ }
+
+ // Perfect forwarding of ValueType
+ template <class ValueType>
+ any & operator=(ValueType&& rhs)
+ {
+ any(static_cast<ValueType&&>(rhs)).swap(*this);
+ return *this;
+ }
+#endif
+
+ public: // queries
+
+ bool empty() const BOOST_NOEXCEPT
+ {
+ return !content;
+ }
+
+ const std::type_info & type() const
+ {
+ return content ? content->type() : typeid(void);
+ }
+
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+ private: // types
+#else
+ public: // types (public so any_cast can be non-friend)
+#endif
+
+ class placeholder
+ {
+ public: // structors
+
+ virtual ~placeholder()
+ {
+ }
+
+ public: // queries
+
+ virtual const std::type_info & type() const = 0;
+
+ virtual placeholder * clone() const = 0;
+
+ };
+
+ template<typename ValueType>
+ class holder : public placeholder
+ {
+ public: // structors
+
+ holder(const ValueType & value)
+ : held(value)
+ {
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ holder(ValueType&& value)
+ : held(static_cast< ValueType&& >(value))
+ {
+ }
+#endif
+ public: // queries
+
+ virtual const std::type_info & type() const
+ {
+ return typeid(ValueType);
+ }
+
+ virtual placeholder * clone() const
+ {
+ return new holder(held);
+ }
+
+ public: // representation
+
+ ValueType held;
+
+ private: // intentionally left unimplemented
+ holder & operator=(const holder &);
+ };
+
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+
+ private: // representation
+
+ template<typename ValueType>
+ friend ValueType * any_cast(any *) BOOST_NOEXCEPT;
+
+ template<typename ValueType>
+ friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT;
+
+#else
+
+ public: // representation (public so any_cast can be non-friend)
+
+#endif
+
+ placeholder * content;
+
+ };
+
+ inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT
+ {
+ lhs.swap(rhs);
+ }
+
+ class bad_any_cast : public std::bad_cast
+ {
+ public:
+ virtual const char * what() const throw()
+ {
+ return "ndnboost::bad_any_cast: "
+ "failed conversion using ndnboost::any_cast";
+ }
+ };
+
+ template<typename ValueType>
+ ValueType * any_cast(any * operand) BOOST_NOEXCEPT
+ {
+ return operand &&
+#ifdef BOOST_AUX_ANY_TYPE_ID_NAME
+ std::strcmp(operand->type().name(), typeid(ValueType).name()) == 0
+#else
+ operand->type() == typeid(ValueType)
+#endif
+ ? &static_cast<any::holder<ValueType> *>(operand->content)->held
+ : 0;
+ }
+
+ template<typename ValueType>
+ inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT
+ {
+ return any_cast<ValueType>(const_cast<any *>(operand));
+ }
+
+ template<typename ValueType>
+ ValueType any_cast(any & operand)
+ {
+ typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ // If 'nonref' is still reference type, it means the user has not
+ // specialized 'remove_reference'.
+
+ // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro
+ // to generate specialization of remove_reference for your class
+ // See type traits library documentation for details
+ BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
+#endif
+
+ nonref * result = any_cast<nonref>(&operand);
+ if(!result)
+ ndnboost::throw_exception(bad_any_cast());
+ return *result;
+ }
+
+ template<typename ValueType>
+ inline ValueType any_cast(const any & operand)
+ {
+ typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ // The comment in the above version of 'any_cast' explains when this
+ // assert is fired and what to do.
+ BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
+#endif
+
+ return any_cast<const nonref &>(const_cast<any &>(operand));
+ }
+
+ // Note: The "unsafe" versions of any_cast are not part of the
+ // public interface and may be removed at any time. They are
+ // required where we know what type is stored in the any and can't
+ // use typeid() comparison, e.g., when our types may travel across
+ // different shared libraries.
+ template<typename ValueType>
+ inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT
+ {
+ return &static_cast<any::holder<ValueType> *>(operand->content)->held;
+ }
+
+ template<typename ValueType>
+ inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT
+ {
+ return unsafe_any_cast<ValueType>(const_cast<any *>(operand));
+ }
+}
+
+// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#endif
diff --git a/ndn-cpp/encoding/der/der.hpp b/ndn-cpp/encoding/der/der.hpp
index d85aa6e..065cfd6 100644
--- a/ndn-cpp/encoding/der/der.hpp
+++ b/ndn-cpp/encoding/der/der.hpp
@@ -111,9 +111,9 @@
}
virtual void accept(VoidNoArgumentsVisitor& visitor) = 0;
- virtual void accept(VoidVisitor& visitor, Any param) = 0;
- virtual Any accept(NoArgumentsVisitor& visitor) = 0;
- virtual Any accept(Visitor& visitor, Any param) = 0;
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) = 0;
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) = 0;
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) = 0;
protected:
void
@@ -206,9 +206,9 @@
~DerBool();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
@@ -224,9 +224,9 @@
~DerInteger();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
@@ -242,9 +242,9 @@
~DerBitString();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
@@ -262,9 +262,9 @@
~DerOctetString();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
@@ -281,9 +281,9 @@
~DerNull();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
@@ -304,9 +304,9 @@
~DerOid();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
int
decode128(int& offset);
@@ -332,9 +332,9 @@
~DerSequence();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
@@ -352,9 +352,9 @@
~DerPrintableString();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
//0x1b
@@ -369,9 +369,9 @@
~DerGtime();
virtual void accept(VoidNoArgumentsVisitor& visitor) { visitor.visit(*this); }
- virtual void accept(VoidVisitor& visitor, Any param) { visitor.visit(*this, param); }
- virtual Any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
- virtual Any accept(Visitor& visitor, Any param) { return visitor.visit(*this, param); }
+ virtual void accept(VoidVisitor& visitor, ndnboost::any param) { visitor.visit(*this, param); }
+ virtual ndnboost::any accept(NoArgumentsVisitor& visitor) { return visitor.visit(*this); }
+ virtual ndnboost::any accept(Visitor& visitor, ndnboost::any param) { return visitor.visit(*this, param); }
};
diff --git a/ndn-cpp/encoding/der/visitor/no-arguments-visitor.cpp b/ndn-cpp/encoding/der/visitor/no-arguments-visitor.cpp
index 3ea819d..06f2157 100644
--- a/ndn-cpp/encoding/der/visitor/no-arguments-visitor.cpp
+++ b/ndn-cpp/encoding/der/visitor/no-arguments-visitor.cpp
@@ -12,41 +12,41 @@
namespace der
{
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerBool& derBool)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerInteger& derInteger)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerPrintableString& derPStr)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerBitString& derBStr)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerNull& derNull)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerOctetString& derOStr)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerOid& derOid)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerSequence& derSeq)
-{ return Any(0); }
+{ return ndnboost::any(0); }
-Any
+ndnboost::any
NoArgumentsVisitor::visit(DerGtime& derGtime)
-{ return Any(0); }
+{ return ndnboost::any(0); }
} // der
diff --git a/ndn-cpp/encoding/der/visitor/no-arguments-visitor.hpp b/ndn-cpp/encoding/der/visitor/no-arguments-visitor.hpp
index 61b0a65..8358066 100644
--- a/ndn-cpp/encoding/der/visitor/no-arguments-visitor.hpp
+++ b/ndn-cpp/encoding/der/visitor/no-arguments-visitor.hpp
@@ -18,15 +18,15 @@
class NoArgumentsVisitor
{
public:
- virtual Any visit(DerBool& ) = 0;
- virtual Any visit(DerInteger& ) = 0;
- virtual Any visit(DerPrintableString&) = 0;
- virtual Any visit(DerBitString& ) = 0;
- virtual Any visit(DerNull& ) = 0;
- virtual Any visit(DerOctetString& ) = 0;
- virtual Any visit(DerOid& ) = 0;
- virtual Any visit(DerSequence& ) = 0;
- virtual Any visit(DerGtime& ) = 0;
+ virtual ndnboost::any visit(DerBool& ) = 0;
+ virtual ndnboost::any visit(DerInteger& ) = 0;
+ virtual ndnboost::any visit(DerPrintableString&) = 0;
+ virtual ndnboost::any visit(DerBitString& ) = 0;
+ virtual ndnboost::any visit(DerNull& ) = 0;
+ virtual ndnboost::any visit(DerOctetString& ) = 0;
+ virtual ndnboost::any visit(DerOid& ) = 0;
+ virtual ndnboost::any visit(DerSequence& ) = 0;
+ virtual ndnboost::any visit(DerGtime& ) = 0;
};
} // der
diff --git a/ndn-cpp/encoding/der/visitor/simple-visitor.cpp b/ndn-cpp/encoding/der/visitor/simple-visitor.cpp
index 5845e22..7007505 100644
--- a/ndn-cpp/encoding/der/visitor/simple-visitor.cpp
+++ b/ndn-cpp/encoding/der/visitor/simple-visitor.cpp
@@ -17,7 +17,7 @@
namespace der
{
-Any
+ndnboost::any
SimpleVisitor::visit(DerBool& derBool)
{
bool result = true;
@@ -25,41 +25,41 @@
if(0 == derBool.getPayload()[0])
result = false;
- return Any(result);
+ return ndnboost::any(result);
}
-Any
+ndnboost::any
SimpleVisitor::visit(DerInteger& derInteger)
{
- return Any(derInteger.getPayload());
+ return ndnboost::any(derInteger.getPayload());
}
-Any
+ndnboost::any
SimpleVisitor::visit(DerPrintableString& derPStr)
{
- return Any(string((const char*)&derPStr.getPayload()[0], derPStr.getPayload().size()));
+ return ndnboost::any(string((const char*)&derPStr.getPayload()[0], derPStr.getPayload().size()));
}
-Any
+ndnboost::any
SimpleVisitor::visit(DerBitString& derBStr)
{
- return Any(derBStr.getPayload());
+ return ndnboost::any(derBStr.getPayload());
}
-Any
+ndnboost::any
SimpleVisitor::visit(DerNull& derNull)
{
- return Any();
+ return ndnboost::any();
}
-Any
+ndnboost::any
SimpleVisitor::visit(DerOctetString& derOStr)
{
vector<uint8_t> result(derOStr.getPayload());
- return Any(result);
+ return ndnboost::any(result);
}
-Any
+ndnboost::any
SimpleVisitor::visit(DerOid& derOid)
{
vector<int> intList;
@@ -78,21 +78,21 @@
intList.push_back(derOid.decode128(offset));
}
- return Any(OID(intList));
+ return ndnboost::any(OID(intList));
}
-Any
+ndnboost::any
SimpleVisitor::visit(DerSequence& derSeq)
{
- return Any();
+ return ndnboost::any();
}
#if 0 // TODO: Implmenent alternative to boost::posix_time::from_iso_string.
-Any
+ndnboost::any
SimpleVisitor::visit(DerGtime& derGtime)
{
string str((const char*)&derGtime.getPayload()[0], derGtime.getPayload().size());
- return Any(boost::posix_time::from_iso_string(str.substr(0, 8) + "T" + str.substr(8, 6)));
+ return ndnboost::any(boost::posix_time::from_iso_string(str.substr(0, 8) + "T" + str.substr(8, 6)));
}
#endif
diff --git a/ndn-cpp/encoding/der/visitor/simple-visitor.hpp b/ndn-cpp/encoding/der/visitor/simple-visitor.hpp
index d54c499..73991f2 100644
--- a/ndn-cpp/encoding/der/visitor/simple-visitor.hpp
+++ b/ndn-cpp/encoding/der/visitor/simple-visitor.hpp
@@ -18,15 +18,15 @@
class SimpleVisitor : public NoArgumentsVisitor
{
public:
- virtual Any visit(DerBool& ) = 0;
- virtual Any visit(DerInteger& ) = 0;
- virtual Any visit(DerPrintableString&) = 0;
- virtual Any visit(DerBitString& ) = 0;
- virtual Any visit(DerNull& ) = 0;
- virtual Any visit(DerOctetString& ) = 0;
- virtual Any visit(DerOid& ) = 0;
- virtual Any visit(DerSequence& ) = 0;
- virtual Any visit(DerGtime& ) = 0;
+ virtual ndnboost::any visit(DerBool& ) = 0;
+ virtual ndnboost::any visit(DerInteger& ) = 0;
+ virtual ndnboost::any visit(DerPrintableString&) = 0;
+ virtual ndnboost::any visit(DerBitString& ) = 0;
+ virtual ndnboost::any visit(DerNull& ) = 0;
+ virtual ndnboost::any visit(DerOctetString& ) = 0;
+ virtual ndnboost::any visit(DerOid& ) = 0;
+ virtual ndnboost::any visit(DerSequence& ) = 0;
+ virtual ndnboost::any visit(DerGtime& ) = 0;
};
} // der
diff --git a/ndn-cpp/encoding/der/visitor/visitor.hpp b/ndn-cpp/encoding/der/visitor/visitor.hpp
index 6d04703..5965ccb 100644
--- a/ndn-cpp/encoding/der/visitor/visitor.hpp
+++ b/ndn-cpp/encoding/der/visitor/visitor.hpp
@@ -9,18 +9,13 @@
#ifndef NDN_DER_VISITOR_HPP
#define NDN_DER_VISITOR_HPP
+// We can use ndnboost::any because this is an internal header and will not conflict with the application if it uses boost::any.
+#include <ndnboost/any.hpp>
+
namespace ndn {
namespace der {
-// TODO: This is a stub. We want to implement an any type, but avoid boost::any which is not in the C++ standard library.
-class Any {
-public:
- Any() {}
-
- template<class T> Any(const T& value) {}
-};
-
class DerBool;
class DerInteger;
class DerPrintableString;
@@ -34,15 +29,15 @@
class Visitor
{
public:
- virtual Any visit(DerBool&, Any) = 0;
- virtual Any visit(DerInteger&, Any) = 0;
- virtual Any visit(DerPrintableString&, Any) = 0;
- virtual Any visit(DerBitString&, Any) = 0;
- virtual Any visit(DerNull&, Any) = 0;
- virtual Any visit(DerOctetString&, Any) = 0;
- virtual Any visit(DerOid&, Any) = 0;
- virtual Any visit(DerSequence&, Any) = 0;
- virtual Any visit(DerGtime&, Any) = 0;
+ virtual ndnboost::any visit(DerBool&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerInteger&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerPrintableString&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerBitString&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerNull&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerOctetString&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerOid&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerSequence&, ndnboost::any) = 0;
+ virtual ndnboost::any visit(DerGtime&, ndnboost::any) = 0;
};
} // der
diff --git a/ndn-cpp/encoding/der/visitor/void-visitor.cpp b/ndn-cpp/encoding/der/visitor/void-visitor.cpp
index a0bcf00..dd8217a 100644
--- a/ndn-cpp/encoding/der/visitor/void-visitor.cpp
+++ b/ndn-cpp/encoding/der/visitor/void-visitor.cpp
@@ -13,39 +13,39 @@
namespace der {
void
-VoidVisitor::visit(DerBool& derBool, Any)
+VoidVisitor::visit(DerBool& derBool, ndnboost::any)
{}
void
-VoidVisitor::visit(DerInteger& derInteger, Any)
+VoidVisitor::visit(DerInteger& derInteger, ndnboost::any)
{}
void
-VoidVisitor::visit(DerPrintableString& derPStr, Any)
+VoidVisitor::visit(DerPrintableString& derPStr, ndnboost::any)
{}
void
-VoidVisitor::visit(DerBitString& derBStr, Any)
+VoidVisitor::visit(DerBitString& derBStr, ndnboost::any)
{}
void
-VoidVisitor::visit(DerNull& derNull, Any)
+VoidVisitor::visit(DerNull& derNull, ndnboost::any)
{}
void
-VoidVisitor::visit(DerOctetString& derOStr, Any)
+VoidVisitor::visit(DerOctetString& derOStr, ndnboost::any)
{}
void
-VoidVisitor::visit(DerOid& derOid, Any)
+VoidVisitor::visit(DerOid& derOid, ndnboost::any)
{}
void
-VoidVisitor::visit(DerSequence& derSequence, Any)
+VoidVisitor::visit(DerSequence& derSequence, ndnboost::any)
{}
void
-VoidVisitor::visit(DerGtime& derGtime, Any)
+VoidVisitor::visit(DerGtime& derGtime, ndnboost::any)
{}
} // der
diff --git a/ndn-cpp/encoding/der/visitor/void-visitor.hpp b/ndn-cpp/encoding/der/visitor/void-visitor.hpp
index a041c10..7cd7999 100644
--- a/ndn-cpp/encoding/der/visitor/void-visitor.hpp
+++ b/ndn-cpp/encoding/der/visitor/void-visitor.hpp
@@ -18,15 +18,15 @@
class VoidVisitor
{
public:
- virtual void visit(DerBool&, Any) = 0;
- virtual void visit(DerInteger&, Any) = 0;
- virtual void visit(DerPrintableString&, Any) = 0;
- virtual void visit(DerBitString&, Any) = 0;
- virtual void visit(DerNull&, Any) = 0;
- virtual void visit(DerOctetString&, Any) = 0;
- virtual void visit(DerOid&, Any) = 0;
- virtual void visit(DerSequence&, Any) = 0;
- virtual void visit(DerGtime&, Any) = 0;
+ virtual void visit(DerBool&, ndnboost::any) = 0;
+ virtual void visit(DerInteger&, ndnboost::any) = 0;
+ virtual void visit(DerPrintableString&, ndnboost::any) = 0;
+ virtual void visit(DerBitString&, ndnboost::any) = 0;
+ virtual void visit(DerNull&, ndnboost::any) = 0;
+ virtual void visit(DerOctetString&, ndnboost::any) = 0;
+ virtual void visit(DerOid&, ndnboost::any) = 0;
+ virtual void visit(DerSequence&, ndnboost::any) = 0;
+ virtual void visit(DerGtime&, ndnboost::any) = 0;
};
} // der