blob: 96192f4b167e007b1c4f7afa06a90a2d600c0643 [file] [log] [blame]
kasunathb81dcec2022-05-23 12:23:44 -07001#pragma once
2
3#include "bej_decoder_core.h"
4#include "rde_common.h"
5
6#include <span>
7#include <string>
8#include <vector>
9
10namespace libbej
11{
12
13/**
14 * @brief Class for decoding RDE BEJ to a JSON output.
15 */
16class BejDecoderJson
17{
18
19 public:
20 /**
21 * @brief Decode the encoded PLDM block.
22 *
23 * @param[in] dictionaries - dictionaries needed for decoding.
24 * @param[in] encodedPldmBlock - encoded PLDM block.
25 * @return 0 if successful.
26 */
27 int decode(const BejDictionaries& dictionaries,
28 const std::span<const uint8_t> encodedPldmBlock);
29
30 /**
31 * @brief Get the JSON output related to the latest call to decode.
32 *
33 * @return std::string containing a JSON. If the decoding was
34 * unsuccessful, this might contain partial data (invalid JSON).
35 */
36 std::string getOutput();
37
38 private:
39 bool isPrevAnnotated;
40 std::string output;
41 std::vector<BejStackProperty> stack;
42};
43
44} // namespace libbej