180ad94fcSkasunath #pragma once 280ad94fcSkasunath 3*0aa36d82Skasunath #include "bej_common.h" 480ad94fcSkasunath #include "bej_decoder_core.h" 580ad94fcSkasunath 680ad94fcSkasunath #include <span> 780ad94fcSkasunath #include <string> 880ad94fcSkasunath #include <vector> 980ad94fcSkasunath 1080ad94fcSkasunath namespace libbej 1180ad94fcSkasunath { 1280ad94fcSkasunath 1380ad94fcSkasunath /** 1480ad94fcSkasunath * @brief Class for decoding RDE BEJ to a JSON output. 1580ad94fcSkasunath */ 1680ad94fcSkasunath class BejDecoderJson 1780ad94fcSkasunath { 1880ad94fcSkasunath public: 1980ad94fcSkasunath /** 2080ad94fcSkasunath * @brief Decode the encoded PLDM block. 2180ad94fcSkasunath * 2280ad94fcSkasunath * @param[in] dictionaries - dictionaries needed for decoding. 2380ad94fcSkasunath * @param[in] encodedPldmBlock - encoded PLDM block. 2480ad94fcSkasunath * @return 0 if successful. 2580ad94fcSkasunath */ 2680ad94fcSkasunath int decode(const BejDictionaries& dictionaries, 2780ad94fcSkasunath const std::span<const uint8_t> encodedPldmBlock); 2880ad94fcSkasunath 2980ad94fcSkasunath /** 3080ad94fcSkasunath * @brief Get the JSON output related to the latest call to decode. 3180ad94fcSkasunath * 3280ad94fcSkasunath * @return std::string containing a JSON. If the decoding was 3380ad94fcSkasunath * unsuccessful, this might contain partial data (invalid JSON). 3480ad94fcSkasunath */ 3580ad94fcSkasunath std::string getOutput(); 3680ad94fcSkasunath 3780ad94fcSkasunath private: 3880ad94fcSkasunath bool isPrevAnnotated; 3980ad94fcSkasunath std::string output; 4080ad94fcSkasunath std::vector<BejStackProperty> stack; 4180ad94fcSkasunath }; 4280ad94fcSkasunath 4380ad94fcSkasunath } // namespace libbej 44