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/management/ndnd-status-response.hpp b/src/management/ndnd-status-response.hpp
index e58de7e..23597b9 100644
--- a/src/management/ndnd-status-response.hpp
+++ b/src/management/ndnd-status-response.hpp
@@ -20,30 +20,39 @@
{
}
- StatusResponse(uint32_t code, const std::string &info)
+ StatusResponse(uint32_t code, const std::string& info)
: code_(code)
, info_(info)
{
}
-
+
+ /**
+ * @brief Create from wire encoding
+ */
+ explicit
+ StatusResponse(const Block& wire)
+ {
+ wireDecode(wire);
+ }
+
inline uint32_t
getCode() const;
inline void
setCode(uint32_t code);
- inline const std::string &
+ inline const std::string&
getInfo() const;
inline void
- setInfo(const std::string &info);
+ setInfo(const std::string& info);
inline const Block&
wireEncode() const;
inline void
- wireDecode(const Block &block);
-
+ wireDecode(const Block& block);
+
private:
uint32_t code_;
std::string info_;
@@ -64,14 +73,14 @@
wire_.reset();
}
-inline const std::string &
+inline const std::string&
StatusResponse::getInfo() const
{
return info_;
}
inline void
-StatusResponse::setInfo(const std::string &info)
+StatusResponse::setInfo(const std::string& info)
{
info_ = info;
wire_.reset();
@@ -93,13 +102,13 @@
wire_.push_back
(dataBlock(tlv::ndnd::StatusText, info_.c_str(), info_.size()));
}
-
- wire_.encode();
+
+ wire_.encode();
return wire_;
}
inline void
-StatusResponse::wireDecode(const Block &wire)
+StatusResponse::wireDecode(const Block& wire)
{
wire_ = wire;
wire_.parse();
@@ -114,7 +123,7 @@
}
inline std::ostream&
-operator << (std::ostream &os, const StatusResponse &status)
+operator << (std::ostream& os, const StatusResponse& status)
{
os << status.getCode() << " " << status.getInfo();
return os;