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/key-locator.cpp b/src/key-locator.cpp
index fd1a7ad..2f92d5d 100644
--- a/src/key-locator.cpp
+++ b/src/key-locator.cpp
@@ -21,12 +21,12 @@
#include "key-locator.hpp"
#include "encoding/block-helpers.hpp"
-#include "util/concepts.hpp"
namespace ndn {
BOOST_CONCEPT_ASSERT((boost::EqualityComparable<KeyLocator>));
BOOST_CONCEPT_ASSERT((WireEncodable<KeyLocator>));
+BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<KeyLocator>));
BOOST_CONCEPT_ASSERT((WireDecodable<KeyLocator>));
static_assert(std::is_base_of<tlv::Error, KeyLocator::Error>::value,
"KeyLocator::Error must inherit from tlv::Error");
@@ -48,7 +48,7 @@
template<encoding::Tag TAG>
size_t
-KeyLocator::wireEncode(EncodingImpl<TAG>& block) const
+KeyLocator::wireEncode(EncodingImpl<TAG>& encoder) const
{
// KeyLocator ::= KEY-LOCATOR-TYPE TLV-LENGTH (Name | KeyDigest)
// KeyDigest ::= KEY-DIGEST-TYPE TLV-LENGTH BYTE+
@@ -59,22 +59,22 @@
case KeyLocator_None:
break;
case KeyLocator_Name:
- totalLength += m_name.wireEncode(block);
+ totalLength += m_name.wireEncode(encoder);
break;
case KeyLocator_KeyDigest:
- totalLength += block.prependBlock(m_keyDigest);
+ totalLength += encoder.prependBlock(m_keyDigest);
break;
default:
throw Error("Unsupported KeyLocator type");
}
- totalLength += block.prependVarNumber(totalLength);
- totalLength += block.prependVarNumber(tlv::KeyLocator);
+ totalLength += encoder.prependVarNumber(totalLength);
+ totalLength += encoder.prependVarNumber(tlv::KeyLocator);
return totalLength;
}
template size_t
-KeyLocator::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& estimator) const;
+KeyLocator::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
template size_t
KeyLocator::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
@@ -180,7 +180,7 @@
// This function takes a constant reference of a shared pointer.
// It MUST NOT change the reference count of that shared pointer.
- return this->setKeyDigest(dataBlock(tlv::KeyDigest, keyDigest->get(), keyDigest->size()));
+ return this->setKeyDigest(makeBinaryBlock(tlv::KeyDigest, keyDigest->get(), keyDigest->size()));
}
bool