1 #pragma once 2 3 #include "bej_common.h" 4 #include "bej_decoder_core.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 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 44