22 #ifndef NDN_ENCODING_BLOCK_HELPERS_HPP 23 #define NDN_ENCODING_BLOCK_HELPERS_HPP 27 #include "../util/concepts.hpp" 82 prependStringBlock(EncodingImpl<TAG>& encoder, uint32_t type,
const std::string& value);
115 template<
class Iterator>
119 BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<Iterator>));
125 size_t valueLength = last - first;
126 size_t totalLength = valueLength;
135 return encoder.
block();
142 template<
class Iterator>
146 BOOST_CONCEPT_ASSERT((boost::InputIterator<Iterator>));
154 size_t valueLength = encoder.
appendRange(first, last);
158 return encoder.
block();
168 template<
class Iterator>
172 static_assert(
sizeof(
typename std::iterator_traits<Iterator>::value_type) == 1,
173 "Iterator should point only to char or unsigned char");
175 typedef typename boost::mpl::if_<
176 std::is_base_of<std::random_access_iterator_tag,
177 typename std::iterator_traits<Iterator>::iterator_category>,
181 return DataBlock::makeBlock(type, first, last);
191 template<Tag TAG,
class U>
197 size_t valueLength = value.wireEncode(encoder);
198 size_t totalLength = valueLength;
199 totalLength += encoder.prependVarNumber(valueLength);
200 totalLength += encoder.prependVarNumber(type);
220 return encoder.
block();
235 #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 real TLV encoding.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
Block makeEmptyBlock(uint32_t type)
Create a TLV block type type containing no value (i.e., a boolean block)
Helper class template to create a data block when RandomAccessIterator is used.
Block makeNestedBlock(uint32_t type, const U &value)
Create a TLV block of type type with WireEncodable value as a value.
size_t prependNestedBlock(EncodingImpl< TAG > &encoder, uint32_t type, const U &value)
Prepend a TLV block of type type with WireEncodable value as a value.
static Block makeBlock(uint32_t type, Iterator first, Iterator last)
Class representing a wire element of NDN-TLV packet format.
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
Helper to prepend TLV block type type with value from a string value.
std::string readString(const Block &block)
Helper to read a string value from a block.
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block type type containing non-negative integer value.
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
EncodingImpl specialization TLV size estimation.
size_t prependVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
a concept check for TLV abstraction with .wireEncode method
Block block(bool verifyLength=true) const
Create Block from the underlying buffer.
size_t prependEmptyBlock(EncodingImpl< TAG > &encoder, uint32_t type)
Helper to prepend TLV block type type containing no value (i.e., a boolean block) ...
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block type type with value from a buffer value of size length.
size_t prependVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
static Block makeBlock(uint32_t type, Iterator first, Iterator last)
Helper class template to create a data block when generic InputIterator is used.
Block makeStringBlock(uint32_t type, const std::string &value)
Create a TLV block type type with value from a string value.
size_t prependRange(Iterator first, Iterator last)
Prepend range of bytes from the range [first, last)