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/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