encoding: Allow creation of a Block from EncodingBuffer

Change-Id: Ifed719e30b9bc04c2e056ac07d6bcf713e8a2bf0
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index 984e8aa..3699f36 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -45,6 +45,15 @@
   Block(const ConstBufferPtr &buffer);
 
   /**
+   * @brief Another helper to create block from a buffer, directly specifying boundaries
+   *        of the block within the buffer
+   *
+   * This version will automatically detect type and position of the value within the block
+   */
+  Block(const ConstBufferPtr &buffer,
+        const Buffer::const_iterator &begin, const Buffer::const_iterator &end);
+  
+  /**
    * @brief A helper version of a constructor to create Block from the raw buffer (type and value-length parsing)
    */
   Block(const uint8_t *buffer, size_t maxlength);
@@ -63,8 +72,8 @@
    */
   Block(const ConstBufferPtr &wire,
         uint32_t type,
-        const Buffer::const_iterator &begin, Buffer::const_iterator &end,
-        const Buffer::const_iterator &valueBegin, Buffer::const_iterator &valueEnd);
+        const Buffer::const_iterator &begin, const Buffer::const_iterator &end,
+        const Buffer::const_iterator &valueBegin, const Buffer::const_iterator &valueEnd);
 
   /**
    * @brief Create Block of a specific type with empty wire buffer
@@ -183,6 +192,9 @@
 
   inline const uint8_t*
   wire() const;
+
+  inline const uint8_t*
+  buf() const;
   
   inline const uint8_t*
   value() const;
@@ -420,6 +432,15 @@
 }
 
 inline const uint8_t*
+Block::buf() const
+{
+  if (!hasWire())
+      throw Error("(Block::wire) Underlying wire buffer is empty");
+
+  return &*m_begin;
+}
+
+inline const uint8_t*
 Block::value() const
 {
   if (!hasValue())