Represents a TLV element of the NDN packet format. More...
#include <block.hpp>
Classes | |
class | Error |
Public Types | |
using | value_type = Buffer::value_type |
using | const_iterator = Buffer::const_iterator |
using | element_container = std::vector< Block > |
using | element_iterator = element_container::iterator |
using | element_const_iterator = element_container::const_iterator |
Public Member Functions | |
Block () | |
Create an invalid Block. More... | |
Block (const Block &) | |
Copy constructor. More... | |
Block & | operator= (const Block &) |
Copy assignment operator. More... | |
Block (Block &&) noexcept | |
Move constructor. More... | |
Block & | operator= (Block &&) noexcept |
Move assignment operator. More... | |
Block (span< const uint8_t > buffer) | |
Parse Block from a byte range. More... | |
Block (const EncodingBuffer &buffer) | |
Parse Block from an EncodingBuffer. More... | |
Block (const ConstBufferPtr &buffer) | |
Parse Block from a wire Buffer. More... | |
Block (ConstBufferPtr buffer, Buffer::const_iterator begin, Buffer::const_iterator end, bool verifyLength=true) | |
Parse Block within boundaries of a wire Buffer. More... | |
Block (const Block &block, Block::const_iterator begin, Block::const_iterator end, bool verifyLength=true) | |
Parse Block within boundaries of an existing Block, reusing underlying wire Buffer. More... | |
Block (ConstBufferPtr buffer, uint32_t type, Buffer::const_iterator begin, Buffer::const_iterator end, Buffer::const_iterator valueBegin, Buffer::const_iterator valueEnd) | |
Create a Block from a wire Buffer without parsing. More... | |
Block (uint32_t type) | |
Create a zero-length Block with the specified TLV-TYPE. More... | |
Block (uint32_t type, ConstBufferPtr value) | |
Create a Block with the specified TLV-TYPE and TLV-VALUE. More... | |
Block (uint32_t type, const Block &value) | |
Create a Block with the specified TLV-TYPE and TLV-VALUE. More... | |
bool | isValid () const noexcept |
Check if the Block is valid. More... | |
void | reset () noexcept |
Reset the Block to a default-constructed state. More... | |
void | resetWire () noexcept |
Reset wire buffer but keep TLV-TYPE and sub-elements (if any) More... | |
bool | hasWire () const noexcept |
Check if the Block contains a fully encoded wire representation. More... | |
const_iterator | begin () const |
Get begin iterator of encoded wire. More... | |
const_iterator | end () const |
Get end iterator of encoded wire. More... | |
const uint8_t * | data () const |
Return a raw pointer to the beginning of the encoded wire. More... | |
const uint8_t * | wire () const |
size_t | size () const |
Return the size of the encoded wire, i.e., of the whole TLV. More... | |
ConstBufferPtr | getBuffer () const |
Get underlying buffer. More... | |
uint32_t | type () const noexcept |
Return the TLV-TYPE of the Block. More... | |
bool | hasValue () const noexcept |
Check if the Block has a non-empty TLV-VALUE. More... | |
const_iterator | value_begin () const noexcept |
Get begin iterator of TLV-VALUE. More... | |
const_iterator | value_end () const noexcept |
Get end iterator of TLV-VALUE. More... | |
size_t | value_size () const noexcept |
Return the size of TLV-VALUE, i.e., the TLV-LENGTH. More... | |
span< const uint8_t > | value_bytes () const noexcept |
Return a read-only view of TLV-VALUE as a contiguous range of bytes. More... | |
const uint8_t * | value () const noexcept |
Return a raw pointer to the beginning of TLV-VALUE. More... | |
Block | blockFromValue () const |
Return a new Block constructed from the TLV-VALUE of this Block. More... | |
void | parse () const |
Parse TLV-VALUE into sub-elements. More... | |
void | encode () |
Encode sub-elements into TLV-VALUE. More... | |
const Block & | get (uint32_t type) const |
Return the first sub-element of the specified TLV-TYPE. More... | |
element_const_iterator | find (uint32_t type) const |
Find the first sub-element of the specified TLV-TYPE. More... | |
void | remove (uint32_t type) |
Remove all sub-elements of the specified TLV-TYPE. More... | |
element_iterator | erase (element_const_iterator position) |
Erase a sub-element. More... | |
element_iterator | erase (element_const_iterator first, element_const_iterator last) |
Erase a range of sub-elements. More... | |
void | push_back (const Block &element) |
Append a sub-element. More... | |
void | push_back (Block &&element) |
Append a sub-element. More... | |
element_iterator | insert (element_const_iterator pos, const Block &element) |
Insert a sub-element. More... | |
const element_container & | elements () const |
Get container of sub-elements. More... | |
element_const_iterator | elements_begin () const |
Equivalent to elements().begin() More... | |
element_const_iterator | elements_end () const |
Equivalent to elements().end() More... | |
size_t | elements_size () const |
Equivalent to elements().size() More... | |
operator boost::asio::const_buffer () const | |
Implicit conversion to boost::asio::const_buffer More... | |
Static Public Member Functions | |
static NDN_CXX_NODISCARD std::tuple< bool, Block > | fromBuffer (ConstBufferPtr buffer, size_t offset=0) |
Try to parse Block from a wire buffer. More... | |
static NDN_CXX_NODISCARD std::tuple< bool, Block > | fromBuffer (span< const uint8_t > buffer) |
Try to parse Block from a byte range. More... | |
static Block | fromStream (std::istream &is) |
Parse Block from an input stream. More... | |
Protected Attributes | |
shared_ptr< const Buffer > | m_buffer |
Underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields. More... | |
Buffer::const_iterator | m_begin |
Buffer::const_iterator | m_end |
Buffer::const_iterator | m_valueBegin |
Buffer::const_iterator | m_valueEnd |
uint32_t | m_type = tlv::Invalid |
TLV-TYPE. More... | |
size_t | m_size = 0 |
Total size including Type-Length-Value. More... | |
element_container | m_elements |
Contains the sub-elements. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Block &block) |
Print block to os . More... | |
Represents a TLV element of the NDN packet format.
using ndn::Block::value_type = Buffer::value_type |
using ndn::Block::const_iterator = Buffer::const_iterator |
using ndn::Block::element_container = std::vector<Block> |
using ndn::Block::element_iterator = element_container::iterator |
using ndn::Block::element_const_iterator = element_container::const_iterator |
|
default |
Create an invalid Block.
isValid() == false
Referenced by Block(), blockFromValue(), fromBuffer(), fromStream(), and ndn::operator""_block().
|
default |
Copy constructor.
|
inlinedefaultnoexcept |
Move constructor.
|
explicit |
Parse Block from a byte range.
buffer | sequence of bytes containing a TLV element; the element must be found at the beginning of the buffer but does not need to span the entire buffer |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH exceeds the size of buffer |
Definition at line 51 of file block.cpp.
References end(), m_begin, m_buffer, m_end, m_size, m_type, m_valueBegin, m_valueEnd, NDN_THROW, ndn::tlv::readType(), and ndn::tlv::readVarNumber().
|
explicit |
Parse Block from an EncodingBuffer.
buffer | an EncodingBuffer containing one TLV element |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE |
|
explicit |
Parse Block from a wire Buffer.
buffer | a Buffer containing one TLV element |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE |
buffer
. Definition at line 80 of file block.cpp.
References begin(), Block(), end(), m_begin, m_buffer, m_end, m_size, m_type, m_valueBegin, m_valueEnd, nonstd::optional_lite::std11::move(), NDN_THROW, ndn::tlv::readType(), ndn::tlv::readVarNumber(), and type().
ndn::Block::Block | ( | ConstBufferPtr | buffer, |
Buffer::const_iterator | begin, | ||
Buffer::const_iterator | end, | ||
bool | verifyLength = true |
||
) |
Parse Block within boundaries of a wire Buffer.
buffer | a Buffer containing a TLV element at [begin ,end ) |
begin | begin position of the TLV element within buffer |
end | end position of the TLV element within buffer |
verifyLength | if true, check TLV-LENGTH equals size of TLV-VALUE |
std::invalid_argument | buffer is empty, or [begin ,end ) range is not within buffer |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE |
ndn::Block::Block | ( | const Block & | block, |
Block::const_iterator | begin, | ||
Block::const_iterator | end, | ||
bool | verifyLength = true |
||
) |
Parse Block within boundaries of an existing Block, reusing underlying wire Buffer.
block | a Block whose buffer contains a TLV element at [begin ,end ) |
begin | begin position of the TLV element within block |
end | end position of the TLV element within block |
verifyLength | if true, check TLV-LENGTH equals size of TLV-VALUE |
std::invalid_argument | [begin ,end ) range is not within block |
tlv::Error | Type-Length parsing fails, or TLV-LENGTH does not match size of TLV-VALUE |
ndn::Block::Block | ( | ConstBufferPtr | buffer, |
uint32_t | type, | ||
Buffer::const_iterator | begin, | ||
Buffer::const_iterator | end, | ||
Buffer::const_iterator | valueBegin, | ||
Buffer::const_iterator | valueEnd | ||
) |
Create a Block from a wire Buffer without parsing.
buffer | a Buffer containing a TLV element at [begin ,end ) |
type | TLV-TYPE |
begin | begin position of the TLV element within buffer |
end | end position of the TLV element within buffer |
valueBegin | begin position of TLV-VALUE within buffer |
valueEnd | end position of TLV-VALUE within buffer |
|
explicit |
ndn::Block::Block | ( | uint32_t | type, |
ConstBufferPtr | value | ||
) |
Create a Block with the specified TLV-TYPE and TLV-VALUE.
type | TLV-TYPE |
value | a Buffer containing the TLV-VALUE, must not be nullptr |
Definition at line 139 of file block.cpp.
References m_size, m_type, ndn::tlv::sizeOfVarNumber(), and value_size().
ndn::Block::Block | ( | uint32_t | type, |
const Block & | value | ||
) |
Create a Block with the specified TLV-TYPE and TLV-VALUE.
type | TLV-TYPE |
value | a Block to be nested as TLV-VALUE, must be valid |
Definition at line 150 of file block.cpp.
References m_size, m_type, ndn::tlv::sizeOfVarNumber(), and value_size().
|
static |
Try to parse Block from a wire buffer.
buffer | a Buffer containing a TLV element at offset offset |
offset | begin position of the TLV element within buffer |
Definition at line 162 of file block.cpp.
References begin(), Block(), nonstd::optional_lite::std11::move(), ndn::tlv::readType(), and ndn::tlv::readVarNumber().
Referenced by ndn::security::detail::CertificateBundleDecoder::append(), ndn::nfd::parseDatasetVector(), nfd::face::WebSocketTransport::receiveMessage(), and nfd::face::EthernetTransport::receivePayload().
|
static |
Try to parse Block from a byte range.
buffer | sequence of bytes containing a TLV element; the element must be found at the beginning of the buffer but does not need to span the entire buffer |
Definition at line 190 of file block.cpp.
References Block(), ndn::tlv::readType(), and ndn::tlv::readVarNumber().
|
static |
Parse Block from an input stream.
tlv::Error | TLV-LENGTH is zero or exceeds upper bound |
Definition at line 220 of file block.cpp.
References begin(), Block(), end(), NDN_THROW, ndn::tlv::readType(), ndn::tlv::readVarNumber(), and ndn::tlv::sizeOfVarNumber().
Referenced by ns3::ndn::BlockHeader::Deserialize().
|
inlinenoexcept |
Check if the Block is valid.
A Block is valid unless it has an invalid TLV-TYPE or is default-constructed. In particular, a Block with zero-length TLV-VALUE is valid.
Definition at line 192 of file block.hpp.
Referenced by ndn::Interest::isSigned(), ndn::operator<<(), ndn::security::parse(), nfd::face::Transport::receive(), nfd::face::Transport::send(), ndn::Interest::setApplicationParameters(), ndn::Data::setContent(), size(), and ndn::Data::wireDecode().
|
noexcept |
Reset the Block to a default-constructed state.
Equivalent to *this = Block()
.
isValid() == false
Definition at line 254 of file block.cpp.
Referenced by ndn::MetaInfo::addAppMetaInfo(), ndn::SignatureInfo::addCustomTlv(), ndn::nfd::FibEntry::addNextHopRecord(), ndn::nfd::RibEntry::addRoute(), ndn::KeyLocator::clear(), ndn::nfd::FibEntry::clearNextHopRecords(), ndn::nfd::RibEntry::clearRoutes(), ndn::Interest::getNonce(), ndn::Interest::refreshNonce(), ndn::MetaInfo::removeAppMetaInfo(), ndn::SignatureInfo::removeCustomTlv(), ndn::Data::resetWire(), ndn::Interest::setApplicationParameters(), ndn::MetaInfo::setAppMetaInfo(), ndn::nfd::FaceStatus::setBaseCongestionMarkingInterval(), ndn::mgmt::ControlResponse::setBody(), ndn::nfd::CsInfo::setCapacity(), ndn::mgmt::ControlResponse::setCode(), ndn::nfd::NextHopRecord::setCost(), ndn::nfd::Route::setCost(), ndn::nfd::ForwarderStatus::setCurrentTimestamp(), ndn::nfd::FaceStatus::setDefaultCongestionThreshold(), ndn::nfd::CsInfo::setEnableAdmit(), ndn::nfd::CsInfo::setEnableServe(), ndn::nfd::FaceStatus::setExpirationPeriod(), ndn::nfd::Route::setExpirationPeriod(), ndn::nfd::FaceTraits< FaceEventNotification >::setFaceId(), ndn::nfd::NextHopRecord::setFaceId(), ndn::nfd::Route::setFaceId(), ndn::nfd::FaceQueryFilter::setFaceId(), ndn::nfd::FaceTraits< FaceEventNotification >::setFacePersistency(), ndn::nfd::FaceQueryFilter::setFacePersistency(), ndn::nfd::FaceTraits< FaceEventNotification >::setFaceScope(), ndn::nfd::FaceQueryFilter::setFaceScope(), ndn::MetaInfo::setFinalBlock(), ndn::nfd::FaceTraits< FaceEventNotification >::setFlagBit(), ndn::nfd::Route::setFlags(), ndn::nfd::FaceTraits< FaceEventNotification >::setFlags(), ndn::Interest::setForwardingHint(), ndn::MetaInfo::setFreshnessPeriod(), ndn::Interest::setHopLimit(), ndn::Interest::setInterestLifetime(), ndn::KeyLocator::setKeyDigest(), ndn::SignatureInfo::setKeyLocator(), ndn::nfd::FaceEventNotification::setKind(), ndn::nfd::FaceTraits< FaceEventNotification >::setLinkType(), ndn::nfd::FaceQueryFilter::setLinkType(), ndn::nfd::ChannelStatus::setLocalUri(), ndn::nfd::FaceTraits< FaceEventNotification >::setLocalUri(), ndn::nfd::FaceQueryFilter::setLocalUri(), ndn::nfd::FaceStatus::setMtu(), ndn::nfd::StrategyChoice::setName(), ndn::KeyLocator::setName(), ndn::nfd::RibEntry::setName(), ndn::Interest::setName(), ndn::nfd::ForwarderStatus::setNCsEntries(), ndn::nfd::CsInfo::setNEntries(), ndn::nfd::ForwarderStatus::setNfdVersion(), ndn::nfd::ForwarderStatus::setNFibEntries(), ndn::nfd::CsInfo::setNHits(), ndn::nfd::FaceStatus::setNInBytes(), ndn::nfd::ForwarderStatus::setNInData(), ndn::nfd::FaceStatus::setNInData(), ndn::nfd::ForwarderStatus::setNInInterests(), ndn::nfd::FaceStatus::setNInInterests(), ndn::nfd::ForwarderStatus::setNInNacks(), ndn::nfd::FaceStatus::setNInNacks(), ndn::nfd::ForwarderStatus::setNMeasurementsEntries(), ndn::nfd::CsInfo::setNMisses(), ndn::nfd::ForwarderStatus::setNNameTreeEntries(), ndn::Interest::setNonce(), ndn::nfd::FaceStatus::setNOutBytes(), ndn::nfd::ForwarderStatus::setNOutData(), ndn::nfd::FaceStatus::setNOutData(), ndn::nfd::ForwarderStatus::setNOutInterests(), ndn::nfd::FaceStatus::setNOutInterests(), ndn::nfd::ForwarderStatus::setNOutNacks(), ndn::nfd::FaceStatus::setNOutNacks(), ndn::nfd::ForwarderStatus::setNPitEntries(), ndn::nfd::ForwarderStatus::setNSatisfiedInterests(), ndn::nfd::ForwarderStatus::setNUnsatisfiedInterests(), ndn::nfd::Route::setOrigin(), ndn::security::ValidityPeriod::setPeriod(), ndn::lp::CachePolicy::setPolicy(), ndn::nfd::FibEntry::setPrefix(), ndn::lp::NackHeader::setReason(), ndn::nfd::FaceTraits< FaceEventNotification >::setRemoteUri(), ndn::nfd::FaceQueryFilter::setRemoteUri(), ndn::Interest::setSignatureInfo(), ndn::SignatureInfo::setSignatureType(), ndn::Interest::setSignatureValue(), ndn::nfd::ForwarderStatus::setStartTimestamp(), ndn::nfd::StrategyChoice::setStrategy(), ndn::mgmt::ControlResponse::setText(), ndn::MetaInfo::setType(), ndn::nfd::FaceQueryFilter::setUriScheme(), ndn::Interest::unsetApplicationParameters(), ndn::nfd::FaceStatus::unsetBaseCongestionMarkingInterval(), ndn::nfd::FaceStatus::unsetDefaultCongestionThreshold(), ndn::nfd::FaceStatus::unsetExpirationPeriod(), ndn::nfd::Route::unsetExpirationPeriod(), ndn::nfd::FaceQueryFilter::unsetFaceId(), ndn::nfd::FaceQueryFilter::unsetFacePersistency(), ndn::nfd::FaceQueryFilter::unsetFaceScope(), ndn::nfd::FaceQueryFilter::unsetLinkType(), and ndn::nfd::FaceStatus::unsetMtu().
|
noexcept |
Reset wire buffer but keep TLV-TYPE and sub-elements (if any)
hasWire() == false
hasValue() == false
Definition at line 260 of file block.cpp.
References m_begin, m_buffer, m_end, m_valueBegin, and m_valueEnd.
Referenced by ndn::Name::deepCopy(), erase(), insert(), push_back(), remove(), and ndn::Name::set().
|
inlinenoexcept |
Check if the Block contains a fully encoded wire representation.
A Block has a fully encoded wire if the underlying buffer exists and contains the full Type-Length-Value instead of just the TLV-VALUE field.
Definition at line 221 of file block.hpp.
Referenced by begin(), ndn::name::Component::compare(), data(), encode(), end(), ndn::Data::getFullName(), ndn::Name::hasWire(), ndn::encoding::prependBlock(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), ndn::nfd::FaceEventNotification::wireEncode(), ndn::nfd::FaceStatus::wireEncode(), ndn::nfd::ChannelStatus::wireEncode(), ndn::nfd::StrategyChoice::wireEncode(), ndn::nfd::CsInfo::wireEncode(), ndn::nfd::FaceQueryFilter::wireEncode(), ndn::nfd::ForwarderStatus::wireEncode(), ndn::KeyLocator::wireEncode(), ndn::lp::GeoTag::wireEncode(), ndn::mgmt::ControlResponse::wireEncode(), ndn::lp::NackHeader::wireEncode(), ndn::nfd::NextHopRecord::wireEncode(), ndn::lp::CachePolicy::wireEncode(), ndn::MetaInfo::wireEncode(), ndn::SignatureInfo::wireEncode(), ndn::nfd::ControlParameters::wireEncode(), ndn::Data::wireEncode(), ndn::security::v2::AdditionalDescription::wireEncode(), ndn::security::ValidityPeriod::wireEncode(), ndn::nfd::Route::wireEncode(), ndn::Name::wireEncode(), ndn::Interest::wireEncode(), ndn::nfd::FibEntry::wireEncode(), ndn::nfd::RibEntry::wireEncode(), and ndn::name::Component::wireEncode().
Block::const_iterator ndn::Block::begin | ( | ) | const |
Get begin iterator of encoded wire.
hasWire() == true
Definition at line 267 of file block.cpp.
References hasWire(), m_begin, and NDN_THROW.
Referenced by Block(), fromBuffer(), fromStream(), parse(), ndn::Face::Impl::shutdown(), and ndn::lp::Packet::wireDecode().
Block::const_iterator ndn::Block::end | ( | ) | const |
Get end iterator of encoded wire.
hasWire() == true
Definition at line 276 of file block.cpp.
References hasWire(), m_end, and NDN_THROW.
Referenced by Block(), fromStream(), ndn::operator""_block(), ndn::Face::Impl::shutdown(), and ndn::lp::Packet::wireDecode().
const uint8_t * ndn::Block::data | ( | ) | const |
Return a raw pointer to the beginning of the encoded wire.
hasWire() == true
Definition at line 285 of file block.cpp.
References hasWire(), m_begin, and NDN_THROW.
Referenced by ndn::util::Sqlite3Statement::bind(), ndn::name::Component::compare(), and operator boost::asio::const_buffer().
|
inline |
Definition at line 250 of file block.hpp.
References nonstd::span_lite::size().
Referenced by nfd::name_tree::computeHash(), nfd::name_tree::computeHashes(), and nfd::face::WebSocketTransport::WebSocketTransport().
size_t ndn::Block::size | ( | ) | const |
Return the size of the encoded wire, i.e., of the whole TLV.
isValid() == true
Definition at line 294 of file block.cpp.
References isValid(), m_size, and NDN_THROW.
Referenced by ndn::security::detail::CertificateBundleDecoder::append(), ndn::util::Sqlite3Statement::bind(), ndn::WireEncodable< X >::BOOST_CONCEPT_USAGE(), ndn::name::Component::compare(), nfd::name_tree::computeHash(), nfd::name_tree::computeHashes(), nfd::face::EthernetTransport::doClose(), nfd::face::StreamTransport< boost::asio::local::stream_protocol >::doSend(), nfd::face::LpFragmenter::fragmentPacket(), nfd::face::StreamTransport< boost::asio::local::stream_protocol >::handleReceive(), operator boost::asio::const_buffer(), ndn::nfd::parseDatasetVector(), nfd::face::LpReliability::piggyback(), nfd::face::Transport::receive(), nfd::face::DatagramTransport< boost::asio::ip::udp, Multicast >::receiveDatagram(), nfd::face::InternalForwarderTransport::receivePacket(), nfd::face::InternalClientTransport::receivePacket(), nfd::face::Transport::send(), ndn::Face::Impl::shutdown(), nfd::face::WebSocketTransport::WebSocketTransport(), and ndn::Data::wireEncode().
|
inline |
|
inlinenoexcept |
Return the TLV-TYPE of the Block.
Definition at line 277 of file block.hpp.
Referenced by ndn::MetaInfo::addAppMetaInfo(), ndn::SignatureInfo::addCustomTlv(), ndn::security::detail::CertificateBundleDecoder::append(), Block(), ndn::name::Component::compare(), ndn::lp::DecodeHelper< TlvType, EmptyValue >::decode(), ndn::lp::DecodeHelper< TlvType, uint64_t >::decode(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::lp::FieldDecl< LOCATION, VALUE, TYPE, REPEATABLE, DECODER_TAG, ENCODER_TAG >::decode(), ndn::name::Component::equals(), find(), nfd::face::LpFragmenter::fragmentPacket(), ndn::name::Component::fromEscapedString(), ndn::name::Component::getSuccessor(), ndn::name::Component::isByteOffset(), ndn::name::Component::isImplicitSha256Digest(), ndn::name::Component::isParametersSha256Digest(), ndn::name::Component::isSegment(), ndn::name::Component::isSequenceNumber(), ndn::name::Component::isTimestamp(), ndn::name::Component::isVersion(), ndn::operator<<(), ndn::operator==(), nfd::face::LpReliability::piggyback(), ndn::encoding::prependBlock(), ndn::encoding::readNonNegativeIntegerAs(), remove(), ndn::Interest::setApplicationParameters(), ndn::Data::setContent(), ndn::KeyLocator::setKeyDigest(), ndn::name::Component::toByteOffset(), ndn::name::Component::toSegment(), ndn::name::Component::toSequenceNumber(), ndn::name::Component::toTimestamp(), ndn::name::Component::toUri(), ndn::name::Component::toVersion(), ndn::name::wantAltUri(), ndn::lp::Packet::wireDecode(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::lp::PrefixAnnouncementHeader::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::lp::GeoTag::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::nfd::ControlParameters::wireDecode(), ndn::Data::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::Name::wireDecode(), ndn::Interest::wireDecode(), ndn::nfd::FibEntry::wireDecode(), ndn::nfd::RibEntry::wireDecode(), and ndn::name::Component::wireEncode().
|
inlinenoexcept |
Check if the Block has a non-empty TLV-VALUE.
This property reflects whether the underlying buffer contains a TLV-VALUE. If this is false, TLV-VALUE has zero-length. If this is true, TLV-VALUE may be zero-length.
Definition at line 291 of file block.hpp.
Referenced by encode().
|
inlinenoexcept |
Get begin iterator of TLV-VALUE.
hasValue() == true
Definition at line 301 of file block.hpp.
Referenced by ndn::security::detail::CertificateBundleDecoder::append(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::name::Component::equals(), ndn::Data::extractSignedRanges(), ndn::security::v2::Certificate::getPublicKey(), parse(), ndn::encoding::readNonNegativeInteger(), ndn::util::SegmentFetcher::stop(), and ndn::name::Component::toNumberWithMarker().
|
inlinenoexcept |
Get end iterator of TLV-VALUE.
hasValue() == true
Definition at line 311 of file block.hpp.
Referenced by ndn::security::detail::CertificateBundleDecoder::append(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::name::Component::equals(), ndn::security::v2::Certificate::getPublicKey(), parse(), ndn::encoding::readNonNegativeInteger(), ndn::util::SegmentFetcher::stop(), and ndn::name::Component::toNumberWithMarker().
|
inlinenoexcept |
Return the size of TLV-VALUE, i.e., the TLV-LENGTH.
Definition at line 321 of file block.hpp.
Referenced by Block(), blockFromValue(), ndn::name::Component::compare(), ndn::lp::DecodeHelper< TlvType, EmptyValue >::decode(), ndn::lp::DecodeHelper< TlvType, uint64_t >::decode(), ndn::lp::DecodeHelper< TlvType, std::pair< Buffer::const_iterator, Buffer::const_iterator > >::decode(), ndn::name::Component::equals(), ndn::name::Component::isImplicitSha256Digest(), ndn::name::Component::isNumber(), ndn::name::Component::isNumberWithMarker(), ndn::name::Component::isParametersSha256Digest(), ndn::MetadataObject::MetadataObject(), ndn::security::v2::operator<<(), ndn::operator<<(), ndn::operator==(), ndn::security::parse(), parse(), ndn::encoding::readDouble(), ndn::encoding::readNonNegativeInteger(), ndn::encoding::readString(), ndn::util::SegmentFetcher::stop(), ndn::name::Component::toNumberWithMarker(), value(), and ndn::name::Component::wireEncode().
|
inlinenoexcept |
Return a read-only view of TLV-VALUE as a contiguous range of bytes.
Definition at line 330 of file block.hpp.
References ndn::security::parse().
Referenced by ndn::security::v2::KeyChain::makeCertificate(), ndn::operator<<(), ndn::security::parse(), ndn::encoding::prependBlock(), and ndn::name::Component::wireEncode().
|
noexcept |
Return a raw pointer to the beginning of TLV-VALUE.
Definition at line 306 of file block.cpp.
References m_valueBegin, and value_size().
Referenced by ndn::name::Component::compare(), ndn::lp::DecodeHelper< TlvType, uint64_t >::decode(), ndn::name::Component::fromTimestamp(), ndn::name::Component::getSuccessor(), ndn::name::Component::isNumberWithMarker(), ndn::operator==(), ndn::security::parse(), ndn::name::parseUriEscapedValue(), ndn::encoding::readDouble(), ndn::encoding::readString(), and ndn::name::Component::toTimestamp().
Block ndn::Block::blockFromValue | ( | ) | const |
Return a new Block constructed from the TLV-VALUE of this Block.
value_size() > 0
Definition at line 312 of file block.cpp.
References Block(), m_valueBegin, m_valueEnd, NDN_THROW, and value_size().
Referenced by ndn::security::v2::validator_config::ValidationPolicyConfig::checkPolicy(), nfd::ManagerBase::registerNotificationStream(), and ndn::nfd::Controller::~Controller().
void ndn::Block::parse | ( | ) | const |
Parse TLV-VALUE into sub-elements.
tlv::Error | TLV-VALUE is not a sequence of TLV elements |
Definition at line 324 of file block.cpp.
References begin(), m_buffer, m_elements, NDN_THROW, ndn::tlv::readType(), ndn::tlv::readVarNumber(), ndn::to_string(), value_begin(), value_end(), and value_size().
Referenced by ndn::security::v2::CertificateBundleFetcher::doFetch(), ndn::MetadataObject::MetadataObject(), ndn::Name::Name(), ndn::PrefixAnnouncement::PrefixAnnouncement(), ndn::lp::Packet::wireDecode(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::lp::PrefixAnnouncementHeader::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::lp::GeoTag::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::nfd::ControlParameters::wireDecode(), ndn::Data::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::Name::wireDecode(), ndn::Interest::wireDecode(), ndn::nfd::FibEntry::wireDecode(), ndn::nfd::RibEntry::wireDecode(), ndn::security::v2::AdditionalDescription::wireEncode(), ndn::security::ValidityPeriod::wireEncode(), and ndn::Name::wireEncode().
void ndn::Block::encode | ( | ) |
Encode sub-elements into TLV-VALUE.
Definition at line 351 of file block.cpp.
References hasValue(), hasWire(), m_begin, m_buffer, m_elements, m_end, m_size, m_type, m_valueBegin, and m_valueEnd.
Referenced by ndn::util::DummyClientFace::Transport::receive(), ndn::mgmt::ControlResponse::setBody(), ndn::Data::setContent(), ndn::Interest::setHopLimit(), ndn::security::v2::KeyChain::sign(), ndn::PrefixAnnouncement::toData(), ndn::lp::Packet::wireEncode(), and ndn::mgmt::ControlResponse::wireEncode().
const Block & ndn::Block::get | ( | uint32_t | type | ) | const |
Return the first sub-element of the specified TLV-TYPE.
tlv::Error | a sub-element of the specified type does not exist |
Definition at line 412 of file block.cpp.
References find(), m_elements, m_type, NDN_THROW, and ndn::to_string().
Referenced by ndn::security::v2::CertificateBundleFetcher::doFetch(), ndn::name::Component::getSuccessor(), ndn::MetadataObject::MetadataObject(), ndn::PrefixAnnouncement::PrefixAnnouncement(), and ndn::lp::PrefixAnnouncementHeader::wireDecode().
Block::element_const_iterator ndn::Block::find | ( | uint32_t | type | ) | const |
Find the first sub-element of the specified TLV-TYPE.
Definition at line 424 of file block.cpp.
References m_elements, and type().
Referenced by ndn::Data::extractSignedRanges(), ndn::name::Component::fromEscapedString(), get(), ndn::PrefixAnnouncement::PrefixAnnouncement(), and ndn::nfd::ControlParameters::wireDecode().
void ndn::Block::remove | ( | uint32_t | type | ) |
Remove all sub-elements of the specified TLV-TYPE.
find(type) == elements_end()
Definition at line 431 of file block.cpp.
References m_elements, resetWire(), and type().
Block::element_iterator ndn::Block::erase | ( | Block::element_const_iterator | position | ) |
Erase a sub-element.
Definition at line 441 of file block.cpp.
References m_elements, and resetWire().
Referenced by ndn::Name::erase().
Block::element_iterator ndn::Block::erase | ( | Block::element_const_iterator | first, |
Block::element_const_iterator | last | ||
) |
Erase a range of sub-elements.
Definition at line 448 of file block.cpp.
References m_elements, and resetWire().
void ndn::Block::push_back | ( | const Block & | element | ) |
Append a sub-element.
Definition at line 455 of file block.cpp.
References m_elements, and resetWire().
Referenced by ndn::Name::append(), ndn::PrefixAnnouncement::toData(), and ndn::mgmt::ControlResponse::wireEncode().
void ndn::Block::push_back | ( | Block && | element | ) |
Append a sub-element.
Definition at line 462 of file block.cpp.
References m_elements, nonstd::optional_lite::std11::move(), and resetWire().
Block::element_iterator ndn::Block::insert | ( | Block::element_const_iterator | pos, |
const Block & | element | ||
) |
Insert a sub-element.
pos | position of the new sub-element |
element | new sub-element to insert |
Definition at line 469 of file block.cpp.
References m_elements, and resetWire().
Referenced by ndn::lp::Packet::add().
|
inline |
Get container of sub-elements.
Definition at line 425 of file block.hpp.
Referenced by ndn::Name::at(), ndn::Name::begin(), ndn::security::v2::CertificateBundleFetcher::doFetch(), ndn::Name::empty(), ndn::Name::end(), nfd::face::LpFragmenter::fragmentPacket(), ndn::lp::Packet::get(), ndn::Name::get(), ndn::lp::Packet::list(), ndn::PrefixAnnouncement::PrefixAnnouncement(), ndn::Name::set(), ndn::lp::Packet::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::lp::GeoTag::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::SignatureInfo::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::security::ValidityPeriod::wireDecode(), and ndn::lp::Packet::wireEncode().
|
inline |
Equivalent to elements().begin()
Definition at line 433 of file block.hpp.
Referenced by ndn::Name::erase(), ndn::operator<<(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::KeyLocator::wireDecode(), ndn::lp::NackHeader::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::Data::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::Interest::wireDecode(), ndn::nfd::FibEntry::wireDecode(), and ndn::nfd::RibEntry::wireDecode().
|
inline |
Equivalent to elements().end()
Definition at line 441 of file block.hpp.
Referenced by ndn::Name::erase(), ndn::operator<<(), ndn::PrefixAnnouncement::PrefixAnnouncement(), ndn::nfd::FaceEventNotification::wireDecode(), ndn::nfd::ChannelStatus::wireDecode(), ndn::nfd::StrategyChoice::wireDecode(), ndn::nfd::CsInfo::wireDecode(), ndn::nfd::FaceStatus::wireDecode(), ndn::nfd::FaceQueryFilter::wireDecode(), ndn::nfd::ForwarderStatus::wireDecode(), ndn::mgmt::ControlResponse::wireDecode(), ndn::nfd::NextHopRecord::wireDecode(), ndn::security::SafeBag::wireDecode(), ndn::lp::CachePolicy::wireDecode(), ndn::MetaInfo::wireDecode(), ndn::nfd::ControlParameters::wireDecode(), ndn::Data::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), ndn::nfd::Route::wireDecode(), ndn::Interest::wireDecode(), ndn::nfd::FibEntry::wireDecode(), and ndn::nfd::RibEntry::wireDecode().
|
inline |
Equivalent to elements().size()
Definition at line 449 of file block.hpp.
Referenced by ndn::Name::size(), ndn::lp::NackHeader::wireDecode(), ndn::security::v2::AdditionalDescription::wireDecode(), and ndn::security::ValidityPeriod::wireDecode().
ndn::Block::operator boost::asio::const_buffer | ( | ) | const |
|
friend |
Print block
to os
.
Default-constructed Block is printed as: [invalid]
. Zero-length Block is printed as: TT[empty]
, where TT is TLV-TYPE in decimal. Non-zero-length Block on which parse() has not been called is printed as: TT[LL]=VVVV
, where LL is TLV-LENGTH in decimal, and VVVV is TLV-VALUE in hexadecimal. Block on which parse() has been called is printed as: TT[LL]={SUB,SUB}
, where each SUB is a sub-element printed using this format.
|
protected |
Underlying buffer storing TLV-VALUE and possibly TLV-TYPE and TLV-LENGTH fields.
If m_buffer is nullptr, this is an invalid or zero-length Block with TLV-TYPE given in m_type. Otherwise,
Definition at line 486 of file block.hpp.
Referenced by Block(), encode(), parse(), and resetWire().
|
protected |
|
protected |
|
protected |
Definition at line 490 of file block.hpp.
Referenced by Block(), blockFromValue(), encode(), resetWire(), and value().
|
protected |
Definition at line 491 of file block.hpp.
Referenced by Block(), blockFromValue(), encode(), and resetWire().
|
protected |
|
protected |
|
mutableprotected |