encoding: Block::fromStream properly handles TLV-LENGTH=0
Block::fromStream implementation is also optimized to reduce
memory copying.
refs #4180
Change-Id: I7cc073330b9ec4a9af4863db62e6c108d220066b
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index a5f1e1a..91ab51c 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -38,7 +38,8 @@
namespace ndn {
-/** @brief Class representing a wire element of NDN-TLV packet format
+/** @brief Represents a TLV element of NDN packet format
+ * @sa https://named-data.net/doc/ndn-tlv/tlv.html
*/
class Block
{
@@ -144,6 +145,8 @@
Block(uint32_t type, const Block& value);
/** @brief Parse Block from an input stream
+ * @throw tlv::Error TLV-LENGTH is zero or exceeds upper bound
+ * @warning If decoding fails, bytes are still consumed from the input stream.
*/
static Block
fromStream(std::istream& is);