Add CompareFlatBuffer method
We are using the simplest possible version of this, which is to copy the
two flatbuffers and see if the resulting memory matches. That should be
determistic between the two, so the exact resulting layout should match.
Change-Id: I5f9b553631cd13bfe93b5f3738d9b0659a7d993b
diff --git a/aos/flatbuffer_merge.h b/aos/flatbuffer_merge.h
index dafba34..5e84160 100644
--- a/aos/flatbuffer_merge.h
+++ b/aos/flatbuffer_merge.h
@@ -77,6 +77,18 @@
return FlatbufferDetachedBuffer<T>(fbb.Release());
}
+// Compares 2 flatbuffers. Returns true if they match, false otherwise.
+bool CompareFlatBuffer(const flatbuffers::TypeTable *typetable,
+ const flatbuffers::Table *t1,
+ const flatbuffers::Table *t2);
+
+template <class T>
+inline bool CompareFlatBuffer(const T *t1, const T *t2) {
+ return CompareFlatBuffer(T::MiniReflectTypeTable(),
+ reinterpret_cast<const flatbuffers::Table *>(t1),
+ reinterpret_cast<const flatbuffers::Table *>(t2));
+}
+
} // namespace aos
#endif // AOS_FLATBUFFER_MERGE_H_