Make registries return an object_t
All the registry helper functions should return an object_t, given that
they're guaranteed to return an object. nlohmann::json as a type can
technically be string/int/bool/null/object/array, so it causes some
peculiarities in parsing.
Change-Id: If296477cb8d066d7f44ef0d12f17d94a5301e450
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/src/task_messages.cpp b/redfish-core/src/task_messages.cpp
index 1521a4a..79c312a 100644
--- a/redfish-core/src/task_messages.cpp
+++ b/redfish-core/src/task_messages.cpp
@@ -33,8 +33,9 @@
namespace messages
{
-static nlohmann::json getLog(redfish::registries::TaskEvent::Index name,
- std::span<const std::string_view> args)
+static nlohmann::json::object_t getLog(
+ redfish::registries::TaskEvent::Index name,
+ std::span<const std::string_view> args)
{
size_t index = static_cast<size_t>(name);
if (index >= redfish::registries::TaskEvent::registry.size())
@@ -53,7 +54,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskStarted(std::string_view arg1)
+nlohmann::json::object_t taskStarted(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskStarted,
std::to_array({arg1}));
@@ -66,7 +67,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskCompletedOK(std::string_view arg1)
+nlohmann::json::object_t taskCompletedOK(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK,
std::to_array({arg1}));
@@ -79,7 +80,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskCompletedWarning(std::string_view arg1)
+nlohmann::json::object_t taskCompletedWarning(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning,
std::to_array({arg1}));
@@ -92,7 +93,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskAborted(std::string_view arg1)
+nlohmann::json::object_t taskAborted(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskAborted,
std::to_array({arg1}));
@@ -105,7 +106,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskCancelled(std::string_view arg1)
+nlohmann::json::object_t taskCancelled(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskCancelled,
std::to_array({arg1}));
@@ -118,7 +119,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskRemoved(std::string_view arg1)
+nlohmann::json::object_t taskRemoved(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskRemoved,
std::to_array({arg1}));
@@ -131,7 +132,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskPaused(std::string_view arg1)
+nlohmann::json::object_t taskPaused(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskPaused,
std::to_array({arg1}));
@@ -144,7 +145,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskResumed(std::string_view arg1)
+nlohmann::json::object_t taskResumed(std::string_view arg1)
{
return getLog(redfish::registries::TaskEvent::Index::taskResumed,
std::to_array({arg1}));
@@ -157,7 +158,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json taskProgressChanged(std::string_view arg1, uint64_t arg2)
+nlohmann::json::object_t taskProgressChanged(std::string_view arg1,
+ uint64_t arg2)
{
std::string arg2Str = std::to_string(arg2);
return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged,