src: Improving consistency and correcting code style
As of this commit, all data structures can be directly constructed from
wire format.
This commit excludes full correction of code style in security/ and
tools/ndnsec*, which will be part of a different commit.
Change-Id: I121ac1f81948bc7468990df52cdefeb2988d91a1
Refs: #1403
diff --git a/src/key-locator.hpp b/src/key-locator.hpp
index a139bf7..14a1b5e 100644
--- a/src/key-locator.hpp
+++ b/src/key-locator.hpp
@@ -37,7 +37,19 @@
{
}
- KeyLocator(const Name& name);
+ KeyLocator(const Name& name)
+ {
+ setName(name);
+ }
+
+ /**
+ * @brief Create from wire encoding
+ */
+ explicit
+ KeyLocator(const Block& wire)
+ {
+ wireDecode(wire);
+ }
///////////////////////////////////////////////////////////////////////////////
@@ -53,7 +65,7 @@
///////////////////////////////////////////////////////////////////////////////
- bool
+ bool
empty() const
{
return m_type == KeyLocator_None;
@@ -87,12 +99,6 @@
mutable Block m_wire;
};
-inline
-KeyLocator::KeyLocator(const Name& name)
-{
- setName(name);
-}
-
template<bool T>
inline size_t
KeyLocator::wireEncode(EncodingImpl<T>& block) const
@@ -105,21 +111,21 @@
// KeyLocatorDigest ::= KEY-LOCATOR-DIGEST-TYPE TLV-LENGTH BYTE+
- size_t total_len = 0;
+ size_t totalLength = 0;
switch (m_type) {
case KeyLocator_None:
break;
case KeyLocator_Name:
- total_len += m_name.wireEncode(block);
+ totalLength += m_name.wireEncode(block);
break;
default:
throw Error("Unsupported KeyLocator type");
}
- total_len += block.prependVarNumber(total_len);
- total_len += block.prependVarNumber(Tlv::KeyLocator);
- return total_len;
+ totalLength += block.prependVarNumber(totalLength);
+ totalLength += block.prependVarNumber(Tlv::KeyLocator);
+ return totalLength;
}
inline const Block&