diff options
author | Ed Tanous <edtanous@google.com> | 2021-11-04 01:02:33 +0300 |
---|---|---|
committer | Ed Tanous <edtanous@google.com> | 2021-12-07 00:23:23 +0300 |
commit | 26702d01c5a9290e8dcd20736223b002ec3ebadd (patch) | |
tree | 4c4b2845c782cc73e126dc0620e3048675d7a2ac | |
parent | 889ff6943d62762eeaf58824b651d2edaf940d1d (diff) | |
download | bmcweb-26702d01c5a9290e8dcd20736223b002ec3ebadd.tar.xz |
/s/boost::beast::span/std::span
std::span is now available in c++ 20 builds, and should be a drop in
replacement for boost::span we were using previously. This commit sed
replaces it, and changes reference to cbegin and cend to begin and end
respectively.
Tested:
Ran redfish-service-validator. No new failures, and all nodes within
/redfish/v1/Registries that would be effected by this change respond
with 200 and the same content as previously.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Iace89473b7c20f32106eae9d872c16cfae5f17f6
-rw-r--r-- | redfish-core/include/event_service_manager.hpp | 19 | ||||
-rw-r--r-- | redfish-core/lib/event_service.hpp | 4 | ||||
-rw-r--r-- | redfish-core/lib/log_services.hpp | 29 |
3 files changed, 26 insertions, 26 deletions
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index a20f36ac0e..eb076c97e5 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -36,6 +36,7 @@ #include <ctime> #include <fstream> #include <memory> +#include <span> #include <variant> namespace redfish @@ -52,22 +53,22 @@ static constexpr const char* eventServiceFile = namespace message_registries { -inline boost::beast::span<const MessageEntry> +inline std::span<const MessageEntry> getRegistryFromPrefix(const std::string& registryName) { if (task_event::header.registryPrefix == registryName) { - return boost::beast::span<const MessageEntry>(task_event::registry); + return {task_event::registry}; } if (openbmc::header.registryPrefix == registryName) { - return boost::beast::span<const MessageEntry>(openbmc::registry); + return {openbmc::registry}; } if (base::header.registryPrefix == registryName) { - return boost::beast::span<const MessageEntry>(base::registry); + return {base::registry}; } - return boost::beast::span<const MessageEntry>(openbmc::registry); + return {openbmc::registry}; } } // namespace message_registries @@ -89,14 +90,14 @@ namespace message_registries { static const Message* getMsgFromRegistry(const std::string& messageKey, - const boost::beast::span<const MessageEntry>& registry) + const std::span<const MessageEntry>& registry) { - boost::beast::span<const MessageEntry>::const_iterator messageIt = - std::find_if(registry.cbegin(), registry.cend(), + std::span<const MessageEntry>::iterator messageIt = + std::find_if(registry.begin(), registry.end(), [&messageKey](const MessageEntry& messageEntry) { return !messageKey.compare(messageEntry.first); }); - if (messageIt != registry.cend()) + if (messageIt != registry.end()) { return &messageIt->second; } diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp index d273aea3b8..da9a165953 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -416,13 +416,13 @@ inline void requestRoutesEventDestinationCollection(App& app) // Check for Message ID in each of the selected Registry for (const std::string& it : registryPrefix) { - const boost::beast::span< + const std::span< const redfish::message_registries::MessageEntry> registry = redfish::message_registries:: getRegistryFromPrefix(it); if (std::any_of( - registry.cbegin(), registry.cend(), + registry.begin(), registry.end(), [&id](const redfish::message_registries:: MessageEntry& messageEntry) { return !id.compare(messageEntry.first); diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 65b12f3038..f71f81b66d 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -39,6 +39,7 @@ #include <charconv> #include <filesystem> #include <optional> +#include <span> #include <string_view> #include <variant> @@ -57,17 +58,16 @@ constexpr char const* crashdumpTelemetryInterface = namespace message_registries { -static const Message* getMessageFromRegistry( - const std::string& messageKey, - const boost::beast::span<const MessageEntry> registry) -{ - boost::beast::span<const MessageEntry>::const_iterator messageIt = - std::find_if(registry.cbegin(), registry.cend(), - [&messageKey](const MessageEntry& messageEntry) { - return !std::strcmp(messageEntry.first, - messageKey.c_str()); - }); - if (messageIt != registry.cend()) +static const Message* + getMessageFromRegistry(const std::string& messageKey, + const std::span<const MessageEntry> registry) +{ + std::span<const MessageEntry>::iterator messageIt = std::find_if( + registry.begin(), registry.end(), + [&messageKey](const MessageEntry& messageEntry) { + return !std::strcmp(messageEntry.first, messageKey.c_str()); + }); + if (messageIt != registry.end()) { return &messageIt->second; } @@ -90,13 +90,12 @@ static const Message* getMessage(const std::string_view& messageID) if (std::string(base::header.registryPrefix) == registryName) { return getMessageFromRegistry( - messageKey, boost::beast::span<const MessageEntry>(base::registry)); + messageKey, std::span<const MessageEntry>(base::registry)); } if (std::string(openbmc::header.registryPrefix) == registryName) { return getMessageFromRegistry( - messageKey, - boost::beast::span<const MessageEntry>(openbmc::registry)); + messageKey, std::span<const MessageEntry>(openbmc::registry)); } return nullptr; } @@ -1135,7 +1134,7 @@ static int fillEventLogEntryJson(const std::string& logEntryID, } // Get the MessageArgs from the log if there are any - boost::beast::span<std::string> messageArgs; + std::span<std::string> messageArgs; if (logEntryFields.size() > 1) { std::string& messageArgsStart = logEntryFields[1]; |