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