summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-07-18 20:07:23 +0300
committerEd Tanous <ed@tanous.net>2024-01-19 22:43:50 +0300
commit18f8f608b966c802b3e2a389e3c1ec5a1fd9407b (patch)
tree89684cb74b7492ffc1e34fb8e3a004de18726071 /include
parentf86bcc875a496b3c321a4ed102579a4031617800 (diff)
downloadbmcweb-18f8f608b966c802b3e2a389e3c1ec5a1fd9407b.tar.xz
Remove some boost includes
The less we rely on boost, and more on std algorithms, the less people have to look up, and the more likely that our code will deduplicate. Replace all uses of boost::algorithms with std alternatives. Tested: Redfish Service Validator passes. Change-Id: I8a26f39b5709adc444b4178e92f5f3c7b988b05b Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/http_utility.hpp6
-rw-r--r--include/ibm/locks.hpp25
-rw-r--r--include/ibm/management_console_rest.hpp4
-rw-r--r--include/openbmc_dbus_rest.hpp16
-rw-r--r--include/str_utility.hpp20
-rw-r--r--include/webassets.hpp1
6 files changed, 46 insertions, 26 deletions
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index ae436caf1c..74ab15a86e 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -1,10 +1,6 @@
#pragma once
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/constants.hpp>
-#include <boost/iterator/iterator_facade.hpp>
-#include <boost/type_index/type_index_facade.hpp>
-
+#include <algorithm>
#include <cctype>
#include <iomanip>
#include <ostream>
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 7a161fc754..3bb82b9479 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -3,7 +3,6 @@
#include "ibm/utils.hpp"
#include "logging.hpp"
-#include <boost/algorithm/string/predicate.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/endian/conversion.hpp>
#include <nlohmann/json.hpp>
@@ -363,8 +362,8 @@ inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord)
{
// validate the locktype
- if (!((boost::equals(std::get<2>(refLockRecord), "Read") ||
- (boost::equals(std::get<2>(refLockRecord), "Write")))))
+ if (!((std::get<2>(refLockRecord) == "Read" ||
+ (std::get<2>(refLockRecord) == "Write"))))
{
BMCWEB_LOG_DEBUG("Validation of LockType Failed");
BMCWEB_LOG_DEBUG("Locktype : {}", std::get<2>(refLockRecord));
@@ -392,9 +391,8 @@ inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord)
// validate the lock flags
// Allowed lockflags are locksame,lockall & dontlock
- if (!((boost::equals(p.first, "LockSame") ||
- (boost::equals(p.first, "LockAll")) ||
- (boost::equals(p.first, "DontLock")))))
+ if (!((p.first == "LockSame" || (p.first == "LockAll") ||
+ (p.first == "DontLock"))))
{
BMCWEB_LOG_DEBUG("Validation of lock flags failed");
BMCWEB_LOG_DEBUG("{}", p.first);
@@ -411,8 +409,7 @@ inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord)
return false;
}
- if ((boost::equals(p.first, "LockSame") ||
- (boost::equals(p.first, "LockAll"))))
+ if ((p.first == "LockSame" || (p.first == "LockAll")))
{
++lockFlag;
if (lockFlag >= 2)
@@ -534,8 +531,8 @@ inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1,
{
// No conflict if both are read locks
- if (boost::equals(std::get<2>(refLockRecord1), "Read") &&
- boost::equals(std::get<2>(refLockRecord2), "Read"))
+ if (std::get<2>(refLockRecord1) == "Read" &&
+ std::get<2>(refLockRecord2) == "Read")
{
BMCWEB_LOG_DEBUG("Both are read locks, no conflict");
return false;
@@ -546,8 +543,8 @@ inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1,
{
// return conflict when any of them is try to lock all resources
// under the current resource level.
- if (boost::equals(p.first, "LockAll") ||
- boost::equals(std::get<4>(refLockRecord2)[i].first, "LockAll"))
+ if (p.first == "LockAll" ||
+ std::get<4>(refLockRecord2)[i].first == "LockAll")
{
BMCWEB_LOG_DEBUG(
"Either of the Comparing locks are trying to lock all "
@@ -558,8 +555,8 @@ inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1,
// determine if there is a lock-all-with-same-segment-size.
// If the current segment sizes are the same,then we should fail.
- if ((boost::equals(p.first, "LockSame") ||
- boost::equals(std::get<4>(refLockRecord2)[i].first, "LockSame")) &&
+ if ((p.first == "LockSame" ||
+ std::get<4>(refLockRecord2)[i].first == "LockSame") &&
(p.second == std::get<4>(refLockRecord2)[i].second))
{
return true;
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index fd1e2a5cc8..103017bf09 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -6,9 +6,9 @@
#include "event_service_manager.hpp"
#include "ibm/locks.hpp"
#include "resource_messages.hpp"
+#include "str_utility.hpp"
#include "utils/json_utils.hpp"
-#include <boost/algorithm/string/predicate.hpp>
#include <boost/container/flat_set.hpp>
#include <nlohmann/json.hpp>
#include <sdbusplus/message/types.hpp>
@@ -49,7 +49,7 @@ inline void handleFilePut(const crow::Request& req,
std::error_code ec;
// Check the content-type of the request
boost::beast::string_view contentType = req.getHeaderValue("content-type");
- if (!boost::iequals(contentType, "application/octet-stream"))
+ if (!bmcweb::asciiIEquals(contentType, "application/octet-stream"))
{
asyncResp->res.result(boost::beast::http::status::not_acceptable);
asyncResp->res.jsonValue["Description"] = contentNotAcceptableMsg;
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 6bd3920587..e801a3291c 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -28,8 +28,6 @@
#include <systemd/sd-bus.h>
#include <tinyxml2.h>
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/predicate.hpp>
#include <boost/beast/http/status.hpp>
#include <boost/beast/http/verb.hpp>
#include <boost/container/flat_map.hpp>
@@ -429,7 +427,10 @@ inline void getObjectAndEnumerate(
// Map indicating connection name, and the path where the object
// manager exists
- boost::container::flat_map<std::string, std::string> connections;
+ boost::container::flat_map<
+ std::string, std::string, std::less<>,
+ std::vector<std::pair<std::string, std::string>>>
+ connections;
for (const auto& object : *(transaction->subtree))
{
@@ -711,7 +712,14 @@ inline int convertJsonToDbus(sd_bus_message* m, const std::string& argType,
}
else if (stringValue != nullptr)
{
- boolInt = boost::istarts_with(*stringValue, "t") ? 1 : 0;
+ if (!stringValue->empty())
+ {
+ if (stringValue->front() == 't' ||
+ stringValue->front() == 'T')
+ {
+ boolInt = 1;
+ }
+ }
}
else
{
diff --git a/include/str_utility.hpp b/include/str_utility.hpp
index 7142583ee2..8ac54b9182 100644
--- a/include/str_utility.hpp
+++ b/include/str_utility.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <algorithm>
+#include <ranges>
#include <string>
#include <string_view>
#include <vector>
@@ -21,4 +23,22 @@ inline void split(std::vector<std::string>& strings, std::string_view str,
start = end + 1;
}
}
+
+inline char asciiToLower(char c)
+{
+ // Converts a character to lower case without relying on std::locale
+ if ('A' <= c && c <= 'Z')
+ {
+ c -= ('A' - 'a');
+ }
+ return c;
+}
+
+inline bool asciiIEquals(std::string_view left, std::string_view right)
+{
+ return std::ranges::equal(left, right, [](char lChar, char rChar) {
+ return asciiToLower(lChar) == asciiToLower(rChar);
+ });
+}
+
} // namespace bmcweb
diff --git a/include/webassets.hpp b/include/webassets.hpp
index 5ab03231e4..c5c7228ede 100644
--- a/include/webassets.hpp
+++ b/include/webassets.hpp
@@ -6,7 +6,6 @@
#include "routing.hpp"
#include "webroutes.hpp"
-#include <boost/algorithm/string/replace.hpp>
#include <boost/container/flat_set.hpp>
#include <filesystem>