encoding: Optimized encoding of Interest and related data structures
Change-Id: I0609b40565835568e09c3cc0330db441fd9243b6
refs: #1172
diff --git a/src/meta-info.hpp b/src/meta-info.hpp
index fc5458e..ff71570 100644
--- a/src/meta-info.hpp
+++ b/src/meta-info.hpp
@@ -33,6 +33,19 @@
{
wireDecode(block);
}
+
+ template<bool T>
+ size_t
+ wireEncode(EncodingImpl<T> &block) const;
+
+ const Block&
+ wireEncode() const;
+
+ void
+ wireDecode(const Block &wire);
+
+ ///////////////////////////////////////////////////////////////////////////////
+ // Gettest/setters
uint32_t
getType() const
@@ -76,16 +89,6 @@
return *this;
}
- template<bool T>
- size_t
- wireEncode(EncodingImpl<T> &block) const;
-
- const Block&
- wireEncode() const;
-
- void
- wireDecode(const Block &wire);
-
private:
uint32_t m_type;
Milliseconds m_freshnessPeriod;
@@ -108,28 +111,19 @@
// FinalBlockId
if (!m_finalBlockId.empty())
{
- size_t var_len = m_finalBlockId.wireEncode (blk);
- total_len += var_len;
- total_len += blk.prependVarNumber (var_len);
- total_len += blk.prependVarNumber (Tlv::FinalBlockId);
+ total_len += prependNestedBlock(blk, Tlv::FinalBlockId, m_finalBlockId);
}
// FreshnessPeriod
if (m_freshnessPeriod >= 0)
{
- size_t var_len = blk.prependNonNegativeInteger (m_freshnessPeriod);
- total_len += var_len;
- total_len += blk.prependVarNumber (var_len);
- total_len += blk.prependVarNumber (Tlv::FreshnessPeriod);
+ total_len += prependNonNegativeIntegerBlock(blk, Tlv::FreshnessPeriod, m_freshnessPeriod);
}
// ContentType
if (m_type != TYPE_DEFAULT)
{
- size_t var_len = blk.prependNonNegativeInteger (m_type);
- total_len += var_len;
- total_len += blk.prependVarNumber (var_len);
- total_len += blk.prependVarNumber (Tlv::ContentType);
+ total_len += prependNonNegativeIntegerBlock(blk, Tlv::ContentType, m_type);
}
total_len += blk.prependVarNumber (total_len);