Add RDE BEJ to JSON decoder
Tested:
Tested this locally with unit tests. I will submit unit tests for
review in the next CL.
Signed-off-by: Kasun Athukorala <kasunath@google.com>
Change-Id: I6f3a6882c2dc022938a22a200b213216c6b89c64
diff --git a/include/bej_decoder_json.hpp b/include/bej_decoder_json.hpp
new file mode 100644
index 0000000..96192f4
--- /dev/null
+++ b/include/bej_decoder_json.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "bej_decoder_core.h"
+#include "rde_common.h"
+
+#include <span>
+#include <string>
+#include <vector>
+
+namespace libbej
+{
+
+/**
+ * @brief Class for decoding RDE BEJ to a JSON output.
+ */
+class BejDecoderJson
+{
+
+ public:
+ /**
+ * @brief Decode the encoded PLDM block.
+ *
+ * @param[in] dictionaries - dictionaries needed for decoding.
+ * @param[in] encodedPldmBlock - encoded PLDM block.
+ * @return 0 if successful.
+ */
+ int decode(const BejDictionaries& dictionaries,
+ const std::span<const uint8_t> encodedPldmBlock);
+
+ /**
+ * @brief Get the JSON output related to the latest call to decode.
+ *
+ * @return std::string containing a JSON. If the decoding was
+ * unsuccessful, this might contain partial data (invalid JSON).
+ */
+ std::string getOutput();
+
+ private:
+ bool isPrevAnnotated;
+ std::string output;
+ std::vector<BejStackProperty> stack;
+};
+
+} // namespace libbej