data: Update TLV encoding/decoding
Change-Id: I142e5b42949737f0ac1f4bb6f072496c105693b0
diff --git a/include/ndn-cpp/data.hpp b/include/ndn-cpp/data.hpp
index d25253f..cd6176f 100644
--- a/include/ndn-cpp/data.hpp
+++ b/include/ndn-cpp/data.hpp
@@ -223,12 +223,7 @@
{
onChanged();
- OBufferStream os;
- Tlv::writeVarNumber(os, Tlv::Content);
- Tlv::writeVarNumber(os, contentLength);
- os.write(reinterpret_cast<const char *>(content), contentLength);
-
- content_ = Block(os.buf());
+ content_ = dataBlock(Tlv::Content, content, contentLength);
}
inline void
diff --git a/src/data.cpp b/src/data.cpp
index 6b1efd7..2bbe9a1 100644
--- a/src/data.cpp
+++ b/src/data.cpp
@@ -18,6 +18,12 @@
if (wire_.hasWire())
return wire_;
+ // Data ::= DATA-TLV TLV-LENGTH
+ // Name
+ // MetaInfo
+ // Content
+ // Signature
+
wire_ = Block(Tlv::Data);
// Name
@@ -57,6 +63,12 @@
wire_ = wire;
wire_.parse();
+ // Data ::= DATA-TLV TLV-LENGTH
+ // Name
+ // MetaInfo
+ // Content
+ // Signature
+
// Name
name_.wireDecode(wire_.get(Tlv::Name));