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/exclude.cpp b/src/exclude.cpp
index 76a6260..b5482cd 100644
--- a/src/exclude.cpp
+++ b/src/exclude.cpp
@@ -22,7 +22,7 @@
*/
#include "exclude.hpp"
-#include "util/concepts.hpp"
+#include "encoding/block-helpers.hpp"
#include <boost/range/adaptors.hpp>
@@ -30,6 +30,7 @@
BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Exclude>));
BOOST_CONCEPT_ASSERT((WireEncodable<Exclude>));
+BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<Exclude>));
BOOST_CONCEPT_ASSERT((WireDecodable<Exclude>));
static_assert(std::is_base_of<tlv::Error, Exclude::Error>::value,
"Exclude::Error must inherit from tlv::Error");
@@ -45,7 +46,7 @@
template<encoding::Tag TAG>
size_t
-Exclude::wireEncode(EncodingImpl<TAG>& block) const
+Exclude::wireEncode(EncodingImpl<TAG>& encoder) const
{
if (m_exclude.empty()) {
throw Error("Exclude filter cannot be empty");
@@ -58,23 +59,23 @@
for (const auto& item : m_exclude) {
if (item.second) {
- totalLength += prependBooleanBlock(block, tlv::Any);
+ totalLength += prependEmptyBlock(encoder, tlv::Any);
}
if (!item.first.empty() || !item.second) {
- totalLength += item.first.wireEncode(block);
+ totalLength += item.first.wireEncode(encoder);
}
}
- totalLength += block.prependVarNumber(totalLength);
- totalLength += block.prependVarNumber(tlv::Exclude);
+ totalLength += encoder.prependVarNumber(totalLength);
+ totalLength += encoder.prependVarNumber(tlv::Exclude);
return totalLength;
}
template size_t
-Exclude::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const;
+Exclude::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
template size_t
-Exclude::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const;
+Exclude::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
const Block&
Exclude::wireEncode() const