Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2015 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_DETAIL_FIELD_INFO_HPP |
| 23 | #define NDN_CXX_LP_DETAIL_FIELD_INFO_HPP |
| 24 | |
| 25 | #include "../../common.hpp" |
| 26 | |
| 27 | #include "../fields.hpp" |
| 28 | |
| 29 | namespace ndn { |
| 30 | namespace lp { |
| 31 | namespace detail { |
| 32 | |
| 33 | class FieldInfo |
| 34 | { |
| 35 | public: |
| 36 | FieldInfo(); |
| 37 | |
| 38 | explicit |
| 39 | FieldInfo(uint64_t tlv); |
| 40 | |
| 41 | public: |
| 42 | /** |
| 43 | * \brief TLV-TYPE of the field; 0 if field does not exist |
| 44 | */ |
| 45 | uint64_t tlvType; |
| 46 | |
| 47 | /** |
| 48 | * \brief is this field known |
| 49 | */ |
| 50 | bool isRecognized; |
| 51 | |
| 52 | /** |
| 53 | * \brief can this unknown field be ignored |
| 54 | */ |
| 55 | bool canIgnore; |
| 56 | |
| 57 | /** |
| 58 | * \brief is the field repeatable |
| 59 | */ |
| 60 | bool isRepeatable; |
| 61 | |
| 62 | /** |
| 63 | * \brief sort order of field_location_tag |
| 64 | */ |
| 65 | int locationSortOrder; |
| 66 | }; |
| 67 | |
| 68 | template<typename TAG> |
| 69 | inline int |
| 70 | getLocationSortOrder(); |
| 71 | |
| 72 | template<> |
| 73 | inline int |
| 74 | getLocationSortOrder<field_location_tags::Header>() |
| 75 | { |
| 76 | return 1; |
| 77 | } |
| 78 | |
| 79 | template<> |
| 80 | inline int |
| 81 | getLocationSortOrder<field_location_tags::Fragment>() |
| 82 | { |
| 83 | return 2; |
| 84 | } |
| 85 | |
| 86 | inline bool |
| 87 | compareFieldSortOrder(const FieldInfo& first, const FieldInfo& second) |
| 88 | { |
| 89 | return (first.locationSortOrder < second.locationSortOrder) || |
| 90 | (first.locationSortOrder == second.locationSortOrder && first.tlvType < second.tlvType); |
| 91 | } |
| 92 | |
| 93 | } // namespace detail |
| 94 | } // namespace lp |
| 95 | } // namespace ndn |
| 96 | |
| 97 | #endif // NDN_CXX_LP_DETAIL_FIELD_INFO_HPP |