blob: 21c25d634675cbaed21126e76d8f533ab12f1a97 [file] [log] [blame]
kasunathb81dcec2022-05-23 12:23:44 -07001#pragma once
2
kasunath0aa36d82022-11-23 14:24:15 -08003#include "bej_common.h"
kasunathb81dcec2022-05-23 12:23:44 -07004#include "bej_decoder_core.h"
kasunathb81dcec2022-05-23 12:23:44 -07005
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{
kasunathb81dcec2022-05-23 12:23:44 -070018 public:
19 /**
20 * @brief Decode the encoded PLDM block.
21 *
22 * @param[in] dictionaries - dictionaries needed for decoding.
23 * @param[in] encodedPldmBlock - encoded PLDM block.
24 * @return 0 if successful.
25 */
26 int decode(const BejDictionaries& dictionaries,
27 const std::span<const uint8_t> encodedPldmBlock);
28
29 /**
30 * @brief Get the JSON output related to the latest call to decode.
31 *
32 * @return std::string containing a JSON. If the decoding was
33 * unsuccessful, this might contain partial data (invalid JSON).
34 */
35 std::string getOutput();
36
37 private:
38 bool isPrevAnnotated;
39 std::string output;
40 std::vector<BejStackProperty> stack;
41};
42
43} // namespace libbej