extension: use map in create extension
Adjust the Create extension to use a map for metadata instead of
vector.
Tested: Unit tests updated and passing.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I9bd62b8dcc8b18a61958ed64de98b52a48333637
diff --git a/extensions/openpower-pels/additional_data.hpp b/extensions/openpower-pels/additional_data.hpp
index 09dbd20..74abce9 100644
--- a/extensions/openpower-pels/additional_data.hpp
+++ b/extensions/openpower-pels/additional_data.hpp
@@ -38,19 +38,9 @@
* @param[in] ad - the AdditionalData property vector with
* entries of "KEY=VALUE"
*/
- explicit AdditionalData(const std::vector<std::string>& ad)
- {
- for (auto& item : ad)
- {
- auto pos = item.find_first_of('=');
- if (pos == std::string::npos || pos == 0)
- {
- continue;
- }
-
- _data[item.substr(0, pos)] = std::move(item.substr(pos + 1));
- }
- }
+ explicit AdditionalData(const std::map<std::string, std::string>& ad) :
+ _data(ad)
+ {}
/**
* @brief Returns the value of the AdditionalData item for the
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index 03254d2..5b773c6 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -73,7 +73,7 @@
void Manager::create(const std::string& message, uint32_t obmcLogID,
uint64_t timestamp, Entry::Level severity,
- const std::vector<std::string>& additionalData,
+ const std::map<std::string, std::string>& additionalData,
const std::vector<std::string>& associations,
const FFDCEntries& ffdc)
{
@@ -361,7 +361,7 @@
void Manager::createPEL(
const std::string& message, uint32_t obmcLogID, uint64_t timestamp,
phosphor::logging::Entry::Level severity,
- const std::vector<std::string>& additionalData,
+ const std::map<std::string, std::string>& additionalData,
const std::vector<std::string>& /*associations*/, const FFDCEntries& ffdc)
{
auto entry = _registry.lookup(message, rg::LookupType::name);
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index 2429aec..787bb02 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -113,7 +113,7 @@
*/
void create(const std::string& message, uint32_t obmcLogID,
uint64_t timestamp, phosphor::logging::Entry::Level severity,
- const std::vector<std::string>& additionalData,
+ const std::map<std::string, std::string>& additionalData,
const std::vector<std::string>& associations,
const phosphor::logging::FFDCEntries& ffdc =
phosphor::logging::FFDCEntries{});
@@ -319,7 +319,7 @@
*/
void createPEL(const std::string& message, uint32_t obmcLogID,
uint64_t timestamp, phosphor::logging::Entry::Level severity,
- const std::vector<std::string>& additionalData,
+ const std::map<std::string, std::string>& additionalData,
const std::vector<std::string>& associations,
const phosphor::logging::FFDCEntries& ffdc);