field.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2023 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_LP_FIELD_HPP
23 #define NDN_CXX_LP_FIELD_HPP
24 
26 
27 #include <boost/concept/usage.hpp>
28 
29 namespace ndn::lp {
30 
34 namespace field_location_tags {
35 
39 struct Header {};
40 
44 struct Fragment {};
45 
46 } // namespace field_location_tags
47 
51 template<typename X>
52 struct Field
53 {
54  static_assert(std::is_same_v<typename X::TlvType::value_type, uint32_t>);
55  static_assert(std::is_same_v<typename X::IsRepeatable::value_type, bool>);
56  static_assert(std::is_default_constructible_v<typename X::ValueType>);
57  static_assert(std::is_copy_constructible_v<typename X::ValueType>);
58 
60  {
61  Block wire;
62  X j;
63  typename X::ValueType decoded = j.decode(wire);
64  EncodingBuffer enc;
65  j.encode(enc, decoded);
66  }
67 };
68 
69 } // namespace ndn::lp
70 
71 #endif // NDN_CXX_LP_FIELD_HPP
Represents a TLV element of the NDN packet format.
Definition: block.hpp:45
EncodingImpl< EncoderTag > EncodingBuffer
Contains classes and functions related to NDNLPv2.
Concept check for NDNLPv2 fields.
Definition: field.hpp:53
BOOST_CONCEPT_USAGE(Field)
Definition: field.hpp:59