Move over to upstream c++ style
This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.
This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables. At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.
Tested: Code still compiles, and appears to run, although other issues
are possible and likely.
Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 18ef2af..4865516 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -28,8 +28,8 @@
namespace messages {
-constexpr const char* MESSAGE_VERSION_PREFIX = "Base.1.2.0.";
-constexpr const char* MESSAGE_ANNOTATION = "@Message.ExtendedInfo";
+constexpr const char* messageVersionPrefix = "Base.1.2.0.";
+constexpr const char* messageAnnotation = "@Message.ExtendedInfo";
/**
* @brief Adds Message JSON object to error object
@@ -318,7 +318,7 @@
/**
* @brief Formats CouldNotEstablishConnection message into JSON
- * Message body: "The service failed to establish a connection with the URI
+ * Message body: "The service failed to establish a Connection with the URI
* <arg0>."
*
* @param[in] arg1 Parameter of message that will replace %1 in its body.
@@ -383,7 +383,7 @@
/**
* @brief Formats SourceDoesNotSupportProtocol message into JSON
- * Message body: "The other end of the connection at <arg0> does not support the
+ * Message body: "The other end of the Connection at <arg0> does not support the
* specified protocol <arg1>."
*
* @param[in] arg1 Parameter of message that will replace %1 in its body.
@@ -403,7 +403,7 @@
/**
* @brief Formats AccessDenied message into JSON
- * Message body: "While attempting to establish a connection to <arg0>, the
+ * Message body: "While attempting to establish a Connection to <arg0>, the
* service denied access."
*
* @param[in] arg1 Parameter of message that will replace %1 in its body.
@@ -524,7 +524,7 @@
/**
* @brief Formats InvalidIndex message into JSON
- * Message body: "The Index <arg0> is not a valid offset into the array."
+ * Message body: "The index <arg0> is not a valid offset into the array."
*
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
diff --git a/redfish-core/include/node.hpp b/redfish-core/include/node.hpp
index 113514a..ebd8989 100644
--- a/redfish-core/include/node.hpp
+++ b/redfish-core/include/node.hpp
@@ -28,11 +28,11 @@
*/
class AsyncResp {
public:
- AsyncResp(crow::response& response) : res(response) {}
+ AsyncResp(crow::Response& response) : res(response) {}
~AsyncResp() { res.end(); }
- crow::response& res;
+ crow::Response& res;
};
/**
@@ -43,10 +43,10 @@
public:
template <typename... Params>
Node(CrowApp& app, std::string&& entityUrl, Params... params) {
- app.route_dynamic(entityUrl.c_str())
+ app.routeDynamic(entityUrl.c_str())
.methods("GET"_method, "PATCH"_method, "POST"_method,
- "DELETE"_method)([&](const crow::request& req,
- crow::response& res, Params... params) {
+ "DELETE"_method)([&](const crow::Request& req,
+ crow::Response& res, Params... params) {
std::vector<std::string> paramVec = {params...};
dispatchRequest(app, req, res, paramVec);
});
@@ -74,14 +74,14 @@
void getSubRoutes(const std::vector<std::unique_ptr<Node>>& allNodes) {
const std::string* url = getUrl();
if (url == nullptr) {
- //CROW_LOG_CRITICAL << "Unable to get url for route";
+ //BMCWEB_LOG_CRITICAL << "Unable to get url for route";
return;
}
for (const auto& node : allNodes) {
const std::string* route = node->getUrl();
if (route == nullptr) {
- //CROW_LOG_CRITICAL << "Unable to get url for route";
+ //BMCWEB_LOG_CRITICAL << "Unable to get url for route";
continue;
}
if (boost::starts_with(*route, *url)) {
@@ -110,25 +110,25 @@
protected:
// Node is designed to be an abstract class, so doGet is pure virtual
- virtual void doGet(crow::response& res, const crow::request& req,
+ virtual void doGet(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) {
res.result(boost::beast::http::status::method_not_allowed);
res.end();
- };
+ }
- virtual void doPatch(crow::response& res, const crow::request& req,
+ virtual void doPatch(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) {
res.result(boost::beast::http::status::method_not_allowed);
res.end();
}
- virtual void doPost(crow::response& res, const crow::request& req,
+ virtual void doPost(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) {
res.result(boost::beast::http::status::method_not_allowed);
res.end();
}
- virtual void doDelete(crow::response& res, const crow::request& req,
+ virtual void doDelete(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) {
res.result(boost::beast::http::status::method_not_allowed);
res.end();
@@ -137,11 +137,11 @@
nlohmann::json json;
private:
- void dispatchRequest(CrowApp& app, const crow::request& req,
- crow::response& res,
+ void dispatchRequest(CrowApp& app, const crow::Request& req,
+ crow::Response& res,
const std::vector<std::string>& params) {
auto ctx =
- app.template get_context<crow::TokenAuthorization::Middleware>(req);
+ app.template getContext<crow::token_authorization::Middleware>(req);
if (!isMethodAllowedForUser(req.method(), entityPrivileges,
ctx.session->username)) {
diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp
index e98debb..437bb15 100644
--- a/redfish-core/include/privileges.hpp
+++ b/redfish-core/include/privileges.hpp
@@ -34,7 +34,7 @@
constexpr const int basePrivilegeCount = basePrivileges.size();
/** @brief Max number of privileges per type */
-constexpr const int MAX_PRIVILEGE_COUNT = 32;
+constexpr const int maxPrivilegeCount = 32;
/** @brief A vector of all privilege names and their indexes */
static const std::vector<std::string> privilegeNames{basePrivileges.begin(),
@@ -45,7 +45,7 @@
*
* Entity privileges and user privileges are represented by this class.
*
- * Each incoming connection requires a comparison between privileges held
+ * Each incoming Connection requires a comparison between privileges held
* by the user issuing a request and the target entity's privileges.
*
* To ensure best runtime performance of this comparison, privileges
@@ -73,8 +73,8 @@
Privileges(std::initializer_list<const char*> privilegeList) {
for (const char* privilege : privilegeList) {
if (!setSinglePrivilege(privilege)) {
- CROW_LOG_CRITICAL << "Unable to set privilege " << privilege
- << "in constructor";
+ BMCWEB_LOG_CRITICAL << "Unable to set privilege " << privilege
+ << "in constructor";
}
}
}
@@ -88,10 +88,10 @@
*
*/
bool setSinglePrivilege(const char* privilege) {
- for (int search_index = 0; search_index < privilegeNames.size();
- search_index++) {
- if (privilege == privilegeNames[search_index]) {
- privilegeBitset.set(search_index);
+ for (int searchIndex = 0; searchIndex < privilegeNames.size();
+ searchIndex++) {
+ if (privilege == privilegeNames[searchIndex]) {
+ privilegeBitset.set(searchIndex);
return true;
}
}
@@ -124,16 +124,16 @@
const PrivilegeType type) const {
std::vector<const std::string*> activePrivileges;
- int search_index = 0;
- int end_index = basePrivilegeCount;
+ int searchIndex = 0;
+ int endIndex = basePrivilegeCount;
if (type == PrivilegeType::OEM) {
- search_index = basePrivilegeCount - 1;
- end_index = privilegeNames.size();
+ searchIndex = basePrivilegeCount - 1;
+ endIndex = privilegeNames.size();
}
- for (; search_index < end_index; search_index++) {
- if (privilegeBitset.test(search_index)) {
- activePrivileges.emplace_back(&privilegeNames[search_index]);
+ for (; searchIndex < endIndex; searchIndex++) {
+ if (privilegeBitset.test(searchIndex)) {
+ activePrivileges.emplace_back(&privilegeNames[searchIndex]);
}
}
@@ -154,7 +154,7 @@
}
private:
- std::bitset<MAX_PRIVILEGE_COUNT> privilegeBitset = 0;
+ std::bitset<maxPrivilegeCount> privilegeBitset = 0;
};
using OperationMap = boost::container::flat_map<boost::beast::http::verb,
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index 5651513..25ac954 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -284,7 +284,7 @@
* @return true if JSON is valid, false when JSON is invalid and response has
* been filled with message and ended.
*/
-bool processJsonFromRequest(crow::response& res, const crow::request& req,
+bool processJsonFromRequest(crow::Response& res, const crow::Request& req,
nlohmann::json& reqJson);
} // namespace json_util