In common.h, define namespace ptr_lib = boost, and use ptr_lib::shared_ptr<Name>, etc.
diff --git a/ndn-cpp/common.h b/ndn-cpp/common.h
index a9c078b..b517c1b 100644
--- a/ndn-cpp/common.h
+++ b/ndn-cpp/common.h
@@ -19,6 +19,7 @@
namespace ndn
{
+namespace ptr_lib = boost;
typedef boost::posix_time::ptime Time;
typedef boost::posix_time::time_duration TimeInterval;
@@ -66,9 +67,6 @@
typedef std::vector<unsigned char> Bytes;
typedef std::vector<std::string>Comps;
-typedef boost::shared_ptr<Bytes> BytesPtr;
-typedef boost::shared_ptr<const Bytes> ConstBytesPtr;
-
inline
const unsigned char *
head(const Bytes &bytes)
@@ -94,18 +92,18 @@
}
}
-inline BytesPtr
+inline ptr_lib::shared_ptr<Bytes>
readRawPtr (const unsigned char *src, size_t len)
{
if (len > 0)
{
- BytesPtr ret (new Bytes (len));
+ ptr_lib::shared_ptr<Bytes> ret (new Bytes (len));
memcpy (head (*ret), src, len);
return ret;
}
else
- return BytesPtr ();
+ return ptr_lib::shared_ptr<Bytes> ();
}
} // ndn
#endif // NDN_COMMON_H
diff --git a/ndn-cpp/data.h b/ndn-cpp/data.h
index 3264e4d..962bfe5 100644
--- a/ndn-cpp/data.h
+++ b/ndn-cpp/data.h
@@ -61,13 +61,13 @@
/**
* @brief Get const smart pointer to signature object
*/
- inline ConstSignaturePtr
+ inline ptr_lib::shared_ptr<const Signature>
getSignature () const;
/**
* @brief Get smart pointer to signature object
*/
- inline SignaturePtr
+ inline ptr_lib::shared_ptr<Signature>
getSignature ();
/**
@@ -75,7 +75,7 @@
* @param signature smart pointer to a signature object
*/
inline void
- setSignature (SignaturePtr sigature);
+ setSignature (ptr_lib::shared_ptr<Signature> sigature);
/**
* @brief Get const reference to content object (content info + actual content)
@@ -126,10 +126,10 @@
private:
Name m_name;
- SignaturePtr m_signature; // signature with its parameters "binds" name and content
+ ptr_lib::shared_ptr<Signature> m_signature; // signature with its parameters "binds" name and content
Content m_content;
- SignedBlobPtr m_wire;
+ ptr_lib::shared_ptr<SignedBlob> m_wire;
};
inline Data &
@@ -151,20 +151,20 @@
return m_name;
}
-inline ConstSignaturePtr
+inline ptr_lib::shared_ptr<const Signature>
Data::getSignature () const
{
return m_signature;
}
-inline SignaturePtr
+inline ptr_lib::shared_ptr<Signature>
Data::getSignature ()
{
return m_signature;
}
inline void
-Data::setSignature (SignaturePtr signature)
+Data::setSignature (ptr_lib::shared_ptr<Signature> signature)
{
m_signature = signature;
}
diff --git a/ndn-cpp/fields/blob.h b/ndn-cpp/fields/blob.h
index ce0d667..d81d039 100644
--- a/ndn-cpp/fields/blob.h
+++ b/ndn-cpp/fields/blob.h
@@ -19,10 +19,6 @@
namespace ndn {
-class Blob;
-typedef boost::shared_ptr<Blob> BlobPtr;
-typedef boost::shared_ptr<const Blob> ConstBlobPtr;
-
/**
* @brief Class representing a general-use binary blob
*/
diff --git a/ndn-cpp/fields/name.h b/ndn-cpp/fields/name.h
index a356f8f..0eeed2a 100644
--- a/ndn-cpp/fields/name.h
+++ b/ndn-cpp/fields/name.h
@@ -18,10 +18,6 @@
namespace ndn {
-class Name;
-typedef boost::shared_ptr<Name> NamePtr;
-typedef boost::shared_ptr<const Name> ConstNamePtr;
-
/**
* @brief Class for NDN Name
*/
diff --git a/ndn-cpp/fields/signature.h b/ndn-cpp/fields/signature.h
index 1368663..65afc04 100644
--- a/ndn-cpp/fields/signature.h
+++ b/ndn-cpp/fields/signature.h
@@ -18,10 +18,6 @@
namespace wire { class Base; }
-class Signature;
-typedef boost::shared_ptr<Signature> SignaturePtr;
-typedef boost::shared_ptr<const Signature> ConstSignaturePtr;
-
/**
* @brief Pure virtual class providing an interface to work with signatures for NDN data packets
*/
diff --git a/ndn-cpp/fields/signed-blob.h b/ndn-cpp/fields/signed-blob.h
index fd5bf90..b8cb39f 100644
--- a/ndn-cpp/fields/signed-blob.h
+++ b/ndn-cpp/fields/signed-blob.h
@@ -17,10 +17,6 @@
namespace ndn {
-class SignedBlob;
-typedef boost::shared_ptr<SignedBlob> SignedBlobPtr;
-typedef boost::shared_ptr<const SignedBlob> ConstSignedBlobPtr;
-
/**
* @brief Class representing a blob, which has a signed portion (e.g., bytes of DATA packet)
*/
diff --git a/ndn-cpp/helpers/hash.cc b/ndn-cpp/helpers/hash.cc
index 0ecf927..aa98784 100644
--- a/ndn-cpp/helpers/hash.cc
+++ b/ndn-cpp/helpers/hash.cc
@@ -49,12 +49,12 @@
unsigned char Hash::_origin = 0;
-HashPtr Hash::Origin(new Hash(&Hash::_origin, sizeof(unsigned char)));
+ptr_lib::shared_ptr<Hash> Hash::Origin(new Hash(&Hash::_origin, sizeof(unsigned char)));
-HashPtr
+ptr_lib::shared_ptr<Hash>
Hash::FromString (const std::string &hashInTextEncoding)
{
- HashPtr retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
+ ptr_lib::shared_ptr<Hash> retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
if (hashInTextEncoding.size () == 0)
{
@@ -78,10 +78,10 @@
return retval;
}
-HashPtr
+ptr_lib::shared_ptr<Hash>
Hash::FromFileContent (const char *filename)
{
- HashPtr retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
+ ptr_lib::shared_ptr<Hash> retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
EVP_MD_CTX *hash_context = EVP_MD_CTX_create ();
@@ -105,10 +105,10 @@
return retval;
}
-HashPtr
+ptr_lib::shared_ptr<Hash>
Hash::FromBytes (const ndn::Bytes &bytes)
{
- HashPtr retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
+ ptr_lib::shared_ptr<Hash> retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
EVP_MD_CTX *hash_context = EVP_MD_CTX_create ();
diff --git a/ndn-cpp/helpers/hash.h b/ndn-cpp/helpers/hash.h
index 8ac23fa..b5d96aa 100644
--- a/ndn-cpp/helpers/hash.h
+++ b/ndn-cpp/helpers/hash.h
@@ -22,16 +22,11 @@
namespace ndn
{
-
-class Hash;
-typedef boost::shared_ptr<Hash> HashPtr;
-typedef boost::shared_ptr<const Hash> ConstHashPtr;
-
class Hash
{
public:
static unsigned char _origin;
- static HashPtr Origin;
+ static ptr_lib::shared_ptr<Hash> Origin;
Hash ()
: m_buf(0)
@@ -59,13 +54,13 @@
}
}
- static HashPtr
+ static ptr_lib::shared_ptr<Hash>
FromString (const std::string &hashInTextEncoding);
- static HashPtr
+ static ptr_lib::shared_ptr<Hash>
FromFileContent (const char *fileName);
- static HashPtr
+ static ptr_lib::shared_ptr<Hash>
FromBytes (const ndn::Bytes &bytes);
~Hash ()
diff --git a/ndn-cpp/interest.h b/ndn-cpp/interest.h
index 7e778df..ace9847 100644
--- a/ndn-cpp/interest.h
+++ b/ndn-cpp/interest.h
@@ -21,9 +21,6 @@
namespace ndn {
class Interest;
-typedef boost::shared_ptr<Interest> InterestPtr;
-typedef boost::shared_ptr<const Interest> ConstInterestPtr;
-
/**
* @brief Class abstracting operations with Interests (constructing and getting access to Interest fields)
*/
@@ -288,7 +285,7 @@
Hash m_publisherPublicKeyDigest;
Exclude m_exclude;
- BlobPtr m_wire;
+ ptr_lib::shared_ptr<Blob> m_wire;
};
namespace Error
diff --git a/test/test-boost-header-only.cpp b/test/test-boost-header-only.cpp
index 03f3efa..3b5e906 100644
--- a/test/test-boost-header-only.cpp
+++ b/test/test-boost-header-only.cpp
@@ -7,6 +7,7 @@
#include <cstdlib>
#include <sstream>
+#include <iostream>
#include "ndn-cpp/fields/name.h"
#include "ndn-cpp/fields/name-component.h"
#include "ndn-cpp/interest.h"
@@ -19,7 +20,7 @@
*
*/
int main(int argc, char** argv) {
- InterestPtr interest(new Interest());
+ ptr_lib::shared_ptr<Interest> interest(new Interest());
interest->setName(Name("/test"));
interest->setMinSuffixComponents(2);
interest->setMaxSuffixComponents(2);