22 #ifndef NDN_ENCODING_BLOCK_HELPERS_HPP 23 #define NDN_ENCODING_BLOCK_HELPERS_HPP 27 #include "../util/concepts.hpp" 42 extern template size_t 45 extern template size_t 75 if (value > std::numeric_limits<R>::max()) {
79 return static_cast<R
>(
value);
94 return static_cast<R
>(readNonNegativeIntegerAs<typename std::underlying_type<R>::type>(block));
107 extern template size_t 110 extern template size_t 131 extern template size_t 134 extern template size_t 175 template<
class Iterator>
179 BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<Iterator>));
185 size_t valueLength = last - first;
186 size_t totalLength = valueLength;
195 return encoder.
block();
201 template<
class Iterator>
205 BOOST_CONCEPT_ASSERT((boost::InputIterator<Iterator>));
213 size_t valueLength = encoder.
appendRange(first, last);
217 return encoder.
block();
230 template<
class Iterator>
234 using BinaryBlockHelper =
typename std::conditional<
235 std::is_base_of<std::random_access_iterator_tag,
236 typename std::iterator_traits<Iterator>::iterator_category>
::value,
240 return BinaryBlockHelper::makeBlock(type, first, last);
250 template<Tag TAG,
class U>
256 size_t valueLength = value.wireEncode(encoder);
257 size_t totalLength = valueLength;
258 totalLength += encoder.prependVarNumber(valueLength);
259 totalLength += encoder.prependVarNumber(type);
280 return encoder.
block();
296 #endif // NDN_ENCODING_BLOCK_HELPERS_HPP Copyright (c) 2011-2015 Regents of the University of California.
size_t appendRange(Iterator first, Iterator last)
Append range of bytes from the range [first, last)
EncodingImpl specialization for actual TLV encoding.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
static Block makeBlock(uint32_t type, Iterator first, Iterator last)
Block makeEmptyBlock(uint32_t type)
Create an empty TLV block.
template size_t prependEmptyBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t)
template size_t prependNonNegativeIntegerBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, uint64_t)
template size_t prependNonNegativeIntegerBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, uint64_t)
Block makeNestedBlock(uint32_t type, const U &value)
Create a TLV block containing a nested TLV element.
size_t prependNestedBlock(EncodingImpl< TAG > &encoder, uint32_t type, const U &value)
Prepend a TLV element containing a nested TLV element.
Represents a TLV element of NDN packet format.
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
Prepend a TLV element containing a string.
std::string readString(const Block &block)
Read TLV-VALUE of a TLV element as a string.
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer.
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
EncodingImpl specialization for TLV size estimation.
Create a binary block copying from generic InputIterator.
template size_t prependEmptyBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t)
std::enable_if< std::is_integral< R >::value, R >::type readNonNegativeIntegerAs(const Block &block)
Read a non-negative integer from a TLV element and cast to the specified type.
size_t prependVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
a concept check for TLV abstraction with .wireEncode method
template size_t prependStringBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, const std::string &)
size_t prependEmptyBlock(EncodingImpl< TAG > &encoder, uint32_t type)
Prepend an empty TLV element.
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
size_t prependVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
Block makeStringBlock(uint32_t type, const std::string &value)
Create a TLV block containing a string.
size_t prependRange(Iterator first, Iterator last)
Prepend range of bytes from the range [first, last)
Block block(bool verifyLength=true) const
Create Block from the underlying buffer.
template size_t prependStringBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, const std::string &)
uint32_t type() const
Get TLV-TYPE.
std::string to_string(const V &v)
static Block makeBlock(uint32_t type, Iterator first, Iterator last)
represents an error in TLV encoding or decoding
Create a binary block copying from RandomAccessIterator.