format update
Change-Id: I9d8d1b1f0a99c37c6b84853d120681d7edc7f912
diff --git a/src/ndncert-common.cpp b/src/ndncert-common.cpp
index 3e31596..3b4d564 100644
--- a/src/ndncert-common.cpp
+++ b/src/ndncert-common.cpp
@@ -23,6 +23,23 @@
namespace ndn {
namespace ndncert {
+std::string
+convertJson2String(const JsonSection& json)
+{
+ std::stringstream ss;
+ boost::property_tree::write_json(ss, json);
+ return ss.str();
+}
+
+JsonSection
+convertString2Json(const std::string& jsonContent)
+{
+ std::istringstream ss(jsonContent);
+ JsonSection json;
+ boost::property_tree::json_parser::read_json(ss, json);
+ return json;
+}
+
std::string statusToString(Status status) {
switch (status)
{
@@ -45,23 +62,6 @@
}
}
-std::string requestTypeToString(RequestType type)
-{
- switch (type)
- {
- case RequestType::NEW:
- return "New";
- case RequestType::RENEW:
- return "Renew";
- case RequestType::REVOKE:
- return "Revoke";
- case RequestType::NOTINITIALIZED:
- return "Not initalized";
- default:
- return "Unrecognized type";
- }
-}
-
std::map<ErrorCode, std::string> errorCodeText = {
{ErrorCode::NO_ERROR, "NO_ERROR"},
{ErrorCode::BAD_INTEREST_FORMAT, "BAD_INTEREST_FORMAT"},
@@ -80,21 +80,21 @@
return errorCodeText.at(code);
}
-std::string
-convertJson2String(const JsonSection& json)
+std::string requestTypeToString(RequestType type)
{
- std::stringstream ss;
- boost::property_tree::write_json(ss, json);
- return ss.str();
-}
-
-JsonSection
-convertString2Json(const std::string& jsonContent)
-{
- std::istringstream ss(jsonContent);
- JsonSection json;
- boost::property_tree::json_parser::read_json(ss, json);
- return json;
+ switch (type)
+ {
+ case RequestType::NEW:
+ return "New";
+ case RequestType::RENEW:
+ return "Renew";
+ case RequestType::REVOKE:
+ return "Revoke";
+ case RequestType::NOTINITIALIZED:
+ return "Not initalized";
+ default:
+ return "Unrecognized type";
+ }
}
} // namespace ndncert
diff --git a/src/ndncert-common.hpp b/src/ndncert-common.hpp
index a1077cc..9bee44a 100644
--- a/src/ndncert-common.hpp
+++ b/src/ndncert-common.hpp
@@ -124,9 +124,16 @@
const std::string CONFIG_CERTIFICATE = "certificate";
const std::string CONFIG_REDIRECTION = "redirect-to";
const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
+typedef boost::property_tree::ptree JsonSection;
+// JSON and string translation for Config file parsing
+std::string
+convertJson2String(const JsonSection& json);
-// NDNCERT Status Enum
+JsonSection
+convertString2Json(const std::string& jsonContent);
+
+// NDNCERT Request status enumeration
enum class Status : uint16_t {
BEFORE_CHALLENGE = 0,
CHALLENGE = 1,
@@ -137,8 +144,11 @@
ENDED = 6
};
-std::string statusToString(Status status);
+// Convert request status to string
+std::string
+statusToString(Status status);
+// NDNCERT error code
enum class ErrorCode : uint16_t {
NO_ERROR = 0,
BAD_INTEREST_FORMAT = 1,
@@ -152,6 +162,11 @@
NO_AVAILABLE_NAMES = 9
};
+// Convert error code to string
+std::string
+errorCodeToString(ErrorCode code);
+
+// NDNCERT request type
enum class RequestType : uint16_t {
NOTINITIALIZED = 0,
NEW = 1,
@@ -159,17 +174,9 @@
REVOKE = 3
};
-std::string requestTypeToString(RequestType type);
-
-std::string errorCodeToString(ErrorCode code);
-
-typedef boost::property_tree::ptree JsonSection;
-
+// Convert request type to string
std::string
-convertJson2String(const JsonSection& json);
-
-JsonSection
-convertString2Json(const std::string& jsonContent);
+requestTypeToString(RequestType type);
} // namespace ndncert
} // namespace ndn