1 #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 
10 namespace libbej
11 {
12 
13 /**
14  * @brief Class for decoding RDE BEJ to a JSON output.
15  */
16 class 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
45