blob: 5cb618c8339856a66a585d5db7ba402f2575082b [file] [log] [blame]
Eric Newberry261dbc22015-07-22 23:18:18 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyeve3874232017-03-26 16:58:59 -05003 * Copyright (c) 2013-2017 Regents of the University of California.
Eric Newberry261dbc22015-07-22 23:18:18 -07004 *
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
Alexander Afanasyeve3874232017-03-26 16:58:59 -050022#ifndef NDN_CXX_LP_FIELD_INFO_HPP
23#define NDN_CXX_LP_FIELD_INFO_HPP
Eric Newberry261dbc22015-07-22 23:18:18 -070024
Alexander Afanasyeve3874232017-03-26 16:58:59 -050025#include "../common.hpp"
Eric Newberry261dbc22015-07-22 23:18:18 -070026
Alexander Afanasyeve3874232017-03-26 16:58:59 -050027#include "fields.hpp"
Eric Newberry261dbc22015-07-22 23:18:18 -070028
29namespace ndn {
30namespace lp {
Eric Newberry261dbc22015-07-22 23:18:18 -070031
32class FieldInfo
33{
34public:
35 FieldInfo();
36
37 explicit
38 FieldInfo(uint64_t tlv);
39
40public:
41 /**
42 * \brief TLV-TYPE of the field; 0 if field does not exist
43 */
44 uint64_t tlvType;
45
46 /**
47 * \brief is this field known
48 */
49 bool isRecognized;
50
51 /**
52 * \brief can this unknown field be ignored
53 */
54 bool canIgnore;
55
56 /**
57 * \brief is the field repeatable
58 */
59 bool isRepeatable;
60
61 /**
62 * \brief sort order of field_location_tag
63 */
64 int locationSortOrder;
65};
66
67template<typename TAG>
68inline int
69getLocationSortOrder();
70
71template<>
72inline int
73getLocationSortOrder<field_location_tags::Header>()
74{
75 return 1;
76}
77
78template<>
79inline int
80getLocationSortOrder<field_location_tags::Fragment>()
81{
82 return 2;
83}
84
85inline bool
86compareFieldSortOrder(const FieldInfo& first, const FieldInfo& second)
87{
88 return (first.locationSortOrder < second.locationSortOrder) ||
89 (first.locationSortOrder == second.locationSortOrder && first.tlvType < second.tlvType);
90}
91
Eric Newberry261dbc22015-07-22 23:18:18 -070092} // namespace lp
93} // namespace ndn
94
Alexander Afanasyeve3874232017-03-26 16:58:59 -050095#endif // NDN_CXX_LP_FIELD_INFO_HPP