lp: fold field-info.{cpp,hpp} into packet.cpp

Change-Id: I1a328cb12bb3d1755d440e490c4d00c222d5e873
diff --git a/src/lp/cache-policy.cpp b/src/lp/cache-policy.cpp
index 2802b96..37dad5e 100644
--- a/src/lp/cache-policy.cpp
+++ b/src/lp/cache-policy.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,6 +22,7 @@
  */
 
 #include "cache-policy.hpp"
+#include "../encoding/block-helpers.hpp"
 
 namespace ndn {
 namespace lp {
diff --git a/src/lp/cache-policy.hpp b/src/lp/cache-policy.hpp
index 5c5c5d1..45b9493 100644
--- a/src/lp/cache-policy.hpp
+++ b/src/lp/cache-policy.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -24,11 +24,7 @@
 #ifndef NDN_CXX_LP_CACHE_POLICY_HPP
 #define NDN_CXX_LP_CACHE_POLICY_HPP
 
-#include "../common.hpp"
-#include "../tag.hpp"
 #include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
-
 #include "tlv.hpp"
 
 namespace ndn {
diff --git a/src/lp/field-info.cpp b/src/lp/field-info.cpp
deleted file mode 100644
index 99b0b0b..0000000
--- a/src/lp/field-info.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#include "field-info.hpp"
-
-#include <boost/mpl/for_each.hpp>
-#include <boost/bind.hpp>
-
-namespace ndn {
-namespace lp {
-
-struct ExtractFieldInfo
-{
-  typedef void result_type;
-
-  template<typename T>
-  void
-  operator()(FieldInfo* info, T)
-  {
-    if (T::TlvType::value != info->tlvType) {
-      return;
-    }
-    info->isRecognized = true;
-    info->canIgnore = false;
-    info->isRepeatable = T::IsRepeatable::value;
-    info->locationSortOrder = getLocationSortOrder<typename T::FieldLocation>();
-  }
-};
-
-FieldInfo::FieldInfo()
-  : tlvType(0)
-  , isRecognized(false)
-  , canIgnore(false)
-  , isRepeatable(false)
-  , locationSortOrder(getLocationSortOrder<field_location_tags::Header>())
-{
-}
-
-FieldInfo::FieldInfo(uint64_t tlv)
-  : tlvType(tlv)
-  , isRecognized(false)
-  , canIgnore(false)
-  , isRepeatable(false)
-  , locationSortOrder(getLocationSortOrder<field_location_tags::Header>())
-{
-  boost::mpl::for_each<FieldSet>(boost::bind(ExtractFieldInfo(), this, _1));
-  if (!isRecognized) {
-    canIgnore = tlv::HEADER3_MIN <= tlvType && tlvType <= tlv::HEADER3_MAX &&
-                (tlvType & 0x03) == 0x00;
-  }
-}
-
-} // namespace lp
-} // namespace ndn
diff --git a/src/lp/field-info.hpp b/src/lp/field-info.hpp
deleted file mode 100644
index 5cb618c..0000000
--- a/src/lp/field-info.hpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_CXX_LP_FIELD_INFO_HPP
-#define NDN_CXX_LP_FIELD_INFO_HPP
-
-#include "../common.hpp"
-
-#include "fields.hpp"
-
-namespace ndn {
-namespace lp {
-
-class FieldInfo
-{
-public:
-  FieldInfo();
-
-  explicit
-  FieldInfo(uint64_t tlv);
-
-public:
-  /**
-   * \brief TLV-TYPE of the field; 0 if field does not exist
-   */
-  uint64_t tlvType;
-
-  /**
-   * \brief is this field known
-   */
-  bool isRecognized;
-
-  /**
-   * \brief can this unknown field be ignored
-   */
-  bool canIgnore;
-
-  /**
-   * \brief is the field repeatable
-   */
-  bool isRepeatable;
-
-  /**
-   * \brief sort order of field_location_tag
-   */
-  int locationSortOrder;
-};
-
-template<typename TAG>
-inline int
-getLocationSortOrder();
-
-template<>
-inline int
-getLocationSortOrder<field_location_tags::Header>()
-{
-  return 1;
-}
-
-template<>
-inline int
-getLocationSortOrder<field_location_tags::Fragment>()
-{
-  return 2;
-}
-
-inline bool
-compareFieldSortOrder(const FieldInfo& first, const FieldInfo& second)
-{
-  return (first.locationSortOrder < second.locationSortOrder) ||
-         (first.locationSortOrder == second.locationSortOrder && first.tlvType < second.tlvType);
-}
-
-} // namespace lp
-} // namespace ndn
-
-#endif // NDN_CXX_LP_FIELD_INFO_HPP
diff --git a/src/lp/packet.cpp b/src/lp/packet.cpp
index 5714547..a3062b6 100644
--- a/src/lp/packet.cpp
+++ b/src/lp/packet.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -20,13 +20,103 @@
  */
 
 #include "packet.hpp"
-#include "field-info.hpp"
+#include "fields.hpp"
 
+#include <boost/bind.hpp>
+#include <boost/mpl/for_each.hpp>
 #include <boost/range/adaptor/reversed.hpp>
 
 namespace ndn {
 namespace lp {
 
+namespace {
+
+template<typename TAG>
+int
+getLocationSortOrder();
+
+template<>
+int
+getLocationSortOrder<field_location_tags::Header>()
+{
+  return 1;
+}
+
+template<>
+int
+getLocationSortOrder<field_location_tags::Fragment>()
+{
+  return 2;
+}
+
+class FieldInfo
+{
+public:
+  FieldInfo();
+
+  explicit
+  FieldInfo(uint64_t tlv);
+
+public:
+  uint64_t tlvType;       ///< TLV-TYPE of the field; 0 if field does not exist
+  bool isRecognized;      ///< is this field known
+  bool canIgnore;         ///< can this unknown field be ignored
+  bool isRepeatable;      ///< is the field repeatable
+  int locationSortOrder;  ///< sort order of field_location_tag
+};
+
+class ExtractFieldInfo
+{
+public:
+  using result_type = void;
+
+  template<typename T>
+  void
+  operator()(FieldInfo* info, T) const
+  {
+    if (T::TlvType::value != info->tlvType) {
+      return;
+    }
+    info->isRecognized = true;
+    info->canIgnore = false;
+    info->isRepeatable = T::IsRepeatable::value;
+    info->locationSortOrder = getLocationSortOrder<typename T::FieldLocation>();
+  }
+};
+
+FieldInfo::FieldInfo()
+  : tlvType(0)
+  , isRecognized(false)
+  , canIgnore(false)
+  , isRepeatable(false)
+  , locationSortOrder(getLocationSortOrder<field_location_tags::Header>())
+{
+}
+
+FieldInfo::FieldInfo(uint64_t tlv)
+  : tlvType(tlv)
+  , isRecognized(false)
+  , canIgnore(false)
+  , isRepeatable(false)
+  , locationSortOrder(getLocationSortOrder<field_location_tags::Header>())
+{
+  boost::mpl::for_each<FieldSet>(boost::bind(ExtractFieldInfo(), this, _1));
+  if (!isRecognized) {
+    canIgnore = tlv::HEADER3_MIN <= tlvType &&
+                tlvType <= tlv::HEADER3_MAX &&
+                (tlvType & 0x03) == 0x00;
+  }
+}
+
+bool
+compareFieldSortOrder(const FieldInfo& first, const FieldInfo& second)
+{
+  return (first.locationSortOrder < second.locationSortOrder) ||
+         (first.locationSortOrder == second.locationSortOrder && first.tlvType < second.tlvType);
+}
+
+} // namespace
+
 Packet::Packet()
   : m_wire(Block(tlv::LpPacket))
 {
diff --git a/src/lp/tags.hpp b/src/lp/tags.hpp
index 5e2b3d6..4bcadae 100644
--- a/src/lp/tags.hpp
+++ b/src/lp/tags.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -23,7 +23,7 @@
 #define NDN_CXX_LP_TAGS_HPP
 
 #include "cache-policy.hpp"
-#include "../tag-host.hpp"
+#include "../tag.hpp"
 
 namespace ndn {
 namespace lp {
@@ -52,7 +52,7 @@
 /** \class CongestionMarkTag
  *  \brief a packet tag for CongestionMark field
  *
- * This tag can be attached to Interest, Data, Nack.
+ *  This tag can be attached to Interest, Data, Nack.
  */
 typedef SimpleTag<uint64_t, 13> CongestionMarkTag;