kasunath | b81dcec | 2022-05-23 12:23:44 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
kasunath | 0aa36d8 | 2022-11-23 14:24:15 -0800 | [diff] [blame] | 3 | #include "bej_common.h" |
kasunath | b81dcec | 2022-05-23 12:23:44 -0700 | [diff] [blame] | 4 | #include "bej_decoder_core.h" |
kasunath | b81dcec | 2022-05-23 12:23:44 -0700 | [diff] [blame] | 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 | { |
kasunath | b81dcec | 2022-05-23 12:23:44 -0700 | [diff] [blame] | 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 |