mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-01 19:58:15 +00:00
Add GetBufferSpan() function to bufferbuilder (#6235)
This will return the finished internal buffer data as a span
This commit is contained in:
@@ -1239,6 +1239,14 @@ class FlatBufferBuilder {
|
||||
return buf_.data();
|
||||
}
|
||||
|
||||
/// @brief Get the serialized buffer (after you call `Finish()`) as a span.
|
||||
/// @return Returns a constructed flatbuffers::span that is a view over the
|
||||
/// FlatBuffer data inside the buffer.
|
||||
flatbuffers::span<uint8_t> GetBufferSpan() const {
|
||||
Finished();
|
||||
return flatbuffers::span<uint8_t>(buf_.data(), buf_.size());
|
||||
}
|
||||
|
||||
/// @brief Get a pointer to an unfinished buffer.
|
||||
/// @return Returns a `uint8_t` pointer to the unfinished buffer.
|
||||
uint8_t *GetCurrentBufferPointer() const { return buf_.data(); }
|
||||
|
||||
Reference in New Issue
Block a user