22 #ifndef NLSR_TLV_NLSR_HPP 23 #define NLSR_TLV_NLSR_HPP 25 #include <ndn-cxx/encoding/tlv.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 67 auto it = block.elements_begin();
69 double doubleFromBlock = 0.0;
71 it->value_size() !=
sizeof(doubleFromBlock)) {
72 BOOST_THROW_EXCEPTION(
ndn::tlv::Error(
"Block does not contain a double"));
74 memcpy(&doubleFromBlock, it->value(),
sizeof(doubleFromBlock));
75 return doubleFromBlock;
83 template<ndn::encoding::Tag TAG>
85 prependDouble(ndn::EncodingImpl<TAG>& encoder, uint32_t type,
double value)
87 size_t totalLength = 0;
89 const uint8_t* doubleBytes =
reinterpret_cast<const uint8_t*
>(&value);
91 totalLength += encoder.prependVarNumber(totalLength);
92 totalLength += encoder.prependVarNumber(type);
101 #endif // NLSR_TLV_NLSR_HPP Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
double readDouble(const ndn::Block &block)
Read a double from a TLV element.
size_t prependDouble(ndn::EncodingImpl< TAG > &encoder, uint32_t type, double value)
Prepend a TLV element containing a double.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.