25 #include <boost/mp11/algorithm.hpp>
31 template<
typename Tag>
33 getLocationSortOrder() noexcept
35 if constexpr (std::is_same_v<Tag, field_location_tags::Header>)
37 if constexpr (std::is_same_v<Tag, field_location_tags::Fragment>)
44 FieldInfo() noexcept = default;
47 FieldInfo(uint32_t type) noexcept;
56 FieldInfo::FieldInfo(uint32_t type) noexcept
59 boost::mp11::mp_for_each<FieldSet>([
this] (
auto fieldDecl) {
60 if (
tlvType == decltype(fieldDecl)::TlvType::value) {
63 locationSortOrder = getLocationSortOrder<typename decltype(fieldDecl)::FieldLocation>();
75 compareFieldSortOrder(
const FieldInfo& first,
const FieldInfo& second) noexcept
77 return (first.locationSortOrder < second.locationSortOrder) ||
78 (first.locationSortOrder == second.locationSortOrder && first.tlvType < second.tlvType);
95 if (elements.size() == 1 && elements.front().type() == FragmentField::TlvType::value) {
96 elements.front().parse();
97 return elements.front().elements().front();
109 add<FragmentField>({wire.
begin(), wire.
end()});
122 FieldInfo
info(element.type());
124 if (!
info.isRecognized && !
info.canIgnore) {
129 if (
info.tlvType == prev.tlvType && !
info.isRepeatable) {
133 else if (
info.tlvType != prev.tlvType && !compareFieldSortOrder(prev,
info)) {
146 Packet::comparePos(uint32_t first,
const Block& second) noexcept
148 return compareFieldSortOrder(FieldInfo(first), FieldInfo(second.type()));
Represents a TLV element of the NDN packet format.
const_iterator begin() const
Returns an iterator to the beginning of the encoded wire.
const element_container & elements() const noexcept
Get container of sub-elements.
void encode()
Encode sub-elements into TLV-VALUE.
const_iterator end() const
Returns an iterator past-the-end of the encoded wire.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
void parse() const
Parse TLV-VALUE into sub-elements.
Block wireEncode() const
Encode packet into wire format.
void wireDecode(const Block &wire)
Decode packet from wire format.
std::string to_string(const errinfo_stacktrace &x)
@ HEADER3_MAX
Upper bound of 3-octet header field.
@ HEADER3_MIN
Lower bound of 3-octet header field.
Contains classes and functions related to NDNLPv2.
bool isRecognized
is this field known
uint32_t tlvType
TLV-TYPE of the field; 0 if field does not exist.
bool canIgnore
can this unknown field be ignored
int8_t locationSortOrder
sort order of field_location_tag
bool isRepeatable
is the field repeatable