Adding support of more fields in ContentObject

All big fields (digest, signature, etc.) are represented with 32-bit
integers. Should be enough for simulation purposes.

Also. This commit contains a number of code reorganizations, so the code
may not work...
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
deleted file mode 100644
index 94732f7..0000000
--- a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ccnb-parser-content-object-visitor.h"
-#include "ccnb-parser-name-components-visitor.h"
-#include "ccnb-parser-non-negative-integer-visitor.h"
-#include "ccnb-parser-timestamp-visitor.h"
-
-#include "../syntax-tree/ccnb-parser-block.h"
-#include "../syntax-tree/ccnb-parser-dtag.h"
-
-#include "ns3/ccnx-name-components.h"
-#include "ns3/assert.h"
-#include "ns3/log.h"
-
-#include "ns3/ccnx-content-object-header.h"
-
-#include <boost/foreach.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("CcnbParserContentObjectVisitor");
-
-namespace ns3 {
-namespace CcnbParser {
-
-// We don't really care about any other fields
-void
-ContentObjectVisitor::visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader* */)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  static NameComponentsVisitor nameComponentsVisitor;
-  static NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
-  static TimestampVisitor          timestampVisitor;
-  
-  CcnxContentObjectHeader &contentObject = *(boost::any_cast<CcnxContentObjectHeader*> (param));
-  
-  switch (n.m_dtag)
-    {
-    case CCN_DTAG_ContentObject:
-      // process nested blocks
-      BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
-        {
-          block->accept (*this, param);
-        }
-      break;
-    case CCN_DTAG_Name:
-      {
-        // process name components
-        Ptr<CcnxNameComponents> name = Create<CcnxNameComponents> ();
-        
-        BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
-          {
-            block->accept (nameComponentsVisitor, &(*name));
-          }
-        contentObject.SetName (name);
-        break;
-      }
-
-    case CCN_DTAG_Signature: // ignoring
-      break;
-
-    case CCN_DTAG_SignedInfo:
-      // process nested blocks
-      BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
-        {
-          block->accept (*this, param);
-        }      
-      break;
-      
-    case CCN_DTAG_Timestamp:
-      NS_LOG_DEBUG ("Timestamp");
-      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnbDecodingException ();
-
-      contentObject.SetTimestamp (
-               boost::any_cast<Time> (
-                                      (*n.m_nestedTags.begin())->accept(
-                                                                        timestampVisitor
-                                                                        )));
-      break;
-
-    case CCN_DTAG_FreshnessSeconds:
-      NS_LOG_DEBUG ("FreshnessSeconds");
-      
-      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnbDecodingException ();
-      contentObject.SetFreshness (
-          Seconds (
-               boost::any_cast<uint32_t> (
-                                          (*n.m_nestedTags.begin())->accept(
-                                                                           nonNegativeIntegerVisitor
-                                                                           ))));
-      
-      break;
-      
-    case CCN_DTAG_Content: // !!! HACK
-      // This hack was necessary for memory optimizations (i.e., content is virtual payload)
-      NS_ASSERT_MSG (n.m_nestedTags.size() == 0, "Parser should have stopped just after processing <Content> tag");
-      break;
-      
-    default: // ignore all other stuff
-      break;
-    }
-}
-
-} // namespace CcnbParser
-} // namespace ns3
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
deleted file mode 100644
index ae6fe9b..0000000
--- a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
-#define _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
-
-#include "ccnb-parser-void-depth-first-visitor.h"
-
-namespace ns3 {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor that fills fields in CcnxContentObjectHeader
- *
- * Usage example:
- * \code
- *   Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
- *   Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
- *   ContentObjectVisitor visitor;
- *   root->accept (visitor, *header); 
- * \endcode
- */
-class ContentObjectVisitor : public VoidDepthFirstVisitor
-{
-public:
-  virtual void visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader* */);
-};
-
-}
-}
-
-#endif // _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.cc
similarity index 79%
copy from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
copy to helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.cc
index 0102b0a..34608b1 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.cc
@@ -18,24 +18,29 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#include "ccnb-parser-nonce-visitor.h"
+#include "ccnb-parser-content-type-visitor.h"
 #include "../syntax-tree/ccnb-parser-blob.h"
 
 namespace ns3 {
 namespace CcnbParser {
 
 boost::any
-NonceVisitor::visit (Blob &n) 
+ContentTypeVisitor::visit (Blob &n) 
 {
   // Buffer n.m_blob;
-  if (n.m_blobSize < 4)
+  if (n.m_blobSize != 3)
     throw CcnbDecodingException ();
-     
-  return boost::any (*(reinterpret_cast<uint32_t*> (n.m_blob)));
+
+  uint32_t type =
+    (n.m_blob [0] << 16) |
+    (n.m_blob [1] << 8 ) |
+    (n.m_blob [2]      );
+    
+  return boost::any (type);
 }
 
 boost::any
-NonceVisitor::visit (Udata &n)
+ContentTypeVisitor::visit (Udata &n)
 {
   // std::string n.m_udata;
   throw CcnbDecodingException ();
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h
similarity index 87%
rename from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
rename to helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h
index c4912aa..0c3cc6c 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h
@@ -18,8 +18,8 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#ifndef _CCNB_PARSER_NONCE_VISITOR_H_
-#define _CCNB_PARSER_NONCE_VISITOR_H_
+#ifndef _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
+#define _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
 
 #include "ccnb-parser-no-argu-depth-first-visitor.h"
 
@@ -35,7 +35,7 @@
  *
  * Will return empty boost::any() if called on anything except BLOB block
  */
-class NonceVisitor : public NoArguDepthFirstVisitor
+class ContentTypeVisitor : public NoArguDepthFirstVisitor
 {
 public:
   virtual boost::any visit (Blob &n); 
@@ -45,4 +45,4 @@
 }
 }
 
-#endif // _CCNB_PARSER_NONCE_VISITOR_H_
+#endif // _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
index b7ccaba..ff219f0 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
+++ b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
@@ -32,7 +32,7 @@
 #include "ccnb-parser-name-components-visitor.h"
 #include "ccnb-parser-non-negative-integer-visitor.h"
 #include "ccnb-parser-timestamp-visitor.h"
-#include "ccnb-parser-nonce-visitor.h"
+#include "ccnb-parser-uint32t-blob-visitor.h"
 
 #include <boost/foreach.hpp>
 
@@ -53,7 +53,7 @@
   static NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
   static NameComponentsVisitor     nameComponentsVisitor;
   static TimestampVisitor          timestampVisitor;
-  static NonceVisitor              nonceVisitor;
+  static Uint32tBlobVisitor        nonceVisitor;
   
   CcnxInterestHeader &interest = *(boost::any_cast<CcnxInterestHeader*> (param));
 
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.cc
similarity index 90%
rename from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
rename to helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.cc
index 0102b0a..fbeee6e 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
+++ b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.cc
@@ -18,14 +18,14 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#include "ccnb-parser-nonce-visitor.h"
+#include "ccnb-parser-uint32t-blob-visitor.h"
 #include "../syntax-tree/ccnb-parser-blob.h"
 
 namespace ns3 {
 namespace CcnbParser {
 
 boost::any
-NonceVisitor::visit (Blob &n) 
+Uint32tBlobVisitor::visit (Blob &n) 
 {
   // Buffer n.m_blob;
   if (n.m_blobSize < 4)
@@ -35,7 +35,7 @@
 }
 
 boost::any
-NonceVisitor::visit (Udata &n)
+Uint32tBlobVisitor::visit (Udata &n)
 {
   // std::string n.m_udata;
   throw CcnbDecodingException ();
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h
similarity index 87%
copy from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
copy to helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h
index c4912aa..e06273f 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
+++ b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h
@@ -18,8 +18,8 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#ifndef _CCNB_PARSER_NONCE_VISITOR_H_
-#define _CCNB_PARSER_NONCE_VISITOR_H_
+#ifndef _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
+#define _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
 
 #include "ccnb-parser-no-argu-depth-first-visitor.h"
 
@@ -35,7 +35,7 @@
  *
  * Will return empty boost::any() if called on anything except BLOB block
  */
-class NonceVisitor : public NoArguDepthFirstVisitor
+class Uint32tBlobVisitor : public NoArguDepthFirstVisitor
 {
 public:
   virtual boost::any visit (Blob &n); 
@@ -45,4 +45,4 @@
 }
 }
 
-#endif // _CCNB_PARSER_NONCE_VISITOR_H_
+#endif // _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
diff --git a/helper/ccnx-decoding-helper.cc b/helper/ccnx-decoding-helper.cc
index ee3f084..6d1d7c8 100644
--- a/helper/ccnx-decoding-helper.cc
+++ b/helper/ccnx-decoding-helper.cc
@@ -21,10 +21,8 @@
 #include "ccnx-decoding-helper.h"
 
 #include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
 
 #include "ccnb-parser/visitors/ccnb-parser-interest-visitor.h"
-#include "ccnb-parser/visitors/ccnb-parser-content-object-visitor.h"
 
 #include "ccnb-parser/syntax-tree/ccnb-parser-block.h"
 #include "ccnb-parser/syntax-tree/ccnb-parser-dtag.h"
@@ -47,16 +45,16 @@
   return i.GetDistanceFrom (start);
 }
 
-size_t
-CcnxDecodingHelper::Deserialize (Buffer::Iterator start, CcnxContentObjectHeader &contentObject)
-{
-  static CcnbParser::ContentObjectVisitor contentObjectVisitor;
+// size_t
+// CcnxDecodingHelper::Deserialize (Buffer::Iterator start, CcnxContentObjectHeader &contentObject)
+// {
+//   static CcnbParser::ContentObjectVisitor contentObjectVisitor;
 
-  Buffer::Iterator i = start;
-  Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
-  root->accept (contentObjectVisitor, &contentObject);
+//   Buffer::Iterator i = start;
+//   Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+//   root->accept (contentObjectVisitor, &contentObject);
 
-  return i.GetDistanceFrom (start);
-}
+//   return i.GetDistanceFrom (start);
+// }
 
 } // namespace ns3
diff --git a/helper/ccnx-encoding-helper.cc b/helper/ccnx-encoding-helper.cc
index 538524c..acb3966 100644
--- a/helper/ccnx-encoding-helper.cc
+++ b/helper/ccnx-encoding-helper.cc
@@ -84,9 +84,7 @@
   if (interest.GetNonce()>0)
     {
       uint32_t nonce = interest.GetNonce();
-      written += AppendTaggedBlob (start, CcnbParser::CCN_DTAG_Nonce,
-                                   reinterpret_cast<const uint8_t*>(&nonce),
-                                   sizeof(nonce));
+      written += AppendTaggedBlob (start, CcnbParser::CCN_DTAG_Nonce, nonce);
     }
     
   if (interest.GetNack ()>0)
@@ -168,102 +166,6 @@
   return written;
 }
 
-size_t
-CcnxEncodingHelper::Serialize (Buffer::Iterator start, const CcnxContentObjectHeader &contentObject)
-{
-  size_t written = 0;
-  written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_ContentObject, CcnbParser::CCN_DTAG); // <ContentObject>
-
-  // fake signature
-  written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_Signature, CcnbParser::CCN_DTAG); // <Signature>
-  // Signature ::= DigestAlgorithm? 
-  //               Witness?         
-  //               SignatureBits   
-  written += AppendTaggedBlob (start, CcnbParser::CCN_DTAG_SignatureBits, 0, 0);      // <SignatureBits />
-  written += AppendCloser (start);                                    // </Signature>  
-
-  written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG);    // <Name>
-  written += AppendNameComponents (start, contentObject.GetName()); //   <Component>...</Component>...
-  written += AppendCloser (start);                                  // </Name>  
-
-  // fake signature
-  written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_SignedInfo, CcnbParser::CCN_DTAG); // <SignedInfo>
-  // SignedInfo ::= PublisherPublicKeyDigest
-  //                Timestamp
-  //                Type?
-  //                FreshnessSeconds?
-  //                FinalBlockID?
-  //                KeyLocator?
-  if (!contentObject.GetTimestamp ().IsZero())
-    {
-      written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_Timestamp, CcnbParser::CCN_DTAG);
-      written += AppendTimestampBlob (start, contentObject.GetTimestamp ());
-      written += AppendCloser (start);
-    }
-  if (contentObject.GetFreshness () >= Seconds(0))
-    {
-      written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_FreshnessSeconds, CcnbParser::CCN_DTAG);
-      written += AppendNumber (start, contentObject.GetFreshness ().ToInteger (Time::S));
-      written += AppendCloser (start);
-    }
-  
-  written += AppendTaggedBlob (start, CcnbParser::CCN_DTAG_PublisherPublicKeyDigest, 0, 0); // <PublisherPublicKeyDigest />
-  written += AppendCloser (start);                                     // </SignedInfo>
-
-  written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_Content, CcnbParser::CCN_DTAG); // <Content>
-
-  // there are no closing tags !!!
-  return written;
-}
-
-size_t
-CcnxEncodingHelper::GetSerializedSize (const CcnxContentObjectHeader &contentObject)
-{
-  size_t written = 0;
-  written += EstimateBlockHeader (CcnbParser::CCN_DTAG_ContentObject); // <ContentObject>
-
-  // fake signature
-  written += EstimateBlockHeader (CcnbParser::CCN_DTAG_Signature); // <Signature>
-  // Signature ::= DigestAlgorithm? 
-  //               Witness?         
-  //               SignatureBits   
-  written += EstimateTaggedBlob (CcnbParser::CCN_DTAG_SignatureBits, 0);      // <SignatureBits />
-  written += 1;                                    // </Signature>  
-
-  written += EstimateBlockHeader (CcnbParser::CCN_DTAG_Name);    // <Name>
-  written += EstimateNameComponents (contentObject.GetName()); //   <Component>...</Component>...
-  written += 1;                                  // </Name>  
-
-  // fake signature
-  written += EstimateBlockHeader (CcnbParser::CCN_DTAG_SignedInfo); // <SignedInfo>
-  // SignedInfo ::= PublisherPublicKeyDigest
-  //                Timestamp
-  //                Type?
-  //                FreshnessSeconds?
-  //                FinalBlockID?
-  //                KeyLocator?
-  if (!contentObject.GetTimestamp ().IsZero())
-    {
-      written += EstimateBlockHeader (CcnbParser::CCN_DTAG_Timestamp);
-      written += EstimateTimestampBlob (contentObject.GetTimestamp ());
-      written += 1;
-    }
-  if (contentObject.GetFreshness () >= Seconds(0))
-    {
-      written += EstimateBlockHeader (CcnbParser::CCN_DTAG_FreshnessSeconds);
-      written += EstimateNumber (contentObject.GetFreshness ().ToInteger (Time::S));
-      written += 1;
-    }
-
-  written += EstimateTaggedBlob (CcnbParser::CCN_DTAG_PublisherPublicKeyDigest, 0); // <PublisherPublicKeyDigest />
-  written += 1;                                     // </SignedInfo>
-
-  written += EstimateBlockHeader (CcnbParser::CCN_DTAG_Content); // <Content>
-
-  // there are no closing tags !!!
-  return written;
-}
-
 //////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////
@@ -423,6 +325,26 @@
     return EstimateBlockHeader (dtag) + 1;
 }
 
+size_t
+CcnxEncodingHelper::AppendString (Buffer::Iterator &start, CcnbParser::ccn_dtag dtag,
+                                  const std::string &string)
+{
+  size_t written = AppendBlockHeader (start, dtag, CcnbParser::CCN_DTAG);
+  {
+    written += AppendBlockHeader (start, string.size (), CcnbParser::CCN_UDATA);
+    start.Write (reinterpret_cast<const uint8_t*> (string.c_str ()), string.size ());
+    written += string.size ();
+  }
+  written += AppendCloser (start);
+
+  return written;
+}
+
+size_t
+CcnxEncodingHelper::EstimateString (CcnbParser::ccn_dtag dtag, const std::string &string)
+{
+  return EstimateBlockHeader (dtag) + EstimateBlockHeader (string.size ()) + string.size () + 1;
+}
 
 
 } // namespace ns3
diff --git a/helper/ccnx-encoding-helper.h b/helper/ccnx-encoding-helper.h
index e4fe45d..65b3b6a 100644
--- a/helper/ccnx-encoding-helper.h
+++ b/helper/ccnx-encoding-helper.h
@@ -58,14 +58,8 @@
    */
   static size_t
   GetSerializedSize (const CcnxInterestHeader &interest);
-
-  static size_t
-  Serialize (Buffer::Iterator start, const CcnxContentObjectHeader &contentObject);
-
-  static size_t
-  GetSerializedSize (const CcnxContentObjectHeader &contentObject);
   
-private:
+public:
   static size_t
   AppendBlockHeader (Buffer::Iterator &start, size_t value, CcnbParser::ccn_tt block_type);
 
@@ -120,8 +114,51 @@
   
   static size_t
   EstimateTaggedBlob (CcnbParser::ccn_dtag dtag, size_t size);
+
+  /**
+   * Append value as a tagged BLOB (templated version)
+   *
+   * This is a ccnb-encoded element with containing the BLOB as content
+   *
+   * Data will be reinterpret_cast<const uint8_t*> and size will be obtained using sizeof
+   *
+   * @param start start iterator of  the buffer to append to.
+   * @param dtag is the element's dtab
+   * @param data a value to add
+   *
+   * @returns written length
+   */
+  template<class T>
+  static inline size_t
+  AppendTaggedBlob (Buffer::Iterator &start, CcnbParser::ccn_dtag dtag, const T &data);
+
+  /**
+   * Append a tagged string (should be a valid UTF-8 coded string)
+   *
+   * This is a ccnb-encoded element with containing UDATA as content
+   *
+   * @param start start iterator of  the buffer to append to.
+   * @param dtag is the element's dtab
+   * @param string UTF-8 string to be written
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendString (Buffer::Iterator &start, CcnbParser::ccn_dtag dtag,
+                const std::string &string);
+
+  static size_t
+  EstimateString (CcnbParser::ccn_dtag dtag, const std::string &string);
 };
 
+
+template<class T>
+size_t
+CcnxEncodingHelper::AppendTaggedBlob (Buffer::Iterator &start, CcnbParser::ccn_dtag dtag, const T &data)
+{
+  return AppendTaggedBlob (start, dtag, reinterpret_cast<const uint8_t*> (&data), sizeof (data));
+}
+
 } // namespace ns3
 
 #endif // _CCNX_ENCODING_HELPER_H_