summaryrefslogtreecommitdiff
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
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>
-rw-r--r--http/http2_connection.hpp1
-rw-r--r--http/http_connection.hpp8
-rw-r--r--http/parsing.hpp17
-rw-r--r--http/server_sent_event.hpp1
-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
-rw-r--r--redfish-core/include/event_service_manager.hpp1
-rw-r--r--redfish-core/include/redfish_aggregator.hpp23
-rw-r--r--redfish-core/include/utils/query_param.hpp1
-rw-r--r--redfish-core/lib/ethernet.hpp2
-rw-r--r--redfish-core/lib/health.hpp2
-rw-r--r--redfish-core/lib/log_services.hpp50
-rw-r--r--redfish-core/lib/managers.hpp7
-rw-r--r--redfish-core/lib/network_protocol.hpp2
-rw-r--r--redfish-core/lib/sensors.hpp34
-rw-r--r--redfish-core/lib/update_service.hpp3
-rw-r--r--test/include/str_utility_test.cpp25
21 files changed, 145 insertions, 104 deletions
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index ee3a218807..95d184e67b 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -12,7 +12,6 @@
#include "ssl_key_handler.hpp"
#include "utility.hpp"
-#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/stream.hpp>
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 7ea0ac6d01..196dc5fa73 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -10,9 +10,9 @@
#include "logging.hpp"
#include "mutual_tls.hpp"
#include "ssl_key_handler.hpp"
+#include "str_utility.hpp"
#include "utility.hpp"
-#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/stream.hpp>
@@ -288,10 +288,10 @@ class Connection :
bool isSse =
isContentTypeAllowed(req->getHeaderValue("Accept"),
http_helpers::ContentType::EventStream, false);
+ std::string_view upgradeType(
+ thisReq.getHeaderValue(boost::beast::http::field::upgrade));
if ((thisReq.isUpgrade() &&
- boost::iequals(
- thisReq.getHeaderValue(boost::beast::http::field::upgrade),
- "websocket")) ||
+ bmcweb::asciiIEquals(upgradeType, "websocket")) ||
isSse)
{
asyncResp->res.setCompleteRequestHandler(
diff --git a/http/parsing.hpp b/http/parsing.hpp
index 839b51cae1..9a19baf452 100644
--- a/http/parsing.hpp
+++ b/http/parsing.hpp
@@ -2,10 +2,12 @@
#include "http/http_request.hpp"
#include "logging.hpp"
+#include "str_utility.hpp"
-#include <boost/algorithm/string/predicate.hpp>
#include <nlohmann/json.hpp>
+#include <algorithm>
+#include <cctype>
#include <string_view>
enum class JsonParseResult
@@ -15,14 +17,17 @@ enum class JsonParseResult
Success,
};
+inline bool isJsonContentType(std::string_view contentType)
+{
+ return bmcweb::asciiIEquals(contentType, "application/json") ||
+ bmcweb::asciiIEquals(contentType, "application/json; charset=utf-8");
+}
+
inline JsonParseResult parseRequestAsJson(const crow::Request& req,
nlohmann::json& jsonOut)
{
- std::string_view contentType =
- req.getHeaderValue(boost::beast::http::field::content_type);
-
- if (!boost::iequals(contentType, "application/json") &&
- !boost::iequals(contentType, "application/json; charset=utf-8"))
+ if (!isJsonContentType(
+ req.getHeaderValue(boost::beast::http::field::content_type)))
{
BMCWEB_LOG_WARNING("Failed to parse content type on request");
#ifndef BMCWEB_INSECURE_IGNORE_CONTENT_TYPE
diff --git a/http/server_sent_event.hpp b/http/server_sent_event.hpp
index 49002f60db..f4ad21a69f 100644
--- a/http/server_sent_event.hpp
+++ b/http/server_sent_event.hpp
@@ -3,7 +3,6 @@
#include "http_request.hpp"
#include "http_response.hpp"
-#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/beast/core/multi_buffer.hpp>
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>
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 7399d2e15e..cac6b8b2b2 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -29,7 +29,6 @@
#include <sys/inotify.h>
-#include <boost/algorithm/string/classification.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/url/format.hpp>
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp
index 4ce25fdcf3..f255b9f0a6 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -5,8 +5,7 @@
#include "error_messages.hpp"
#include "http_client.hpp"
#include "http_connection.hpp"
-
-#include <boost/algorithm/string/predicate.hpp>
+#include "parsing.hpp"
#include <array>
#include <ranges>
@@ -154,8 +153,12 @@ inline bool searchCollectionsArray(std::string_view uri,
// defined in the above array.
inline bool isPropertyUri(std::string_view propertyName)
{
- return boost::iends_with(propertyName, "uri") ||
- std::binary_search(nonUriProperties.begin(), nonUriProperties.end(),
+ if (propertyName.ends_with("uri") || propertyName.ends_with("Uri") ||
+ propertyName.ends_with("URI"))
+ {
+ return true;
+ }
+ return std::binary_search(nonUriProperties.begin(), nonUriProperties.end(),
propertyName);
}
@@ -870,9 +873,7 @@ class RedfishAggregator
// We want to attempt prefix fixing regardless of response code
// The resp will not have a json component
// We need to create a json from resp's stringResponse
- std::string_view contentType = resp.getHeaderValue("Content-Type");
- if (boost::iequals(contentType, "application/json") ||
- boost::iequals(contentType, "application/json; charset=utf-8"))
+ if (isJsonContentType(resp.getHeaderValue("Content-Type")))
{
nlohmann::json jsonVal = nlohmann::json::parse(*resp.body(),
nullptr, false);
@@ -934,9 +935,7 @@ class RedfishAggregator
// The resp will not have a json component
// We need to create a json from resp's stringResponse
- std::string_view contentType = resp.getHeaderValue("Content-Type");
- if (boost::iequals(contentType, "application/json") ||
- boost::iequals(contentType, "application/json; charset=utf-8"))
+ if (isJsonContentType(resp.getHeaderValue("Content-Type")))
{
nlohmann::json jsonVal = nlohmann::json::parse(*resp.body(),
nullptr, false);
@@ -1068,9 +1067,7 @@ class RedfishAggregator
// The resp will not have a json component
// We need to create a json from resp's stringResponse
- std::string_view contentType = resp.getHeaderValue("Content-Type");
- if (boost::iequals(contentType, "application/json") ||
- boost::iequals(contentType, "application/json; charset=utf-8"))
+ if (isJsonContentType(resp.getHeaderValue("Content-Type")))
{
bool addedLinks = false;
nlohmann::json jsonVal = nlohmann::json::parse(*resp.body(),
diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp
index 55c92bca42..03b5f53b6b 100644
--- a/redfish-core/include/utils/query_param.hpp
+++ b/redfish-core/include/utils/query_param.hpp
@@ -11,7 +11,6 @@
#include <sys/types.h>
-#include <boost/algorithm/string/classification.hpp>
#include <boost/beast/http/message.hpp> // IWYU pragma: keep
#include <boost/beast/http/status.hpp>
#include <boost/beast/http/verb.hpp>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 099aab83f9..390efbcc36 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -28,8 +28,6 @@
#include "utils/ip_utils.hpp"
#include "utils/json_utils.hpp"
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
#include <boost/url/format.hpp>
#include <array>
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index 6e0d3349bd..20ea0f6236 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -73,7 +73,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate>
bool isSelf = false;
if (selfPath)
{
- if (boost::equals(path.str, *selfPath) ||
+ if (path.str == *selfPath ||
path.str.starts_with(*selfPath + "/"))
{
isSelf = true;
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index e634191151..371ae44867 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -36,10 +36,6 @@
#include <tinyxml2.h>
#include <unistd.h>
-#include <boost/algorithm/string/case_conv.hpp>
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/replace.hpp>
-#include <boost/algorithm/string/split.hpp>
#include <boost/beast/http/verb.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/system/linux_error.hpp>
@@ -50,9 +46,11 @@
#include <array>
#include <charconv>
#include <filesystem>
+#include <iterator>
#include <optional>
#include <ranges>
#include <span>
+#include <string>
#include <string_view>
#include <variant>
@@ -115,6 +113,15 @@ inline std::optional<bool> getProviderNotifyAction(const std::string& notify)
return notifyAction;
}
+inline std::string getDumpPath(std::string_view dumpType)
+{
+ std::string dbusDumpPath = "/xyz/openbmc_project/dump/";
+ std::ranges::transform(dumpType, std::back_inserter(dbusDumpPath),
+ bmcweb::asciiToLower);
+
+ return dbusDumpPath;
+}
+
inline static int getJournalMetadata(sd_journal* journal,
std::string_view field,
std::string_view& contents)
@@ -537,9 +544,7 @@ inline void
" Dump Entries";
nlohmann::json::array_t entriesArray;
- std::string dumpEntryPath =
- "/xyz/openbmc_project/dump/" +
- std::string(boost::algorithm::to_lower_copy(dumpType)) + "/entry/";
+ std::string dumpEntryPath = getDumpPath(dumpType) + "/entry/";
dbus::utility::ManagedObjectType resp(objects);
std::ranges::sort(resp, [](const auto& l, const auto& r) {
@@ -640,9 +645,7 @@ inline void
}
bool foundDumpEntry = false;
- std::string dumpEntryPath =
- "/xyz/openbmc_project/dump/" +
- std::string(boost::algorithm::to_lower_copy(dumpType)) + "/entry/";
+ std::string dumpEntryPath = getDumpPath(dumpType) + "/entry/";
for (const auto& objectPath : resp)
{
@@ -736,11 +739,10 @@ inline void deleteDumpEntry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
return;
}
};
+
crow::connections::systemBus->async_method_call(
respHandler, "xyz.openbmc_project.Dump.Manager",
- "/xyz/openbmc_project/dump/" +
- std::string(boost::algorithm::to_lower_copy(dumpType)) + "/entry/" +
- entryID,
+ std::format("{}/entry/{}", getDumpPath(dumpType), entryID),
"xyz.openbmc_project.Object.Delete", "Delete");
}
@@ -847,10 +849,8 @@ inline void
return;
}
- std::string dumpEntryPath =
- sdbusplus::message::object_path("/xyz/openbmc_project/dump/") /
- std::string(boost::algorithm::to_lower_copy(dumpType)) / "entry" /
- entryID;
+ std::string dumpEntryPath = std::format("{}/entry/{}",
+ getDumpPath(dumpType), entryID);
auto downloadDumpEntryHandler =
[asyncResp, entryID,
@@ -1212,18 +1212,13 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
BMCWEB_LOG_DEBUG("Dump Created. Path: {}", objPath.str);
createDumpTaskCallback(std::move(payload), asyncResp, objPath);
},
- "xyz.openbmc_project.Dump.Manager",
- "/xyz/openbmc_project/dump/" +
- std::string(boost::algorithm::to_lower_copy(dumpType)),
+ "xyz.openbmc_project.Dump.Manager", getDumpPath(dumpType),
"xyz.openbmc_project.Dump.Create", "CreateDump", createDumpParamVec);
}
inline void clearDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& dumpType)
{
- std::string dumpTypeLowerCopy =
- std::string(boost::algorithm::to_lower_copy(dumpType));
-
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
if (ec)
@@ -1233,8 +1228,7 @@ inline void clearDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
return;
}
},
- "xyz.openbmc_project.Dump.Manager",
- "/xyz/openbmc_project/dump/" + dumpTypeLowerCopy,
+ "xyz.openbmc_project.Dump.Manager", getDumpPath(dumpType),
"xyz.openbmc_project.Collection.DeleteAll", "DeleteAll");
}
@@ -2836,11 +2830,7 @@ inline void
// LogServices. Return without adding any error response.
return;
}
-
- const std::string dbusDumpPath =
- "/xyz/openbmc_project/dump/" +
- boost::algorithm::to_lower_copy(dumpType);
-
+ std::string dbusDumpPath = getDumpPath(dumpType);
for (const std::string& path : subTreePaths)
{
if (path == dbusDumpPath)
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 38add8be5b..c61132f215 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -743,7 +743,7 @@ inline const dbus::utility::ManagedObjectType::value_type*
std::replace(escaped.begin(), escaped.end(), ' ', '_');
escaped = "/" + escaped;
auto it = std::ranges::find_if(managedObj, [&escaped](const auto& obj) {
- if (boost::algorithm::ends_with(obj.first.str, escaped))
+ if (obj.first.str.ends_with(escaped))
{
BMCWEB_LOG_DEBUG("Matched {}", obj.first.str);
return true;
@@ -1492,8 +1492,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
auto pathItr = std::ranges::find_if(
managedObj, [&dbusObjName](const auto& obj) {
- return boost::algorithm::ends_with(obj.first.str,
- "/" + dbusObjName);
+ return obj.first.parent_path() == dbusObjName;
});
dbus::utility::DBusPropertiesMap output;
@@ -1621,7 +1620,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
bool foundChassis = false;
for (const auto& obj : managedObj)
{
- if (boost::algorithm::ends_with(obj.first.str, chassis))
+ if (obj.first.parent_path() == chassis)
{
chassis = obj.first.str;
foundChassis = true;
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 151f993d61..c57343c3bd 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -404,7 +404,7 @@ inline void
for (const auto& entry : subtree)
{
- if (boost::algorithm::starts_with(entry.first, netBasePath))
+ if (entry.first.starts_with(netBasePath))
{
sdbusplus::asio::setProperty(
*crow::connections::systemBus, entry.second.begin()->first,
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 19e32cec7f..1935adc136 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -26,11 +26,6 @@
#include "utils/json_utils.hpp"
#include "utils/query_param.hpp"
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/find.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/algorithm/string/replace.hpp>
-#include <boost/range/algorithm/replace_copy_if.hpp>
#include <boost/system/error_code.hpp>
#include <boost/url/format.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -43,6 +38,7 @@
#include <map>
#include <ranges>
#include <set>
+#include <string>
#include <string_view>
#include <utility>
#include <variant>
@@ -823,7 +819,10 @@ inline void objectPropertiesToJson(
}
else if (sensorType == "power")
{
- if (boost::iequals(sensorName, "total_power"))
+ std::string lower;
+ std::ranges::transform(sensorName, std::back_inserter(lower),
+ bmcweb::asciiToLower);
+ if (lower == "total_power")
{
sensorJson["@odata.type"] = "#Power.v1_0_0.PowerControl";
// Put multiple "sensors" into a single PowerControl, so have
@@ -832,7 +831,7 @@ inline void objectPropertiesToJson(
sensorJson["Name"] = "Chassis Power Control";
unit = "/PowerConsumedWatts"_json_pointer;
}
- else if (!(boost::ifind_first(sensorName, "input").empty()))
+ else if (lower.find("input") != std::string::npos)
{
unit = "/PowerInputWatts"_json_pointer;
}
@@ -1073,7 +1072,7 @@ inline void populateFanRedundancy(
sensorsAsyncResp->asyncResp->res);
return;
}
- std::replace(name.begin(), name.end(), '_', ' ');
+ std::ranges::replace(name, '_', ' ');
std::string health;
@@ -2186,11 +2185,22 @@ inline nlohmann::json& getPowerSupply(nlohmann::json& powerSupplyArray,
const InventoryItem& inventoryItem,
const std::string& chassisId)
{
+ std::string nameS;
+ std::ranges::replace_copy(inventoryItem.name, nameS.begin(), '_', ' ');
// Check if matching PowerSupply object already exists in JSON array
for (nlohmann::json& powerSupply : powerSupplyArray)
{
- if (powerSupply["Name"] ==
- boost::replace_all_copy(inventoryItem.name, "_", " "))
+ nlohmann::json::iterator nameIt = powerSupply.find("Name");
+ if (nameIt == powerSupply.end())
+ {
+ continue;
+ }
+ const std::string* name = nameIt->get_ptr<std::string*>();
+ if (name == nullptr)
+ {
+ continue;
+ }
+ if (nameS == *name)
{
return powerSupply;
}
@@ -2203,7 +2213,9 @@ inline nlohmann::json& getPowerSupply(nlohmann::json& powerSupplyArray,
chassisId);
url.set_fragment(("/PowerSupplies"_json_pointer).to_string());
powerSupply["@odata.id"] = std::move(url);
- powerSupply["Name"] = boost::replace_all_copy(inventoryItem.name, "_", " ");
+ std::string escaped;
+ std::ranges::replace_copy(inventoryItem.name, escaped.begin(), '_', ' ');
+ powerSupply["Name"] = std::move(escaped);
powerSupply["Manufacturer"] = inventoryItem.manufacturer;
powerSupply["Model"] = inventoryItem.model;
powerSupply["PartNumber"] = inventoryItem.partNumber;
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 9a07d3c334..74e110170a 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -28,7 +28,6 @@
#include "utils/dbus_utils.hpp"
#include "utils/sw_utils.hpp"
-#include <boost/algorithm/string/case_conv.hpp>
#include <boost/system/error_code.hpp>
#include <boost/url/format.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -731,7 +730,7 @@ inline void
// Make sure that content type is application/octet-stream or
// multipart/form-data
- if (boost::iequals(contentType, "application/octet-stream"))
+ if (bmcweb::asciiIEquals(contentType, "application/octet-stream"))
{
// Setup callback for when new software detected
monitorForSoftwareAvailable(asyncResp, req,
diff --git a/test/include/str_utility_test.cpp b/test/include/str_utility_test.cpp
index a32ce09d95..c52cab9527 100644
--- a/test/include/str_utility_test.cpp
+++ b/test/include/str_utility_test.cpp
@@ -49,4 +49,29 @@ TEST(Split, Sensor)
"unit", "name"));
}
+TEST(AsciiToLower, Positive)
+{
+ using bmcweb::asciiToLower;
+ // Noop
+ EXPECT_EQ(asciiToLower('a'), 'a');
+ EXPECT_EQ(asciiToLower('z'), 'z');
+ EXPECT_EQ(asciiToLower('0'), '0');
+ EXPECT_EQ(asciiToLower('_'), '_');
+
+ // Converted
+ EXPECT_EQ(asciiToLower('A'), 'a');
+ EXPECT_EQ(asciiToLower('Z'), 'z');
+}
+
+TEST(AsciiIEquals, Positive)
+{
+ using bmcweb::asciiIEquals;
+ EXPECT_TRUE(asciiIEquals("FOO", "foo"));
+ EXPECT_TRUE(asciiIEquals("foo", "foo"));
+ EXPECT_TRUE(asciiIEquals("", ""));
+ EXPECT_TRUE(asciiIEquals("_", "_"));
+
+ EXPECT_FALSE(asciiIEquals("bar", "foo"));
+}
+
} // namespace