Add comments & remove unneeded accessor on static flatbuffer API
* Add comments indicating that FromFlatbuffer is a "deep" copy, to make
clear that users do not need to manually copy sub-objects themselves.
* Remove the AsMutableFlatbufferVector method. Providing non-const
access to the raw flatbuffer types does not seem to have any value,
and it was resulting in people attempting to use the wrong API to
mutate the flatbuffer state.
Change-Id: Ic3160293a0e4d4d0c439b387cc5dcbfe2e02cd11
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/flatbuffers/static_vector.h b/aos/flatbuffers/static_vector.h
index 1752e00..f4cfea6 100644
--- a/aos/flatbuffers/static_vector.h
+++ b/aos/flatbuffers/static_vector.h
@@ -239,9 +239,6 @@
// Accessors for using the Vector as a flatbuffers::Vector.
// Note that these pointers will be unstable if any memory allocations occur
// that cause memory to get shifted around.
- Flatbuffer *AsMutableFlatbufferVector() {
- return reinterpret_cast<Flatbuffer *>(vector_buffer().data());
- }
ConstFlatbuffer *AsFlatbufferVector() const {
return reinterpret_cast<const Flatbuffer *>(vector_buffer().data());
}
@@ -249,6 +246,8 @@
// Copies the contents of the provided vector into this; returns false on
// failure (e.g., if the provided vector is too long for the amount of space
// we can allocate through reserve()).
+ // This is a deep copy, and will call FromFlatbuffer on any constituent
+ // objects.
[[nodiscard]] bool FromFlatbuffer(ConstFlatbuffer *vector);
// Returns the element at the provided index. index must be less than size().