change default FreshnessPeriod to 0 ms

set InterestLifetime to default value when not present

do not encode ChildSelector if at default value

refs #3944

Change-Id: I4a3ebf5512d0d2270798ed212eab7903ba8b8ed0
diff --git a/src/meta-info.cpp b/src/meta-info.cpp
index 0fd6923..41ad0f7 100644
--- a/src/meta-info.cpp
+++ b/src/meta-info.cpp
@@ -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).
  *
@@ -34,7 +34,7 @@
 
 MetaInfo::MetaInfo()
   : m_type(tlv::ContentType_Blob)
-  , m_freshnessPeriod(-1)
+  , m_freshnessPeriod(DEFAULT_FRESHNESS_PERIOD)
 {
 }
 
@@ -52,8 +52,11 @@
 }
 
 MetaInfo&
-MetaInfo::setFreshnessPeriod(const time::milliseconds& freshnessPeriod)
+MetaInfo::setFreshnessPeriod(time::milliseconds freshnessPeriod)
 {
+  if (freshnessPeriod < time::milliseconds::zero()) {
+    BOOST_THROW_EXCEPTION(std::invalid_argument("FreshnessPeriod must be >= 0"));
+  }
   m_wire.reset();
   m_freshnessPeriod = freshnessPeriod;
   return *this;
@@ -143,23 +146,20 @@
   }
 
   // FinalBlockId
-  if (!m_finalBlockId.empty())
-    {
-      totalLength += prependNestedBlock(encoder, tlv::FinalBlockId, m_finalBlockId);
-    }
+  if (!m_finalBlockId.empty()) {
+    totalLength += prependNestedBlock(encoder, tlv::FinalBlockId, m_finalBlockId);
+  }
 
   // FreshnessPeriod
-  if (m_freshnessPeriod >= time::milliseconds::zero())
-    {
-      totalLength += prependNonNegativeIntegerBlock(encoder, tlv::FreshnessPeriod,
-                                                    m_freshnessPeriod.count());
-    }
+  if (m_freshnessPeriod != DEFAULT_FRESHNESS_PERIOD) {
+    totalLength += prependNonNegativeIntegerBlock(encoder, tlv::FreshnessPeriod,
+                                                  m_freshnessPeriod.count());
+  }
 
   // ContentType
-  if (m_type != tlv::ContentType_Blob)
-    {
-      totalLength += prependNonNegativeIntegerBlock(encoder, tlv::ContentType, m_type);
-    }
+  if (m_type != tlv::ContentType_Blob) {
+    totalLength += prependNonNegativeIntegerBlock(encoder, tlv::ContentType, m_type);
+  }
 
   totalLength += encoder.prependVarNumber(totalLength);
   totalLength += encoder.prependVarNumber(tlv::MetaInfo);
@@ -218,7 +218,7 @@
     ++val;
   }
   else {
-    m_freshnessPeriod = time::milliseconds::min();
+    m_freshnessPeriod = DEFAULT_FRESHNESS_PERIOD;
   }
 
   // FinalBlockId
@@ -248,7 +248,7 @@
   os << "ContentType: " << info.getType();
 
   // FreshnessPeriod
-  if (info.getFreshnessPeriod() >= time::milliseconds::zero()) {
+  if (info.getFreshnessPeriod() > time::milliseconds::zero()) {
     os << ", FreshnessPeriod: " << info.getFreshnessPeriod();
   }