Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | e387423 | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 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 | |
Alexander Afanasyev | e387423 | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 22 | #ifndef NDN_CXX_LP_FIELD_INFO_HPP |
| 23 | #define NDN_CXX_LP_FIELD_INFO_HPP |
Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | e387423 | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 25 | #include "../common.hpp" |
Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | e387423 | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 27 | #include "fields.hpp" |
Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 28 | |
| 29 | namespace ndn { |
| 30 | namespace lp { |
Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 31 | |
| 32 | class FieldInfo |
| 33 | { |
| 34 | public: |
| 35 | FieldInfo(); |
| 36 | |
| 37 | explicit |
| 38 | FieldInfo(uint64_t tlv); |
| 39 | |
| 40 | public: |
| 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 | |
| 67 | template<typename TAG> |
| 68 | inline int |
| 69 | getLocationSortOrder(); |
| 70 | |
| 71 | template<> |
| 72 | inline int |
| 73 | getLocationSortOrder<field_location_tags::Header>() |
| 74 | { |
| 75 | return 1; |
| 76 | } |
| 77 | |
| 78 | template<> |
| 79 | inline int |
| 80 | getLocationSortOrder<field_location_tags::Fragment>() |
| 81 | { |
| 82 | return 2; |
| 83 | } |
| 84 | |
| 85 | inline bool |
| 86 | compareFieldSortOrder(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 Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 92 | } // namespace lp |
| 93 | } // namespace ndn |
| 94 | |
Alexander Afanasyev | e387423 | 2017-03-26 16:58:59 -0500 | [diff] [blame] | 95 | #endif // NDN_CXX_LP_FIELD_INFO_HPP |