encoding: Fixing bugs in EncodingBlock and Block
Several Block constructors incorrectly initialized value boundaries.
Change-Id: I0d8a4fe73cc24530245862e0428e617437078bf0
refs: #1256, #1257
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 9c8ba1e..5409879 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -39,8 +39,8 @@
, m_end(m_buffer->end())
, m_size(m_end - m_begin)
{
- m_value_begin = m_buffer->begin();
- m_value_end = m_buffer->end();
+ m_value_begin = m_begin;
+ m_value_end = m_end;
m_type = Tlv::readType(m_value_begin, m_value_end);
@@ -58,8 +58,8 @@
, m_end(end)
, m_size(m_end - m_begin)
{
- m_value_begin = m_buffer->begin();
- m_value_end = m_buffer->end();
+ m_value_begin = m_begin;
+ m_value_end = m_end;
m_type = Tlv::readType(m_value_begin, m_value_end);
uint64_t length = Tlv::readVarNumber(m_value_begin, m_value_end);
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index 2afd154..a2f19be 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -17,6 +17,9 @@
namespace ndn {
+template<bool> class EncodingImpl;
+typedef EncodingImpl<true> EncodingBuffer;
+
/**
* @brief Class representing wire element of the NDN packet
*/
@@ -223,6 +226,7 @@
Buffer::const_iterator m_value_end;
mutable element_container m_subBlocks;
+ friend class EncodingImpl<true>;
};
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/encoding/encoding-buffer.hpp b/src/encoding/encoding-buffer.hpp
index 62d6a12..b4c9018 100644
--- a/src/encoding/encoding-buffer.hpp
+++ b/src/encoding/encoding-buffer.hpp
@@ -18,6 +18,7 @@
#include "buffer.hpp"
#include "tlv.hpp"
+#include "block.hpp"
#include <boost/lexical_cast.hpp>