|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
24 #include <boost/endian/conversion.hpp>
29 namespace endian = boost::endian;
37 size_t valueLength = encoder.prependNonNegativeInteger(value);
38 size_t totalLength = valueLength;
39 totalLength += encoder.prependVarNumber(valueLength);
40 totalLength += encoder.prependVarNumber(type);
60 return encoder.
block();
76 size_t totalLength = encoder.prependVarNumber(0);
77 totalLength += encoder.prependVarNumber(type);
97 return encoder.
block();
106 return encoder.prependByteArrayBlock(type,
reinterpret_cast<const uint8_t*
>(value.data()), value.size());
124 return std::string(
reinterpret_cast<const char*
>(block.
value()), block.
value_size());
129 static_assert(std::numeric_limits<double>::is_iec559,
"This code requires IEEE-754 doubles");
136 std::memcpy(&temp, &value, 8);
137 endian::native_to_big_inplace(temp);
138 return encoder.prependByteArrayBlock(type,
reinterpret_cast<const uint8_t*
>(&temp), 8);
156 return encoder.
block();
166 #if BOOST_VERSION >= 107100
167 return endian::endian_load<double, 8, endian::order::big>(block.
value());
170 std::memcpy(&temp, block.
value(), 8);
171 endian::big_to_native_inplace(temp);
173 std::memcpy(&d, &temp, 8);
189 return encoder.
block();
195 return makeBinaryBlock(type,
reinterpret_cast<const uint8_t*
>(value), length);
template size_t prependDoubleBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, double)
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH.
EncodingImpl specialization for TLV size estimation.
std::string readString(const Block &block)
Read TLV-VALUE of a TLV element as a string.
Buffer::const_iterator value_end() const
Get end iterator of TLV-VALUE.
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
EncodingImpl specialization for actual TLV encoding.
template size_t prependNonNegativeIntegerBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, uint64_t)
Buffer::const_iterator value_begin() const
Get begin iterator of TLV-VALUE.
Block block(bool verifyLength=true) const
Create Block from the underlying buffer.
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer.
template size_t prependStringBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, const std::string &)
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
uint64_t readNonNegativeInteger(size_t size, Iterator &begin, Iterator end)
Read nonNegativeInteger in NDN-TLV encoding.
size_t prependByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize) const noexcept
Prepend TLV block of type type and value from buffer array of size arraySize.
const uint8_t * value() const noexcept
Return a raw pointer to the beginning of TLV-VALUE.
Represents a TLV element of NDN packet format.
size_t prependDoubleBlock(EncodingImpl< TAG > &encoder, uint32_t type, double value)
Prepend a TLV element containing an IEEE 754 double-precision floating-point number.
template size_t prependStringBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, const std::string &)
template size_t prependEmptyBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t)
size_t prependEmptyBlock(EncodingImpl< TAG > &encoder, uint32_t type)
Prepend an empty TLV element.
double readDouble(const Block &block)
Read TLV-VALUE of a TLV element as an IEEE 754 double-precision floating-point number.
template size_t prependDoubleBlock< EncoderTag >(EncodingImpl< EncoderTag > &, uint32_t, double)
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
Prepend a TLV element containing a string.
represents an error in TLV encoding or decoding
Block makeEmptyBlock(uint32_t type)
Create an empty TLV block.
size_t prependByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize)
Prepend TLV block of type type and value from buffer array of size arraySize.
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
template size_t prependEmptyBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t)
Block makeDoubleBlock(uint32_t type, double value)
Create a TLV element containing an IEEE 754 double-precision floating-point number.
Block makeStringBlock(uint32_t type, const std::string &value)
Create a TLV block containing a string.
Copyright (c) 2011-2015 Regents of the University of California.
template size_t prependNonNegativeIntegerBlock< EstimatorTag >(EncodingImpl< EstimatorTag > &, uint32_t, uint64_t)