Add WriteFlatbufferToJson() overload for type const T* msg
This overload for const T* msg is occasionally useful,
add it and have the const Flatbuffer<T>& msg overload call into
this one.
Change-Id: I472217749394f91838c97358dc3f34455e10d5ae
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/json_to_flatbuffer.h b/aos/json_to_flatbuffer.h
index 01a3c3f..b664036 100644
--- a/aos/json_to_flatbuffer.h
+++ b/aos/json_to_flatbuffer.h
@@ -86,14 +86,19 @@
// Writes a Flatbuffer to a file, or dies.
template <typename T>
-inline void WriteFlatbufferToJson(std::string_view filename,
- const Flatbuffer<T> &msg) {
+inline void WriteFlatbufferToJson(std::string_view filename, const T *msg) {
std::ofstream json_file(std::string(filename), std::ios::out);
CHECK(json_file) << ": Couldn't open " << filename;
json_file << FlatbufferToJson(msg);
json_file.close();
}
+template <typename T>
+inline void WriteFlatbufferToJson(std::string_view filename,
+ const Flatbuffer<T> &msg) {
+ WriteFlatbufferToJson(filename, &msg.message());
+}
+
// Writes a NonSizePrefixedFlatbuffer to a binary file, or dies.
template <typename T>
inline void WriteFlatbufferToFile(std::string_view filename,