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>
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index ee3a218..95d184e 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 7ea0ac6..196dc5f 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 @@
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 839b51c..9a19baf 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 @@
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 49002f6..f4ad21a 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 ae436ca..74ab15a 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 7a161fc..3bb82b9 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 @@
{
// 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 @@
// 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 @@
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 @@
{
// 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 @@
{
// 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 @@
// 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 fd1e2a5..103017b 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 @@
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 6bd3920..e801a32 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 @@
// 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 @@
}
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 7142583..8ac54b9 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 @@
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 5ab0323..c5c7228 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 7399d2e..cac6b8b 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 4ce25fd..f255b9f 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 55c92bc..03b5f53 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 099aab8..390efbc 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 6e0d334..20ea0f6 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -73,7 +73,7 @@
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 e634191..371ae44 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 @@
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 @@
" 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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 38add8b..c61132f 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -743,7 +743,7 @@
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 @@
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 @@
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 151f993..c57343c 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -404,7 +404,7 @@
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 19e32ce..1935adc 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 @@
}
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 @@
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 @@
sensorsAsyncResp->asyncResp->res);
return;
}
- std::replace(name.begin(), name.end(), '_', ' ');
+ std::ranges::replace(name, '_', ' ');
std::string health;
@@ -2186,11 +2185,22 @@
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 @@
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 9a07d3c..74e1101 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 @@
// 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 a32ce09..c52cab9 100644
--- a/test/include/str_utility_test.cpp
+++ b/test/include/str_utility_test.cpp
@@ -49,4 +49,29 @@
"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