ccnx: small extensions

Change-Id: Ib6755980e1cb86d45ca682d359c95d058dc70a92
diff --git a/ccnx/ccnx-common.h b/ccnx/ccnx-common.h
index c78970b..579128f 100644
--- a/ccnx/ccnx-common.h
+++ b/ccnx/ccnx-common.h
@@ -116,6 +116,20 @@
 }
 
 template<class Msg>
+boost::shared_ptr<Msg>
+deserializeMsg (const void *buf, size_t length)
+{
+  boost::shared_ptr<Msg> retval (new Msg ());
+  if (!retval->ParseFromArray (buf, length))
+    {
+      // to indicate an error
+      return boost::shared_ptr<Msg> ();
+    }
+  return retval;
+}
+
+
+template<class Msg>
 BytesPtr
 serializeGZipMsg(const Msg &msg)
 {
diff --git a/ccnx/ccnx-name.h b/ccnx/ccnx-name.h
index e29a5b3..c11e52f 100644
--- a/ccnx/ccnx-name.h
+++ b/ccnx/ccnx-name.h
@@ -162,6 +162,8 @@
   std::vector<Bytes> m_comps;
 };
 
+typedef boost::shared_ptr<Name> NamePtr;
+
 std::ostream&
 operator <<(std::ostream &os, const Name &name);
 
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
index 54f93af..54ca745 100644
--- a/ccnx/ccnx-wrapper.cpp
+++ b/ccnx/ccnx-wrapper.cpp
@@ -325,18 +325,6 @@
 }
 
 int
-CcnxWrapper::publishData (const Name &name, const Bytes &content, int freshness)
-{
-  return publishData(name, head(content), content.size(), freshness);
-}
-
-int
-CcnxWrapper::publishUnsignedData(const Name &name, const Bytes &content, int freshness)
-{
-  return publishUnsignedData(name, head(content), content.size(), freshness);
-}
-
-int
 CcnxWrapper::publishUnsignedData(const Name &name, const unsigned char *buf, size_t len, int freshness)
 {
   {
diff --git a/ccnx/ccnx-wrapper.h b/ccnx/ccnx-wrapper.h
index 42b3d91..3fd3c23 100644
--- a/ccnx/ccnx-wrapper.h
+++ b/ccnx/ccnx-wrapper.h
@@ -35,7 +35,7 @@
 
 namespace Ccnx {
 
-struct CcnxOperationException : virtual boost::exception, virtual std::exception { };
+struct CcnxOperationException : boost::exception, std::exception { };
 
 class CcnxWrapper
 {
@@ -45,7 +45,7 @@
   typedef boost::function<void (Name, Selectors)> InterestCallback;
 
   CcnxWrapper();
-  virtual ~CcnxWrapper();
+  ~CcnxWrapper();
 
   void
   start (); // called automatically in constructor
@@ -56,27 +56,33 @@
   void
   shutdown (); // called in destructor, but can called manually
 
-  virtual int
+  int
   setInterestFilter (const Name &prefix, const InterestCallback &interestCallback, bool record = true);
 
-  virtual void
+  void
   clearInterestFilter (const Name &prefix, bool record = true);
 
-  virtual int
+  int
   sendInterest (const Name &interest, const Closure &closure, const Selectors &selector = Selectors());
 
-  virtual int
+  int
   publishData (const Name &name, const unsigned char *buf, size_t len, int freshness = DEFAULT_FRESHNESS/* max value for ccnx*/);
 
-  int
+  inline int
   publishData (const Name &name, const Bytes &content, int freshness = DEFAULT_FRESHNESS/* max value for ccnx*/);
 
-  int
-  publishUnsignedData(const Name &name, const Bytes &content, int freshness = DEFAULT_FRESHNESS);
+  inline int
+  publishData (const Name &name, const std::string &content, int freshness = DEFAULT_FRESHNESS/* max value for ccnx*/);
 
   int
   publishUnsignedData(const Name &name, const unsigned char *buf, size_t len, int freshness = DEFAULT_FRESHNESS);
 
+  inline int
+  publishUnsignedData(const Name &name, const Bytes &content, int freshness = DEFAULT_FRESHNESS);
+
+  inline int
+  publishUnsignedData(const Name &name, const std::string &content, int freshness = DEFAULT_FRESHNESS);
+
   static Name
   getLocalPrefix ();
 
@@ -121,6 +127,30 @@
 
 typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;
 
+inline int
+CcnxWrapper::publishData (const Name &name, const Bytes &content, int freshness)
+{
+  return publishData(name, head(content), content.size(), freshness);
+}
+
+inline int
+CcnxWrapper::publishData (const Name &name, const std::string &content, int freshness)
+{
+  return publishData(name, reinterpret_cast<const unsigned char *> (content.c_str ()), content.size (), freshness);
+}
+
+inline int
+CcnxWrapper::publishUnsignedData(const Name &name, const Bytes &content, int freshness)
+{
+  return publishUnsignedData(name, head(content), content.size(), freshness);
+}
+
+inline int
+CcnxWrapper::publishUnsignedData(const Name &name, const std::string &content, int freshness)
+{
+  return publishUnsignedData(name, reinterpret_cast<const unsigned char *> (content.c_str ()), content.size (), freshness);
+}
+
 
 } // Ccnx