Austin Schuh | 3e95e5d | 2019-09-20 00:08:54 -0700 | [diff] [blame] | 1 | #ifndef AOS_JSON_TO_FLATBUFFER_H_ |
| 2 | #define AOS_JSON_TO_FLATBUFFER_H_ |
| 3 | |
| 4 | #include <cstddef> |
| 5 | #include <string> |
| 6 | |
Austin Schuh | d339a9b | 2019-10-05 21:33:32 -0700 | [diff] [blame] | 7 | #include "absl/strings/string_view.h" |
Austin Schuh | 3e95e5d | 2019-09-20 00:08:54 -0700 | [diff] [blame] | 8 | #include "flatbuffers/flatbuffers.h" |
| 9 | |
| 10 | namespace aos { |
| 11 | |
| 12 | // Parses the flatbuffer into the vector, or returns an empty vector. |
| 13 | ::std::vector<uint8_t> JsonToFlatbuffer( |
Austin Schuh | d339a9b | 2019-10-05 21:33:32 -0700 | [diff] [blame] | 14 | const absl::string_view data, const flatbuffers::TypeTable *typetable); |
Austin Schuh | 3e95e5d | 2019-09-20 00:08:54 -0700 | [diff] [blame] | 15 | |
| 16 | // Converts a flatbuffer into a Json string. |
| 17 | // |
| 18 | // multi_line controls if the Json is written out on multiple lines or one. |
| 19 | ::std::string FlatbufferToJson(const uint8_t *buffer, |
| 20 | const flatbuffers::TypeTable *typetable, |
| 21 | bool multi_line = false); |
| 22 | |
Austin Schuh | 3e95e5d | 2019-09-20 00:08:54 -0700 | [diff] [blame] | 23 | } // namespace aos |
| 24 | |
| 25 | #endif // AOS_JSON_TO_FLATBUFFER_H_ |