diff options
Diffstat (limited to 'redfish-core/lib/sensors.hpp')
-rw-r--r-- | redfish-core/lib/sensors.hpp | 34 |
1 files changed, 23 insertions, 11 deletions
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; |