PEL: peltool: Add const strings for section header
Added "Section Version", "Sub-section type" and "Created by" constant strings.
Updated all getJSON() functions to use the new constants.
Signed-off-by: Harisuddin Mohamed Isa <harisuddin@gmail.com>
Change-Id: I434192afed929972845c3cfb8876cc5ef784eec2
diff --git a/extensions/openpower-pels/user_data_json.cpp b/extensions/openpower-pels/user_data_json.cpp
index a86ccb3..f91d5f8 100644
--- a/extensions/openpower-pels/user_data_json.cpp
+++ b/extensions/openpower-pels/user_data_json.cpp
@@ -16,7 +16,9 @@
#include "user_data_json.hpp"
+#include "json_utils.hpp"
#include "pel_types.hpp"
+#include "pel_values.hpp"
#include "user_data_formats.hpp"
#include <fifo_map.hpp>
@@ -27,7 +29,7 @@
namespace openpower::pels::user_data
{
-
+namespace pv = openpower::pels::pel_values;
using namespace phosphor::logging;
// Use fifo_map as nlohmann::json's map. We are just ignoring the 'less'
@@ -51,12 +53,9 @@
const fifoJSON& json)
{
fifoJSON output;
- output["Section Version"] = std::to_string(version);
- output["Sub-section type"] = std::to_string(subType);
-
- char value[10];
- sprintf(value, "0x%04X", componentID);
- output["Created by"] = std::string{value};
+ output[pv::sectionVer] = std::to_string(version);
+ output[pv::subSection] = std::to_string(subType);
+ output[pv::createdBy] = getNumberString("0x%04X", componentID);
if (!json.is_object())
{