encoding: Improving structure and documentation of block helpers
This commit add several new helpers to simplify operations with
std::string:
- prependStringBlock
- makeStringBlock
- readString
The following functions are deprecated and their replacements:
- nonNegativeIntegerBlock (use makeNonNegativeIntegerBlock)
- prependBooleanBlock (use prependEmptyBlock)
- booleanBlock (use makeEmptyBlock)
- dataBlock (use makeBinaryBlock)
- nestedBlock (use makeNestedBlock)
Change-Id: Ic595ae64fc9c80c2c04e5fde1d8812e8b9debd60
Refs: #2951
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index e17fe9a..5e5f666 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -206,7 +206,7 @@
uint64_t length = tlv::readVarNumber(begin, end);
if (length == 0) {
- return dataBlock(type, static_cast<uint8_t*>(nullptr), length);
+ return makeEmptyBlock(type);
}
if (length > MAX_SIZE_OF_BLOCK_FROM_STREAM)
@@ -223,7 +223,7 @@
throw tlv::Error("Not enough data in the buffer to fully parse TLV");
}
- return dataBlock(type, buf, length);
+ return makeBinaryBlock(type, buf, length);
}
std::tuple<bool, Block>