/src/flatbuffers/include/flatbuffers/flatbuffer_builder.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2021 Google Inc. All rights reserved. |
3 | | * |
4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | |
17 | | #ifndef FLATBUFFERS_FLATBUFFER_BUILDER_H_ |
18 | | #define FLATBUFFERS_FLATBUFFER_BUILDER_H_ |
19 | | |
20 | | #include <algorithm> |
21 | | #include <cstdint> |
22 | | #include <functional> |
23 | | #include <initializer_list> |
24 | | #include <type_traits> |
25 | | |
26 | | #include "flatbuffers/allocator.h" |
27 | | #include "flatbuffers/array.h" |
28 | | #include "flatbuffers/base.h" |
29 | | #include "flatbuffers/buffer.h" |
30 | | #include "flatbuffers/buffer_ref.h" |
31 | | #include "flatbuffers/default_allocator.h" |
32 | | #include "flatbuffers/detached_buffer.h" |
33 | | #include "flatbuffers/stl_emulation.h" |
34 | | #include "flatbuffers/string.h" |
35 | | #include "flatbuffers/struct.h" |
36 | | #include "flatbuffers/table.h" |
37 | | #include "flatbuffers/vector.h" |
38 | | #include "flatbuffers/vector_downward.h" |
39 | | #include "flatbuffers/verifier.h" |
40 | | |
41 | | namespace flatbuffers { |
42 | | |
43 | | // Converts a Field ID to a virtual table offset. |
44 | 1.16M | inline voffset_t FieldIndexToOffset(voffset_t field_id) { |
45 | | // Should correspond to what EndTable() below builds up. |
46 | 1.16M | const voffset_t fixed_fields = |
47 | 1.16M | 2 * sizeof(voffset_t); // Vtable size and Object Size. |
48 | 1.16M | size_t offset = fixed_fields + field_id * sizeof(voffset_t); |
49 | 1.16M | FLATBUFFERS_ASSERT(offset < std::numeric_limits<voffset_t>::max()); |
50 | 1.16M | return static_cast<voffset_t>(offset); |
51 | 1.16M | } |
52 | | |
53 | | template <typename T, typename Alloc = std::allocator<T>> |
54 | 65.7k | const T* data(const std::vector<T, Alloc>& v) { |
55 | | // Eventually the returned pointer gets passed down to memcpy, so |
56 | | // we need it to be non-null to avoid undefined behavior. |
57 | 65.7k | static uint8_t t; |
58 | 65.7k | return v.empty() ? reinterpret_cast<const T*>(&t) : &v.front(); |
59 | 65.7k | } Unexecuted instantiation: MyGame::Example::Test const* flatbuffers::data<MyGame::Example::Test, std::__1::allocator<MyGame::Example::Test> >(std::__1::vector<MyGame::Example::Test, std::__1::allocator<MyGame::Example::Test> > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::String> const* flatbuffers::data<flatbuffers::Offset<flatbuffers::String>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String> > >(std::__1::vector<flatbuffers::Offset<flatbuffers::String>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String> > > const&) Unexecuted instantiation: long const* flatbuffers::data<long, std::__1::allocator<long> >(std::__1::vector<long, std::__1::allocator<long> > const&) Unexecuted instantiation: double const* flatbuffers::data<double, std::__1::allocator<double> >(std::__1::vector<double, std::__1::allocator<double> > const&) Unexecuted instantiation: unsigned long const* flatbuffers::data<unsigned long, std::__1::allocator<unsigned long> >(std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&) Unexecuted instantiation: MyGame::Example::Color const* flatbuffers::data<MyGame::Example::Color, std::__1::allocator<MyGame::Example::Color> >(std::__1::vector<MyGame::Example::Color, std::__1::allocator<MyGame::Example::Color> > const&) Unexecuted instantiation: signed char const* flatbuffers::data<signed char, std::__1::allocator<signed char> >(std::__1::vector<signed char, std::__1::allocator<signed char> > const&) Unexecuted instantiation: flatbuffers::Offset<MyGame::Example::Monster> const* flatbuffers::data<flatbuffers::Offset<MyGame::Example::Monster>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Monster>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > > const&) Unexecuted instantiation: MyGame::Example::Ability const* flatbuffers::data<MyGame::Example::Ability, std::__1::allocator<MyGame::Example::Ability> >(std::__1::vector<MyGame::Example::Ability, std::__1::allocator<MyGame::Example::Ability> > const&) Unexecuted instantiation: flatbuffers::Offset<MyGame::Example::Referrable> const* flatbuffers::data<flatbuffers::Offset<MyGame::Example::Referrable>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Referrable>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > > const&) Unexecuted instantiation: flatbuffers::Offset<MyGame::Example::Stat> const* flatbuffers::data<flatbuffers::Offset<MyGame::Example::Stat>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Stat>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > > const&) Unexecuted instantiation: LeafStruct const* flatbuffers::data<LeafStruct, std::__1::allocator<LeafStruct> >(std::__1::vector<LeafStruct, std::__1::allocator<LeafStruct> > const&) Unexecuted instantiation: flatbuffers::Offset<WrapperTable> const* flatbuffers::data<flatbuffers::Offset<WrapperTable>, std::__1::allocator<flatbuffers::Offset<WrapperTable> > >(std::__1::vector<flatbuffers::Offset<WrapperTable>, std::__1::allocator<flatbuffers::Offset<WrapperTable> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::String const*> const* flatbuffers::data<flatbuffers::Offset<flatbuffers::String const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String const*> > >(std::__1::vector<flatbuffers::Offset<flatbuffers::String const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String const*> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Table const*> const* flatbuffers::data<flatbuffers::Offset<flatbuffers::Table const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::Table const*> > >(std::__1::vector<flatbuffers::Offset<flatbuffers::Table const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::Table const*> > > const&) unsigned char const* flatbuffers::data<unsigned char, std::__1::allocator<unsigned char> >(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) Line | Count | Source | 54 | 14.8k | const T* data(const std::vector<T, Alloc>& v) { | 55 | | // Eventually the returned pointer gets passed down to memcpy, so | 56 | | // we need it to be non-null to avoid undefined behavior. | 57 | 14.8k | static uint8_t t; | 58 | 14.8k | return v.empty() ? reinterpret_cast<const T*>(&t) : &v.front(); | 59 | 14.8k | } |
flatbuffers::Offset<reflection::RPCCall> const* flatbuffers::data<flatbuffers::Offset<reflection::RPCCall>, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > >(std::__1::vector<flatbuffers::Offset<reflection::RPCCall>, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > > const&) Line | Count | Source | 54 | 810 | const T* data(const std::vector<T, Alloc>& v) { | 55 | | // Eventually the returned pointer gets passed down to memcpy, so | 56 | | // we need it to be non-null to avoid undefined behavior. | 57 | 810 | static uint8_t t; | 58 | 810 | return v.empty() ? reinterpret_cast<const T*>(&t) : &v.front(); | 59 | 810 | } |
flatbuffers::Offset<reflection::EnumVal> const* flatbuffers::data<flatbuffers::Offset<reflection::EnumVal>, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > >(std::__1::vector<flatbuffers::Offset<reflection::EnumVal>, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > > const&) Line | Count | Source | 54 | 50.0k | const T* data(const std::vector<T, Alloc>& v) { | 55 | | // Eventually the returned pointer gets passed down to memcpy, so | 56 | | // we need it to be non-null to avoid undefined behavior. | 57 | 50.0k | static uint8_t t; | 58 | 50.0k | return v.empty() ? reinterpret_cast<const T*>(&t) : &v.front(); | 59 | 50.0k | } |
|
60 | | template <typename T, typename Alloc = std::allocator<T>> |
61 | 40.8k | T* data(std::vector<T, Alloc>& v) { |
62 | | // Eventually the returned pointer gets passed down to memcpy, so |
63 | | // we need it to be non-null to avoid undefined behavior. |
64 | 40.8k | static uint8_t t; |
65 | 40.8k | return v.empty() ? reinterpret_cast<T*>(&t) : &v.front(); |
66 | 40.8k | } Unexecuted instantiation: flatbuffers::Offset<MyGame::Example::Monster>* flatbuffers::data<flatbuffers::Offset<MyGame::Example::Monster>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Monster>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > >&) Unexecuted instantiation: MyGame::Example::Ability* flatbuffers::data<MyGame::Example::Ability, std::__1::allocator<MyGame::Example::Ability> >(std::__1::vector<MyGame::Example::Ability, std::__1::allocator<MyGame::Example::Ability> >&) Unexecuted instantiation: flatbuffers::Offset<MyGame::Example::Referrable>* flatbuffers::data<flatbuffers::Offset<MyGame::Example::Referrable>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Referrable>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > >&) Unexecuted instantiation: flatbuffers::Offset<MyGame::Example::Stat>* flatbuffers::data<flatbuffers::Offset<MyGame::Example::Stat>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Stat>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > >&) Unexecuted instantiation: flatbuffers::Offset<reflection::EnumVal>* flatbuffers::data<flatbuffers::Offset<reflection::EnumVal>, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > >(std::__1::vector<flatbuffers::Offset<reflection::EnumVal>, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > >&) Unexecuted instantiation: flatbuffers::Offset<reflection::RPCCall>* flatbuffers::data<flatbuffers::Offset<reflection::RPCCall>, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > >(std::__1::vector<flatbuffers::Offset<reflection::RPCCall>, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > >&) Unexecuted instantiation: flatbuffers::Offset<reflection::SchemaFile>* flatbuffers::data<flatbuffers::Offset<reflection::SchemaFile>, std::__1::allocator<flatbuffers::Offset<reflection::SchemaFile> > >(std::__1::vector<flatbuffers::Offset<reflection::SchemaFile>, std::__1::allocator<flatbuffers::Offset<reflection::SchemaFile> > >&) flatbuffers::Offset<reflection::KeyValue>* flatbuffers::data<flatbuffers::Offset<reflection::KeyValue>, std::__1::allocator<flatbuffers::Offset<reflection::KeyValue> > >(std::__1::vector<flatbuffers::Offset<reflection::KeyValue>, std::__1::allocator<flatbuffers::Offset<reflection::KeyValue> > >&) Line | Count | Source | 61 | 183 | T* data(std::vector<T, Alloc>& v) { | 62 | | // Eventually the returned pointer gets passed down to memcpy, so | 63 | | // we need it to be non-null to avoid undefined behavior. | 64 | 183 | static uint8_t t; | 65 | 183 | return v.empty() ? reinterpret_cast<T*>(&t) : &v.front(); | 66 | 183 | } |
flatbuffers::Offset<reflection::Field>* flatbuffers::data<flatbuffers::Offset<reflection::Field>, std::__1::allocator<flatbuffers::Offset<reflection::Field> > >(std::__1::vector<flatbuffers::Offset<reflection::Field>, std::__1::allocator<flatbuffers::Offset<reflection::Field> > >&) Line | Count | Source | 61 | 29.3k | T* data(std::vector<T, Alloc>& v) { | 62 | | // Eventually the returned pointer gets passed down to memcpy, so | 63 | | // we need it to be non-null to avoid undefined behavior. | 64 | 29.3k | static uint8_t t; | 65 | 29.3k | return v.empty() ? reinterpret_cast<T*>(&t) : &v.front(); | 66 | 29.3k | } |
flatbuffers::Offset<reflection::Object>* flatbuffers::data<flatbuffers::Offset<reflection::Object>, std::__1::allocator<flatbuffers::Offset<reflection::Object> > >(std::__1::vector<flatbuffers::Offset<reflection::Object>, std::__1::allocator<flatbuffers::Offset<reflection::Object> > >&) Line | Count | Source | 61 | 3.78k | T* data(std::vector<T, Alloc>& v) { | 62 | | // Eventually the returned pointer gets passed down to memcpy, so | 63 | | // we need it to be non-null to avoid undefined behavior. | 64 | 3.78k | static uint8_t t; | 65 | 3.78k | return v.empty() ? reinterpret_cast<T*>(&t) : &v.front(); | 66 | 3.78k | } |
flatbuffers::Offset<reflection::Enum>* flatbuffers::data<flatbuffers::Offset<reflection::Enum>, std::__1::allocator<flatbuffers::Offset<reflection::Enum> > >(std::__1::vector<flatbuffers::Offset<reflection::Enum>, std::__1::allocator<flatbuffers::Offset<reflection::Enum> > >&) Line | Count | Source | 61 | 3.78k | T* data(std::vector<T, Alloc>& v) { | 62 | | // Eventually the returned pointer gets passed down to memcpy, so | 63 | | // we need it to be non-null to avoid undefined behavior. | 64 | 3.78k | static uint8_t t; | 65 | 3.78k | return v.empty() ? reinterpret_cast<T*>(&t) : &v.front(); | 66 | 3.78k | } |
flatbuffers::Offset<reflection::Service>* flatbuffers::data<flatbuffers::Offset<reflection::Service>, std::__1::allocator<flatbuffers::Offset<reflection::Service> > >(std::__1::vector<flatbuffers::Offset<reflection::Service>, std::__1::allocator<flatbuffers::Offset<reflection::Service> > >&) Line | Count | Source | 61 | 3.78k | T* data(std::vector<T, Alloc>& v) { | 62 | | // Eventually the returned pointer gets passed down to memcpy, so | 63 | | // we need it to be non-null to avoid undefined behavior. | 64 | 3.78k | static uint8_t t; | 65 | 3.78k | return v.empty() ? reinterpret_cast<T*>(&t) : &v.front(); | 66 | 3.78k | } |
Unexecuted instantiation: unsigned char* flatbuffers::data<unsigned char, std::__1::allocator<unsigned char> >(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&) |
67 | | |
68 | | /// @addtogroup flatbuffers_cpp_api |
69 | | /// @{ |
70 | | /// @class FlatBufferBuilder |
71 | | /// @brief Helper class to hold data needed in creation of a FlatBuffer. |
72 | | /// To serialize data, you typically call one of the `Create*()` functions in |
73 | | /// the generated code, which in turn call a sequence of `StartTable`/ |
74 | | /// `PushElement`/`AddElement`/`EndTable`, or the builtin `CreateString`/ |
75 | | /// `CreateVector` functions. Do this is depth-first order to build up a tree to |
76 | | /// the root. `Finish()` wraps up the buffer ready for transport. |
77 | | template <bool Is64Aware = false> |
78 | | class FlatBufferBuilderImpl { |
79 | | public: |
80 | | // This switches the size type of the builder, based on if its 64-bit aware |
81 | | // (uoffset64_t) or not (uoffset_t). |
82 | | typedef |
83 | | typename std::conditional<Is64Aware, uoffset64_t, uoffset_t>::type SizeT; |
84 | | |
85 | | /// @brief Default constructor for FlatBufferBuilder. |
86 | | /// @param[in] initial_size The initial size of the buffer, in bytes. Defaults |
87 | | /// to `1024`. |
88 | | /// @param[in] allocator An `Allocator` to use. If null will use |
89 | | /// `DefaultAllocator`. |
90 | | /// @param[in] own_allocator Whether the builder/vector should own the |
91 | | /// allocator. Defaults to / `false`. |
92 | | /// @param[in] buffer_minalign Force the buffer to be aligned to the given |
93 | | /// minimum alignment upon reallocation. Only needed if you intend to store |
94 | | /// types with custom alignment AND you wish to read the buffer in-place |
95 | | /// directly after creation. |
96 | | explicit FlatBufferBuilderImpl( |
97 | | size_t initial_size = 1024, Allocator* allocator = nullptr, |
98 | | bool own_allocator = false, |
99 | | size_t buffer_minalign = AlignOf<largest_scalar_t>()) |
100 | 142k | : buf_(initial_size, allocator, own_allocator, buffer_minalign, |
101 | 142k | static_cast<SizeT>(Is64Aware ? FLATBUFFERS_MAX_64_BUFFER_SIZE |
102 | 142k | : FLATBUFFERS_MAX_BUFFER_SIZE)), |
103 | 142k | num_field_loc(0), |
104 | 142k | max_voffset_(0), |
105 | 142k | length_of_64_bit_region_(0), |
106 | 142k | nested(false), |
107 | 142k | finished(false), |
108 | 142k | minalign_(1), |
109 | 142k | force_defaults_(false), |
110 | 142k | dedup_vtables_(true), |
111 | 142k | string_pool(nullptr) { |
112 | 142k | EndianCheck(); |
113 | 142k | } |
114 | | |
115 | | /// @brief Move constructor for FlatBufferBuilder. |
116 | | FlatBufferBuilderImpl(FlatBufferBuilderImpl&& other) noexcept |
117 | | : buf_(1024, nullptr, false, AlignOf<largest_scalar_t>(), |
118 | | static_cast<SizeT>(Is64Aware ? FLATBUFFERS_MAX_64_BUFFER_SIZE |
119 | | : FLATBUFFERS_MAX_BUFFER_SIZE)), |
120 | | num_field_loc(0), |
121 | | max_voffset_(0), |
122 | | length_of_64_bit_region_(0), |
123 | | nested(false), |
124 | | finished(false), |
125 | | minalign_(1), |
126 | | force_defaults_(false), |
127 | | dedup_vtables_(true), |
128 | | string_pool(nullptr) { |
129 | | EndianCheck(); |
130 | | // Default construct and swap idiom. |
131 | | // Lack of delegating constructors in vs2010 makes it more verbose than |
132 | | // needed. |
133 | | Swap(other); |
134 | | } |
135 | | |
136 | | /// @brief Move assignment operator for FlatBufferBuilder. |
137 | | FlatBufferBuilderImpl& operator=(FlatBufferBuilderImpl&& other) noexcept { |
138 | | // Move construct a temporary and swap idiom |
139 | | FlatBufferBuilderImpl temp(std::move(other)); |
140 | | Swap(temp); |
141 | | return *this; |
142 | | } |
143 | | |
144 | 0 | void Swap(FlatBufferBuilderImpl& other) { |
145 | 0 | using std::swap; |
146 | 0 | buf_.swap(other.buf_); |
147 | 0 | swap(num_field_loc, other.num_field_loc); |
148 | 0 | swap(max_voffset_, other.max_voffset_); |
149 | 0 | swap(length_of_64_bit_region_, other.length_of_64_bit_region_); |
150 | 0 | swap(nested, other.nested); |
151 | 0 | swap(finished, other.finished); |
152 | 0 | swap(minalign_, other.minalign_); |
153 | 0 | swap(force_defaults_, other.force_defaults_); |
154 | 0 | swap(dedup_vtables_, other.dedup_vtables_); |
155 | 0 | swap(string_pool, other.string_pool); |
156 | 0 | } |
157 | | |
158 | 142k | ~FlatBufferBuilderImpl() { |
159 | 142k | if (string_pool) delete string_pool; |
160 | 142k | } |
161 | | |
162 | | void Reset() { |
163 | | Clear(); // clear builder state |
164 | | buf_.reset(); // deallocate buffer |
165 | | } |
166 | | |
167 | | /// @brief Reset all the state in this FlatBufferBuilder so it can be reused |
168 | | /// to construct another buffer. |
169 | 789k | void Clear() { |
170 | 789k | ClearOffsets(); |
171 | 789k | buf_.clear(); |
172 | 789k | nested = false; |
173 | 789k | finished = false; |
174 | 789k | minalign_ = 1; |
175 | 789k | length_of_64_bit_region_ = 0; |
176 | 789k | if (string_pool) string_pool->clear(); |
177 | 789k | } |
178 | | |
179 | | /// @brief The current size of the serialized buffer, counting from the end. |
180 | | /// @return Returns an `SizeT` with the current size of the buffer. |
181 | 12.1M | SizeT GetSize() const { return buf_.size(); }Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::GetSize() const flatbuffers::FlatBufferBuilderImpl<false>::GetSize() const Line | Count | Source | 181 | 12.1M | SizeT GetSize() const { return buf_.size(); } |
|
182 | | |
183 | | /// @brief The current size of the serialized buffer relative to the end of |
184 | | /// the 32-bit region. |
185 | | /// @return Returns an `uoffset_t` with the current size of the buffer. |
186 | | template <bool is_64 = Is64Aware> |
187 | | // Only enable this method for the 64-bit builder, as only that builder is |
188 | | // concerned with the 32/64-bit boundary, and should be the one to bare any |
189 | | // run time costs. |
190 | | typename std::enable_if<is_64, uoffset_t>::type GetSizeRelative32BitRegion() |
191 | 0 | const { |
192 | 0 | //[32-bit region][64-bit region] |
193 | 0 | // [XXXXXXXXXXXXXXXXXXX] GetSize() |
194 | 0 | // [YYYYYYYYYYYYY] length_of_64_bit_region_ |
195 | 0 | // [ZZZZ] return size |
196 | 0 | return static_cast<uoffset_t>(GetSize() - length_of_64_bit_region_); |
197 | 0 | } |
198 | | |
199 | | template <bool is_64 = Is64Aware> |
200 | | // Only enable this method for the 32-bit builder. |
201 | | typename std::enable_if<!is_64, uoffset_t>::type GetSizeRelative32BitRegion() |
202 | 10.3M | const { |
203 | 10.3M | return static_cast<uoffset_t>(GetSize()); |
204 | 10.3M | } |
205 | | |
206 | | /// @brief Get the serialized buffer (after you call `Finish()`). |
207 | | /// @return Returns an `uint8_t` pointer to the FlatBuffer data inside the |
208 | | /// buffer. |
209 | 404k | uint8_t* GetBufferPointer() const { |
210 | 404k | Finished(); |
211 | 404k | return buf_.data(); |
212 | 404k | } |
213 | | |
214 | | /// @brief Get the serialized buffer (after you call `Finish()`) as a span. |
215 | | /// @return Returns a constructed flatbuffers::span that is a view over the |
216 | | /// FlatBuffer data inside the buffer. |
217 | | flatbuffers::span<uint8_t> GetBufferSpan() const { |
218 | | Finished(); |
219 | | return flatbuffers::span<uint8_t>(buf_.data(), buf_.size()); |
220 | | } |
221 | | |
222 | | /// @brief Get a pointer to an unfinished buffer. |
223 | | /// @return Returns a `uint8_t` pointer to the unfinished buffer. |
224 | 74.4k | uint8_t* GetCurrentBufferPointer() const { return buf_.data(); } |
225 | | |
226 | | /// @brief Get the released DetachedBuffer. |
227 | | /// @return A `DetachedBuffer` that owns the buffer and its allocator. |
228 | | DetachedBuffer Release() { |
229 | | Finished(); |
230 | | DetachedBuffer buffer = buf_.release(); |
231 | | Clear(); |
232 | | return buffer; |
233 | | } |
234 | | |
235 | | /// @brief Get the released pointer to the serialized buffer. |
236 | | /// @param size The size of the memory block containing |
237 | | /// the serialized `FlatBuffer`. |
238 | | /// @param offset The offset from the released pointer where the finished |
239 | | /// `FlatBuffer` starts. |
240 | | /// @return A raw pointer to the start of the memory block containing |
241 | | /// the serialized `FlatBuffer`. |
242 | | /// @remark If the allocator is owned, it gets deleted when the destructor is |
243 | | /// called. |
244 | | uint8_t* ReleaseRaw(size_t& size, size_t& offset) { |
245 | | Finished(); |
246 | | uint8_t* raw = buf_.release_raw(size, offset); |
247 | | Clear(); |
248 | | return raw; |
249 | | } |
250 | | |
251 | | /// @brief get the minimum alignment this buffer needs to be accessed |
252 | | /// properly. This is only known once all elements have been written (after |
253 | | /// you call Finish()). You can use this information if you need to embed |
254 | | /// a FlatBuffer in some other buffer, such that you can later read it |
255 | | /// without first having to copy it into its own buffer. |
256 | 10.3k | size_t GetBufferMinAlignment() const { |
257 | 10.3k | Finished(); |
258 | 10.3k | return minalign_; |
259 | 10.3k | } |
260 | | |
261 | | /// @cond FLATBUFFERS_INTERNAL |
262 | 414k | void Finished() const { |
263 | | // If you get this assert, you're attempting to get access a buffer |
264 | | // which hasn't been finished yet. Be sure to call |
265 | | // FlatBufferBuilder::Finish with your root table. |
266 | | // If you really need to access an unfinished buffer, call |
267 | | // GetCurrentBufferPointer instead. |
268 | 414k | FLATBUFFERS_ASSERT(finished); |
269 | 414k | } |
270 | | /// @endcond |
271 | | |
272 | | /// @brief In order to save space, fields that are set to their default value |
273 | | /// don't get serialized into the buffer. |
274 | | /// @param[in] fd When set to `true`, always serializes default values that |
275 | | /// are set. Optional fields which are not set explicitly, will still not be |
276 | | /// serialized. |
277 | 100k | void ForceDefaults(bool fd) { force_defaults_ = fd; } |
278 | | |
279 | | /// @brief By default vtables are deduped in order to save space. |
280 | | /// @param[in] dedup When set to `true`, dedup vtables. |
281 | | void DedupVtables(bool dedup) { dedup_vtables_ = dedup; } |
282 | | |
283 | | /// @cond FLATBUFFERS_INTERNAL |
284 | 880k | void Pad(size_t num_bytes) { buf_.fill(num_bytes); } |
285 | | |
286 | 7.34M | void TrackMinAlign(size_t elem_size) { |
287 | 7.34M | if (elem_size > minalign_) minalign_ = elem_size; |
288 | 7.34M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::TrackMinAlign(unsigned long) flatbuffers::FlatBufferBuilderImpl<false>::TrackMinAlign(unsigned long) Line | Count | Source | 286 | 7.34M | void TrackMinAlign(size_t elem_size) { | 287 | 7.34M | if (elem_size > minalign_) minalign_ = elem_size; | 288 | 7.34M | } |
|
289 | | |
290 | 6.06M | void Align(size_t elem_size) { |
291 | 6.06M | TrackMinAlign(elem_size); |
292 | 6.06M | buf_.fill(PaddingBytes(buf_.size(), elem_size)); |
293 | 6.06M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::Align(unsigned long) flatbuffers::FlatBufferBuilderImpl<false>::Align(unsigned long) Line | Count | Source | 290 | 6.06M | void Align(size_t elem_size) { | 291 | 6.06M | TrackMinAlign(elem_size); | 292 | 6.06M | buf_.fill(PaddingBytes(buf_.size(), elem_size)); | 293 | 6.06M | } |
|
294 | | |
295 | 0 | void PushFlatBuffer(const uint8_t* bytes, size_t size) { |
296 | 0 | PushBytes(bytes, size); |
297 | 0 | finished = true; |
298 | 0 | } |
299 | | |
300 | 472k | void PushBytes(const uint8_t* bytes, size_t size) { buf_.push(bytes, size); }Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::PushBytes(unsigned char const*, unsigned long) flatbuffers::FlatBufferBuilderImpl<false>::PushBytes(unsigned char const*, unsigned long) Line | Count | Source | 300 | 472k | void PushBytes(const uint8_t* bytes, size_t size) { buf_.push(bytes, size); } |
|
301 | | |
302 | 61.5k | void PopBytes(size_t amount) { buf_.pop(amount); } |
303 | | |
304 | | template <typename T> |
305 | 5.05M | void AssertScalarT() { |
306 | | // The code assumes power of 2 sizes and endian-swap-ability. |
307 | 5.05M | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); |
308 | 5.05M | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AssertScalarT<unsigned int>() Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AssertScalarT<unsigned long>() Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<MyGame::Example::Color>() Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AssertScalarT<int>() Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AssertScalarT<signed char>() Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AssertScalarT<unsigned char>() void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<int>() Line | Count | Source | 305 | 1.13M | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 1.13M | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 1.13M | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<unsigned int>() Line | Count | Source | 305 | 2.94M | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 2.94M | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 2.94M | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<unsigned char>() Line | Count | Source | 305 | 249k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 249k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 249k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<long>() Line | Count | Source | 305 | 222k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 222k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 222k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<unsigned short>() Line | Count | Source | 305 | 55.5k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 55.5k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 55.5k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<unsigned long>() Line | Count | Source | 305 | 158k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 158k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 158k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<short>() Line | Count | Source | 305 | 31.5k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 31.5k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 31.5k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<float>() Line | Count | Source | 305 | 43.6k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 43.6k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 43.6k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<signed char>() Line | Count | Source | 305 | 113k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 113k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 113k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AssertScalarT<double>() Line | Count | Source | 305 | 90.0k | void AssertScalarT() { | 306 | | // The code assumes power of 2 sizes and endian-swap-ability. | 307 | 90.0k | static_assert(flatbuffers::is_scalar<T>::value, "T must be a scalar type"); | 308 | 90.0k | } |
|
309 | | |
310 | | // Write a single aligned scalar to the buffer |
311 | | template <typename T, typename ReturnT = uoffset_t> |
312 | 4.46M | ReturnT PushElement(T element) { |
313 | 4.46M | AssertScalarT<T>(); |
314 | 4.46M | Align(sizeof(T)); |
315 | 4.46M | buf_.push_small(EndianScalar(element)); |
316 | 4.46M | return CalculateOffset<ReturnT>(); |
317 | 4.46M | } Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<true>::PushElement<unsigned int, unsigned int>(unsigned int) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<true>::PushElement<unsigned long, unsigned int>(unsigned long) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<true>::PushElement<int, unsigned int>(int) Unexecuted instantiation: unsigned long flatbuffers::FlatBufferBuilderImpl<true>::PushElement<unsigned int, unsigned long>(unsigned int) Unexecuted instantiation: unsigned long flatbuffers::FlatBufferBuilderImpl<true>::PushElement<unsigned long, unsigned long>(unsigned long) unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<int, unsigned int>(int) Line | Count | Source | 312 | 1.13M | ReturnT PushElement(T element) { | 313 | 1.13M | AssertScalarT<T>(); | 314 | 1.13M | Align(sizeof(T)); | 315 | 1.13M | buf_.push_small(EndianScalar(element)); | 316 | 1.13M | return CalculateOffset<ReturnT>(); | 317 | 1.13M | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<unsigned int, unsigned int>(unsigned int) Line | Count | Source | 312 | 2.39M | ReturnT PushElement(T element) { | 313 | 2.39M | AssertScalarT<T>(); | 314 | 2.39M | Align(sizeof(T)); | 315 | 2.39M | buf_.push_small(EndianScalar(element)); | 316 | 2.39M | return CalculateOffset<ReturnT>(); | 317 | 2.39M | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<unsigned char, unsigned int>(unsigned char) Line | Count | Source | 312 | 223k | ReturnT PushElement(T element) { | 313 | 223k | AssertScalarT<T>(); | 314 | 223k | Align(sizeof(T)); | 315 | 223k | buf_.push_small(EndianScalar(element)); | 316 | 223k | return CalculateOffset<ReturnT>(); | 317 | 223k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<long, unsigned int>(long) Line | Count | Source | 312 | 222k | ReturnT PushElement(T element) { | 313 | 222k | AssertScalarT<T>(); | 314 | 222k | Align(sizeof(T)); | 315 | 222k | buf_.push_small(EndianScalar(element)); | 316 | 222k | return CalculateOffset<ReturnT>(); | 317 | 222k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<unsigned short, unsigned int>(unsigned short) Line | Count | Source | 312 | 55.5k | ReturnT PushElement(T element) { | 313 | 55.5k | AssertScalarT<T>(); | 314 | 55.5k | Align(sizeof(T)); | 315 | 55.5k | buf_.push_small(EndianScalar(element)); | 316 | 55.5k | return CalculateOffset<ReturnT>(); | 317 | 55.5k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<unsigned long, unsigned int>(unsigned long) Line | Count | Source | 312 | 158k | ReturnT PushElement(T element) { | 313 | 158k | AssertScalarT<T>(); | 314 | 158k | Align(sizeof(T)); | 315 | 158k | buf_.push_small(EndianScalar(element)); | 316 | 158k | return CalculateOffset<ReturnT>(); | 317 | 158k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<short, unsigned int>(short) Line | Count | Source | 312 | 31.5k | ReturnT PushElement(T element) { | 313 | 31.5k | AssertScalarT<T>(); | 314 | 31.5k | Align(sizeof(T)); | 315 | 31.5k | buf_.push_small(EndianScalar(element)); | 316 | 31.5k | return CalculateOffset<ReturnT>(); | 317 | 31.5k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<float, unsigned int>(float) Line | Count | Source | 312 | 43.6k | ReturnT PushElement(T element) { | 313 | 43.6k | AssertScalarT<T>(); | 314 | 43.6k | Align(sizeof(T)); | 315 | 43.6k | buf_.push_small(EndianScalar(element)); | 316 | 43.6k | return CalculateOffset<ReturnT>(); | 317 | 43.6k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<signed char, unsigned int>(signed char) Line | Count | Source | 312 | 113k | ReturnT PushElement(T element) { | 313 | 113k | AssertScalarT<T>(); | 314 | 113k | Align(sizeof(T)); | 315 | 113k | buf_.push_small(EndianScalar(element)); | 316 | 113k | return CalculateOffset<ReturnT>(); | 317 | 113k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<double, unsigned int>(double) Line | Count | Source | 312 | 90.0k | ReturnT PushElement(T element) { | 313 | 90.0k | AssertScalarT<T>(); | 314 | 90.0k | Align(sizeof(T)); | 315 | 90.0k | buf_.push_small(EndianScalar(element)); | 316 | 90.0k | return CalculateOffset<ReturnT>(); | 317 | 90.0k | } |
|
318 | | |
319 | | template <typename T, template <typename> class OffsetT = Offset> |
320 | 489k | uoffset_t PushElement(OffsetT<T> off) { |
321 | | // Special case for offsets: see ReferTo below. |
322 | 489k | return PushElement(ReferTo(off.o)); |
323 | 489k | } Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<flatbuffers::String, flatbuffers::Offset>(flatbuffers::Offset<flatbuffers::String>) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<MyGame::Example::Monster, flatbuffers::Offset>(flatbuffers::Offset<MyGame::Example::Monster>) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<MyGame::Example::Referrable, flatbuffers::Offset>(flatbuffers::Offset<MyGame::Example::Referrable>) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<MyGame::Example::Stat, flatbuffers::Offset>(flatbuffers::Offset<MyGame::Example::Stat>) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<true>::PushElement<WrapperTable, flatbuffers::Offset>(flatbuffers::Offset<WrapperTable>) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::SchemaFile, flatbuffers::Offset>(flatbuffers::Offset<reflection::SchemaFile>) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<flatbuffers::String const*, flatbuffers::Offset>(flatbuffers::Offset<flatbuffers::String const*>) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<flatbuffers::Table const*, flatbuffers::Offset>(flatbuffers::Offset<flatbuffers::Table const*>) unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::KeyValue, flatbuffers::Offset>(flatbuffers::Offset<reflection::KeyValue>) Line | Count | Source | 320 | 183 | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 183 | return PushElement(ReferTo(off.o)); | 323 | 183 | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::EnumVal, flatbuffers::Offset>(flatbuffers::Offset<reflection::EnumVal>) Line | Count | Source | 320 | 84.1k | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 84.1k | return PushElement(ReferTo(off.o)); | 323 | 84.1k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::Field, flatbuffers::Offset>(flatbuffers::Offset<reflection::Field>) Line | Count | Source | 320 | 22.5k | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 22.5k | return PushElement(ReferTo(off.o)); | 323 | 22.5k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::RPCCall, flatbuffers::Offset>(flatbuffers::Offset<reflection::RPCCall>) Line | Count | Source | 320 | 1.22k | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 1.22k | return PushElement(ReferTo(off.o)); | 323 | 1.22k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::Object, flatbuffers::Offset>(flatbuffers::Offset<reflection::Object>) Line | Count | Source | 320 | 29.3k | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 29.3k | return PushElement(ReferTo(off.o)); | 323 | 29.3k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::Enum, flatbuffers::Offset>(flatbuffers::Offset<reflection::Enum>) Line | Count | Source | 320 | 50.0k | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 50.0k | return PushElement(ReferTo(off.o)); | 323 | 50.0k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<reflection::Service, flatbuffers::Offset>(flatbuffers::Offset<reflection::Service>) Line | Count | Source | 320 | 810 | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 810 | return PushElement(ReferTo(off.o)); | 323 | 810 | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<void, flatbuffers::Offset>(flatbuffers::Offset<void>) Line | Count | Source | 320 | 301k | uoffset_t PushElement(OffsetT<T> off) { | 321 | | // Special case for offsets: see ReferTo below. | 322 | 301k | return PushElement(ReferTo(off.o)); | 323 | 301k | } |
Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<false>::PushElement<void, flatbuffers::Offset64>(flatbuffers::Offset64<void>) |
324 | | |
325 | | // When writing fields, we track where they are, so we can create correct |
326 | | // vtables later. |
327 | 1.68M | void TrackField(voffset_t field, uoffset_t off) { |
328 | 1.68M | FieldLoc fl = {off, field}; |
329 | 1.68M | buf_.scratch_push_small(fl); |
330 | 1.68M | num_field_loc++; |
331 | 1.68M | if (field > max_voffset_) { |
332 | 824k | max_voffset_ = field; |
333 | 824k | } |
334 | 1.68M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::TrackField(unsigned short, unsigned int) flatbuffers::FlatBufferBuilderImpl<false>::TrackField(unsigned short, unsigned int) Line | Count | Source | 327 | 1.68M | void TrackField(voffset_t field, uoffset_t off) { | 328 | 1.68M | FieldLoc fl = {off, field}; | 329 | 1.68M | buf_.scratch_push_small(fl); | 330 | 1.68M | num_field_loc++; | 331 | 1.68M | if (field > max_voffset_) { | 332 | 824k | max_voffset_ = field; | 333 | 824k | } | 334 | 1.68M | } |
|
335 | | |
336 | | // Like PushElement, but additionally tracks the field this represents. |
337 | | template <typename T> |
338 | 2.43M | void AddElement(voffset_t field, T e, T def) { |
339 | | // We don't serialize values equal to the default. |
340 | 2.43M | if (IsTheSameAs(e, def) && !force_defaults_) return; |
341 | 1.60M | TrackField(field, PushElement(e)); |
342 | 1.60M | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddElement<unsigned long>(unsigned short, unsigned long, unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddElement<int>(unsigned short, int, int) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddElement<unsigned int>(unsigned short, unsigned int, unsigned int) void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned int>(unsigned short, unsigned int, unsigned int) Line | Count | Source | 338 | 1.01M | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 1.01M | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 994k | TrackField(field, PushElement(e)); | 342 | 994k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned char>(unsigned short, unsigned char, unsigned char) Line | Count | Source | 338 | 224k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 224k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 93.4k | TrackField(field, PushElement(e)); | 342 | 93.4k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<long>(unsigned short, long, long) Line | Count | Source | 338 | 141k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 141k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 66.5k | TrackField(field, PushElement(e)); | 342 | 66.5k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned short>(unsigned short, unsigned short, unsigned short) Line | Count | Source | 338 | 273k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 273k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 53.0k | TrackField(field, PushElement(e)); | 342 | 53.0k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned long>(unsigned short, unsigned long, unsigned long) Line | Count | Source | 338 | 110k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 110k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 100k | TrackField(field, PushElement(e)); | 342 | 100k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<short>(unsigned short, short, short) Line | Count | Source | 338 | 21.3k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 21.3k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 20.6k | TrackField(field, PushElement(e)); | 342 | 20.6k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<int>(unsigned short, int, int) Line | Count | Source | 338 | 241k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 241k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 125k | TrackField(field, PushElement(e)); | 342 | 125k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<float>(unsigned short, float, float) Line | Count | Source | 338 | 30.2k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 30.2k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 28.0k | TrackField(field, PushElement(e)); | 342 | 28.0k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<signed char>(unsigned short, signed char, signed char) Line | Count | Source | 338 | 331k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 331k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 91.4k | TrackField(field, PushElement(e)); | 342 | 91.4k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<double>(unsigned short, double, double) Line | Count | Source | 338 | 50.7k | void AddElement(voffset_t field, T e, T def) { | 339 | | // We don't serialize values equal to the default. | 340 | 50.7k | if (IsTheSameAs(e, def) && !force_defaults_) return; | 341 | 27.4k | TrackField(field, PushElement(e)); | 342 | 27.4k | } |
|
343 | | |
344 | | template <typename T> |
345 | 29.8k | void AddElement(voffset_t field, T e) { |
346 | 29.8k | TrackField(field, PushElement(e)); |
347 | 29.8k | } void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned char>(unsigned short, unsigned char) Line | Count | Source | 345 | 3.22k | void AddElement(voffset_t field, T e) { | 346 | 3.22k | TrackField(field, PushElement(e)); | 347 | 3.22k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<signed char>(unsigned short, signed char) Line | Count | Source | 345 | 6.60k | void AddElement(voffset_t field, T e) { | 346 | 6.60k | TrackField(field, PushElement(e)); | 347 | 6.60k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<short>(unsigned short, short) Line | Count | Source | 345 | 1.24k | void AddElement(voffset_t field, T e) { | 346 | 1.24k | TrackField(field, PushElement(e)); | 347 | 1.24k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned short>(unsigned short, unsigned short) Line | Count | Source | 345 | 1.03k | void AddElement(voffset_t field, T e) { | 346 | 1.03k | TrackField(field, PushElement(e)); | 347 | 1.03k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<int>(unsigned short, int) Line | Count | Source | 345 | 1.05k | void AddElement(voffset_t field, T e) { | 346 | 1.05k | TrackField(field, PushElement(e)); | 347 | 1.05k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned int>(unsigned short, unsigned int) Line | Count | Source | 345 | 1.22k | void AddElement(voffset_t field, T e) { | 346 | 1.22k | TrackField(field, PushElement(e)); | 347 | 1.22k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<long>(unsigned short, long) Line | Count | Source | 345 | 3.88k | void AddElement(voffset_t field, T e) { | 346 | 3.88k | TrackField(field, PushElement(e)); | 347 | 3.88k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<unsigned long>(unsigned short, unsigned long) Line | Count | Source | 345 | 4.61k | void AddElement(voffset_t field, T e) { | 346 | 4.61k | TrackField(field, PushElement(e)); | 347 | 4.61k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<float>(unsigned short, float) Line | Count | Source | 345 | 1.12k | void AddElement(voffset_t field, T e) { | 346 | 1.12k | TrackField(field, PushElement(e)); | 347 | 1.12k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddElement<double>(unsigned short, double) Line | Count | Source | 345 | 5.87k | void AddElement(voffset_t field, T e) { | 346 | 5.87k | TrackField(field, PushElement(e)); | 347 | 5.87k | } |
|
348 | | |
349 | | template <typename T> |
350 | 1.06M | void AddOffset(voffset_t field, Offset<T> off) { |
351 | 1.06M | if (off.IsNull()) return; // Don't store. |
352 | 677k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); |
353 | 677k | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<unsigned char, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<unsigned char, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<MyGame::Example::Test const*, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<MyGame::Example::Test const*, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<MyGame::Example::Monster>(unsigned short, flatbuffers::Offset<MyGame::Example::Monster>) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<MyGame::Example::Stat>(unsigned short, flatbuffers::Offset<MyGame::Example::Stat>) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<MyGame::Example::Ability const*, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<MyGame::Example::Ability const*, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<long, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<long, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<double, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<double, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<MyGame::InParentNamespace>(unsigned short, flatbuffers::Offset<MyGame::InParentNamespace>) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<unsigned long, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<unsigned long, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<MyGame::Example::Color, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<MyGame::Example::Color, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<signed char, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<signed char, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::String>(unsigned short, flatbuffers::Offset<flatbuffers::String>) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<WrapperTable>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<WrapperTable>, unsigned int> >) void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<void>(unsigned short, flatbuffers::Offset<void>) Line | Count | Source | 350 | 149k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 149k | if (off.IsNull()) return; // Don't store. | 352 | 149k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 149k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::String>(unsigned short, flatbuffers::Offset<flatbuffers::String>) Line | Count | Source | 350 | 276k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 276k | if (off.IsNull()) return; // Don't store. | 352 | 276k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 276k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>, unsigned int> >) Line | Count | Source | 350 | 188k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 188k | if (off.IsNull()) return; // Don't store. | 352 | 0 | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 0 | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<reflection::Type>(unsigned short, flatbuffers::Offset<reflection::Type>) Line | Count | Source | 350 | 156k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 156k | if (off.IsNull()) return; // Don't store. | 352 | 156k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 156k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>, unsigned int> >) Line | Count | Source | 350 | 188k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 188k | if (off.IsNull()) return; // Don't store. | 352 | 183 | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 183 | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>, unsigned int> >) Line | Count | Source | 350 | 50.0k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 50.0k | if (off.IsNull()) return; // Don't store. | 352 | 50.0k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 50.0k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::Field>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Field>, unsigned int> >) Line | Count | Source | 350 | 29.3k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 29.3k | if (off.IsNull()) return; // Don't store. | 352 | 29.3k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 29.3k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<reflection::Object>(unsigned short, flatbuffers::Offset<reflection::Object>) Line | Count | Source | 350 | 6.24k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 6.24k | if (off.IsNull()) return; // Don't store. | 352 | 2.62k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 2.62k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>, unsigned int> >) Line | Count | Source | 350 | 810 | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 810 | if (off.IsNull()) return; // Don't store. | 352 | 810 | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 810 | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::Object>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Object>, unsigned int> >) Line | Count | Source | 350 | 3.78k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 3.78k | if (off.IsNull()) return; // Don't store. | 352 | 3.78k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 3.78k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>, unsigned int> >) Line | Count | Source | 350 | 3.78k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 3.78k | if (off.IsNull()) return; // Don't store. | 352 | 3.78k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 3.78k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::Service>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Service>, unsigned int> >) Line | Count | Source | 350 | 3.78k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 3.78k | if (off.IsNull()) return; // Don't store. | 352 | 3.78k | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 3.78k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<flatbuffers::Vector<flatbuffers::Offset<reflection::SchemaFile>, unsigned int> >(unsigned short, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::SchemaFile>, unsigned int> >) Line | Count | Source | 350 | 3.78k | void AddOffset(voffset_t field, Offset<T> off) { | 351 | 3.78k | if (off.IsNull()) return; // Don't store. | 352 | 0 | AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); | 353 | 0 | } |
|
354 | | |
355 | | template <typename T> |
356 | 17.6k | void AddOffset(voffset_t field, Offset64<T> off) { |
357 | 17.6k | if (off.IsNull()) return; // Don't store. |
358 | 17.6k | AddElement(field, ReferTo(off.o), static_cast<uoffset64_t>(0)); |
359 | 17.6k | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::Vector<signed char, unsigned int> >(unsigned short, flatbuffers::Offset64<flatbuffers::Vector<signed char, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::Vector<unsigned char, unsigned int> >(unsigned short, flatbuffers::Offset64<flatbuffers::Vector<unsigned char, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::String>(unsigned short, flatbuffers::Offset64<flatbuffers::String>) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::Vector<unsigned char, unsigned long> >(unsigned short, flatbuffers::Offset64<flatbuffers::Vector<unsigned char, unsigned long> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::Vector<LeafStruct const*, unsigned int> >(unsigned short, flatbuffers::Offset64<flatbuffers::Vector<LeafStruct const*, unsigned int> >) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::AddOffset<flatbuffers::Vector<LeafStruct const*, unsigned long> >(unsigned short, flatbuffers::Offset64<flatbuffers::Vector<LeafStruct const*, unsigned long> >) void flatbuffers::FlatBufferBuilderImpl<false>::AddOffset<void>(unsigned short, flatbuffers::Offset64<void>) Line | Count | Source | 356 | 17.6k | void AddOffset(voffset_t field, Offset64<T> off) { | 357 | 17.6k | if (off.IsNull()) return; // Don't store. | 358 | 17.6k | AddElement(field, ReferTo(off.o), static_cast<uoffset64_t>(0)); | 359 | 17.6k | } |
|
360 | | |
361 | | template <typename T> |
362 | 0 | void AddStruct(voffset_t field, const T* structptr) { |
363 | 0 | if (!structptr) return; // Default, don't store. |
364 | 0 | Align(AlignOf<T>()); |
365 | 0 | buf_.push_small(*structptr); |
366 | 0 | TrackField(field, CalculateOffset<uoffset_t>()); |
367 | 0 | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddStruct<MyGame::Example::Vec3>(unsigned short, MyGame::Example::Vec3 const*) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::AddStruct<MyGame::Example::Test>(unsigned short, MyGame::Example::Test const*) |
368 | | |
369 | 48.7k | void AddStructOffset(voffset_t field, uoffset_t off) { |
370 | 48.7k | TrackField(field, off); |
371 | 48.7k | } |
372 | | |
373 | | // Offsets initially are relative to the end of the buffer (downwards). |
374 | | // This function converts them to be relative to the current location |
375 | | // in the buffer (when stored here), pointing upwards. |
376 | 1.47M | uoffset_t ReferTo(uoffset_t off) { |
377 | | // Align to ensure GetSizeRelative32BitRegion() below is correct. |
378 | 1.47M | Align(sizeof(uoffset_t)); |
379 | | // 32-bit offsets are relative to the tail of the 32-bit region of the |
380 | | // buffer. For most cases (without 64-bit entities) this is equivalent to |
381 | | // size of the whole buffer (e.g. GetSize()) |
382 | 1.47M | return ReferTo(off, GetSizeRelative32BitRegion()); |
383 | 1.47M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::ReferTo(unsigned int) flatbuffers::FlatBufferBuilderImpl<false>::ReferTo(unsigned int) Line | Count | Source | 376 | 1.47M | uoffset_t ReferTo(uoffset_t off) { | 377 | | // Align to ensure GetSizeRelative32BitRegion() below is correct. | 378 | 1.47M | Align(sizeof(uoffset_t)); | 379 | | // 32-bit offsets are relative to the tail of the 32-bit region of the | 380 | | // buffer. For most cases (without 64-bit entities) this is equivalent to | 381 | | // size of the whole buffer (e.g. GetSize()) | 382 | 1.47M | return ReferTo(off, GetSizeRelative32BitRegion()); | 383 | 1.47M | } |
|
384 | | |
385 | 17.6k | uoffset64_t ReferTo(uoffset64_t off) { |
386 | | // Align to ensure GetSize() below is correct. |
387 | 17.6k | Align(sizeof(uoffset64_t)); |
388 | | // 64-bit offsets are relative to tail of the whole buffer |
389 | 17.6k | return ReferTo(off, GetSize()); |
390 | 17.6k | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::ReferTo(unsigned long) flatbuffers::FlatBufferBuilderImpl<false>::ReferTo(unsigned long) Line | Count | Source | 385 | 17.6k | uoffset64_t ReferTo(uoffset64_t off) { | 386 | | // Align to ensure GetSize() below is correct. | 387 | 17.6k | Align(sizeof(uoffset64_t)); | 388 | | // 64-bit offsets are relative to tail of the whole buffer | 389 | 17.6k | return ReferTo(off, GetSize()); | 390 | 17.6k | } |
|
391 | | |
392 | | template <typename T, typename T2> |
393 | 17.6k | T ReferTo(const T off, const T2 size) { |
394 | 17.6k | FLATBUFFERS_ASSERT(off && off <= size); |
395 | 17.6k | return size - off + static_cast<T>(sizeof(T)); |
396 | 17.6k | } |
397 | | |
398 | | template <typename T> |
399 | 1.47M | T ReferTo(const T off, const T size) { |
400 | 1.47M | FLATBUFFERS_ASSERT(off && off <= size); |
401 | 1.47M | return size - off + static_cast<T>(sizeof(T)); |
402 | 1.47M | } Unexecuted instantiation: unsigned long flatbuffers::FlatBufferBuilderImpl<true>::ReferTo<unsigned long>(unsigned long, unsigned long) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<true>::ReferTo<unsigned int>(unsigned int, unsigned int) unsigned int flatbuffers::FlatBufferBuilderImpl<false>::ReferTo<unsigned int>(unsigned int, unsigned int) Line | Count | Source | 399 | 1.47M | T ReferTo(const T off, const T size) { | 400 | 1.47M | FLATBUFFERS_ASSERT(off && off <= size); | 401 | 1.47M | return size - off + static_cast<T>(sizeof(T)); | 402 | 1.47M | } |
|
403 | | |
404 | 2.07M | void NotNested() { |
405 | | // If you hit this, you're trying to construct a Table/Vector/String |
406 | | // during the construction of its parent table (between the MyTableBuilder |
407 | | // and table.Finish(). |
408 | | // Move the creation of these sub-objects to above the MyTableBuilder to |
409 | | // not get this assert. |
410 | | // Ignoring this assert may appear to work in simple cases, but the reason |
411 | | // it is here is that storing objects in-line may cause vtable offsets |
412 | | // to not fit anymore. It also leads to vtable duplication. |
413 | 2.07M | FLATBUFFERS_ASSERT(!nested); |
414 | | // If you hit this, fields were added outside the scope of a table. |
415 | 2.07M | FLATBUFFERS_ASSERT(!num_field_loc); |
416 | 2.07M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::NotNested() flatbuffers::FlatBufferBuilderImpl<false>::NotNested() Line | Count | Source | 404 | 2.07M | void NotNested() { | 405 | | // If you hit this, you're trying to construct a Table/Vector/String | 406 | | // during the construction of its parent table (between the MyTableBuilder | 407 | | // and table.Finish(). | 408 | | // Move the creation of these sub-objects to above the MyTableBuilder to | 409 | | // not get this assert. | 410 | | // Ignoring this assert may appear to work in simple cases, but the reason | 411 | | // it is here is that storing objects in-line may cause vtable offsets | 412 | | // to not fit anymore. It also leads to vtable duplication. | 413 | 2.07M | FLATBUFFERS_ASSERT(!nested); | 414 | | // If you hit this, fields were added outside the scope of a table. | 415 | 2.07M | FLATBUFFERS_ASSERT(!num_field_loc); | 416 | 2.07M | } |
|
417 | | |
418 | | // From generated code (or from the parser), we call StartTable/EndTable |
419 | | // with a sequence of AddElement calls in between. |
420 | 1.20M | uoffset_t StartTable() { |
421 | 1.20M | NotNested(); |
422 | 1.20M | nested = true; |
423 | 1.20M | return GetSizeRelative32BitRegion(); |
424 | 1.20M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::StartTable() flatbuffers::FlatBufferBuilderImpl<false>::StartTable() Line | Count | Source | 420 | 1.20M | uoffset_t StartTable() { | 421 | 1.20M | NotNested(); | 422 | 1.20M | nested = true; | 423 | 1.20M | return GetSizeRelative32BitRegion(); | 424 | 1.20M | } |
|
425 | | |
426 | | // This finishes one serialized object by generating the vtable if it's a |
427 | | // table, comparing it against existing vtables, and writing the |
428 | | // resulting vtable offset. |
429 | 998k | uoffset_t EndTable(uoffset_t start) { |
430 | | // If you get this assert, a corresponding StartTable wasn't called. |
431 | 998k | FLATBUFFERS_ASSERT(nested); |
432 | | // Write the vtable offset, which is the start of any Table. |
433 | | // We fill its value later. |
434 | | // This is relative to the end of the 32-bit region. |
435 | 998k | const uoffset_t vtable_offset_loc = |
436 | 998k | static_cast<uoffset_t>(PushElement<soffset_t>(0)); |
437 | | // Write a vtable, which consists entirely of voffset_t elements. |
438 | | // It starts with the number of offsets, followed by a type id, followed |
439 | | // by the offsets themselves. In reverse: |
440 | | // Include space for the last offset and ensure empty tables have a |
441 | | // minimum size. |
442 | 998k | max_voffset_ = |
443 | 998k | (std::max)(static_cast<voffset_t>(max_voffset_ + sizeof(voffset_t)), |
444 | 998k | FieldIndexToOffset(0)); |
445 | 998k | buf_.fill_big(max_voffset_); |
446 | 998k | const uoffset_t table_object_size = vtable_offset_loc - start; |
447 | | // Vtable use 16bit offsets. |
448 | 998k | FLATBUFFERS_ASSERT(table_object_size < 0x10000); |
449 | 998k | WriteScalar<voffset_t>(buf_.data() + sizeof(voffset_t), |
450 | 998k | static_cast<voffset_t>(table_object_size)); |
451 | 998k | WriteScalar<voffset_t>(buf_.data(), max_voffset_); |
452 | | // Write the offsets into the table |
453 | 998k | for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc); |
454 | 2.63M | it < buf_.scratch_end(); it += sizeof(FieldLoc)) { |
455 | 1.63M | auto field_location = reinterpret_cast<FieldLoc*>(it); |
456 | 1.63M | const voffset_t pos = |
457 | 1.63M | static_cast<voffset_t>(vtable_offset_loc - field_location->off); |
458 | | // If this asserts, it means you've set a field twice. |
459 | 1.63M | FLATBUFFERS_ASSERT( |
460 | 1.63M | !ReadScalar<voffset_t>(buf_.data() + field_location->id)); |
461 | 1.63M | WriteScalar<voffset_t>(buf_.data() + field_location->id, pos); |
462 | 1.63M | } |
463 | 998k | ClearOffsets(); |
464 | 998k | auto vt1 = reinterpret_cast<voffset_t*>(buf_.data()); |
465 | 998k | auto vt1_size = ReadScalar<voffset_t>(vt1); |
466 | 998k | auto vt_use = GetSizeRelative32BitRegion(); |
467 | | // See if we already have generated a vtable with this exact same |
468 | | // layout before. If so, make it point to the old one, remove this one. |
469 | 998k | if (dedup_vtables_) { |
470 | 1.92M | for (auto it = buf_.scratch_data(); it < buf_.scratch_end(); |
471 | 1.58M | it += sizeof(uoffset_t)) { |
472 | 1.58M | auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it); |
473 | 1.58M | auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr + length_of_64_bit_region_)); |
474 | 1.58M | auto vt2_size = ReadScalar<voffset_t>(vt2); |
475 | 1.58M | if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue; |
476 | 660k | vt_use = *vt_offset_ptr; |
477 | 660k | buf_.pop(GetSizeRelative32BitRegion() - vtable_offset_loc); |
478 | 660k | break; |
479 | 1.58M | } |
480 | 998k | } |
481 | | // If this is a new vtable, remember it. |
482 | 998k | if (vt_use == GetSizeRelative32BitRegion()) { |
483 | 337k | buf_.scratch_push_small(vt_use); |
484 | 337k | } |
485 | | // Fill the vtable offset we created above. |
486 | | // The offset points from the beginning of the object to where the vtable is |
487 | | // stored. |
488 | | // Offsets default direction is downward in memory for future format |
489 | | // flexibility (storing all vtables at the start of the file). |
490 | 998k | WriteScalar(buf_.data_at(vtable_offset_loc + length_of_64_bit_region_), |
491 | 998k | static_cast<soffset_t>(vt_use) - |
492 | 998k | static_cast<soffset_t>(vtable_offset_loc)); |
493 | 998k | nested = false; |
494 | 998k | return vtable_offset_loc; |
495 | 998k | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::EndTable(unsigned int) flatbuffers::FlatBufferBuilderImpl<false>::EndTable(unsigned int) Line | Count | Source | 429 | 998k | uoffset_t EndTable(uoffset_t start) { | 430 | | // If you get this assert, a corresponding StartTable wasn't called. | 431 | 998k | FLATBUFFERS_ASSERT(nested); | 432 | | // Write the vtable offset, which is the start of any Table. | 433 | | // We fill its value later. | 434 | | // This is relative to the end of the 32-bit region. | 435 | 998k | const uoffset_t vtable_offset_loc = | 436 | 998k | static_cast<uoffset_t>(PushElement<soffset_t>(0)); | 437 | | // Write a vtable, which consists entirely of voffset_t elements. | 438 | | // It starts with the number of offsets, followed by a type id, followed | 439 | | // by the offsets themselves. In reverse: | 440 | | // Include space for the last offset and ensure empty tables have a | 441 | | // minimum size. | 442 | 998k | max_voffset_ = | 443 | 998k | (std::max)(static_cast<voffset_t>(max_voffset_ + sizeof(voffset_t)), | 444 | 998k | FieldIndexToOffset(0)); | 445 | 998k | buf_.fill_big(max_voffset_); | 446 | 998k | const uoffset_t table_object_size = vtable_offset_loc - start; | 447 | | // Vtable use 16bit offsets. | 448 | 998k | FLATBUFFERS_ASSERT(table_object_size < 0x10000); | 449 | 998k | WriteScalar<voffset_t>(buf_.data() + sizeof(voffset_t), | 450 | 998k | static_cast<voffset_t>(table_object_size)); | 451 | 998k | WriteScalar<voffset_t>(buf_.data(), max_voffset_); | 452 | | // Write the offsets into the table | 453 | 998k | for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc); | 454 | 2.63M | it < buf_.scratch_end(); it += sizeof(FieldLoc)) { | 455 | 1.63M | auto field_location = reinterpret_cast<FieldLoc*>(it); | 456 | 1.63M | const voffset_t pos = | 457 | 1.63M | static_cast<voffset_t>(vtable_offset_loc - field_location->off); | 458 | | // If this asserts, it means you've set a field twice. | 459 | 1.63M | FLATBUFFERS_ASSERT( | 460 | 1.63M | !ReadScalar<voffset_t>(buf_.data() + field_location->id)); | 461 | 1.63M | WriteScalar<voffset_t>(buf_.data() + field_location->id, pos); | 462 | 1.63M | } | 463 | 998k | ClearOffsets(); | 464 | 998k | auto vt1 = reinterpret_cast<voffset_t*>(buf_.data()); | 465 | 998k | auto vt1_size = ReadScalar<voffset_t>(vt1); | 466 | 998k | auto vt_use = GetSizeRelative32BitRegion(); | 467 | | // See if we already have generated a vtable with this exact same | 468 | | // layout before. If so, make it point to the old one, remove this one. | 469 | 998k | if (dedup_vtables_) { | 470 | 1.92M | for (auto it = buf_.scratch_data(); it < buf_.scratch_end(); | 471 | 1.58M | it += sizeof(uoffset_t)) { | 472 | 1.58M | auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it); | 473 | 1.58M | auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr + length_of_64_bit_region_)); | 474 | 1.58M | auto vt2_size = ReadScalar<voffset_t>(vt2); | 475 | 1.58M | if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue; | 476 | 660k | vt_use = *vt_offset_ptr; | 477 | 660k | buf_.pop(GetSizeRelative32BitRegion() - vtable_offset_loc); | 478 | 660k | break; | 479 | 1.58M | } | 480 | 998k | } | 481 | | // If this is a new vtable, remember it. | 482 | 998k | if (vt_use == GetSizeRelative32BitRegion()) { | 483 | 337k | buf_.scratch_push_small(vt_use); | 484 | 337k | } | 485 | | // Fill the vtable offset we created above. | 486 | | // The offset points from the beginning of the object to where the vtable is | 487 | | // stored. | 488 | | // Offsets default direction is downward in memory for future format | 489 | | // flexibility (storing all vtables at the start of the file). | 490 | 998k | WriteScalar(buf_.data_at(vtable_offset_loc + length_of_64_bit_region_), | 491 | 998k | static_cast<soffset_t>(vt_use) - | 492 | 998k | static_cast<soffset_t>(vtable_offset_loc)); | 493 | 998k | nested = false; | 494 | 998k | return vtable_offset_loc; | 495 | 998k | } |
|
496 | | |
497 | | FLATBUFFERS_ATTRIBUTE([[deprecated("call the version above instead")]]) |
498 | | uoffset_t EndTable(uoffset_t start, voffset_t /*numfields*/) { |
499 | | return EndTable(start); |
500 | | } |
501 | | |
502 | | // This checks a required field has been set in a given table that has |
503 | | // just been constructed. |
504 | | template <typename T> |
505 | 350k | void Required(Offset<T> table, voffset_t field) { |
506 | 350k | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); |
507 | 350k | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; |
508 | | // If this fails, the caller will show what field needs to be set. |
509 | 350k | FLATBUFFERS_ASSERT(ok); |
510 | 350k | (void)ok; |
511 | 350k | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::Required<MyGame::Example::Monster>(flatbuffers::Offset<MyGame::Example::Monster>, unsigned short) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::SchemaFile>(flatbuffers::Offset<reflection::SchemaFile>, unsigned short) void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::KeyValue>(flatbuffers::Offset<reflection::KeyValue>, unsigned short) Line | Count | Source | 505 | 183 | void Required(Offset<T> table, voffset_t field) { | 506 | 183 | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 183 | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 183 | FLATBUFFERS_ASSERT(ok); | 510 | 183 | (void)ok; | 511 | 183 | } |
void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::EnumVal>(flatbuffers::Offset<reflection::EnumVal>, unsigned short) Line | Count | Source | 505 | 84.1k | void Required(Offset<T> table, voffset_t field) { | 506 | 84.1k | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 84.1k | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 84.1k | FLATBUFFERS_ASSERT(ok); | 510 | 84.1k | (void)ok; | 511 | 84.1k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::Enum>(flatbuffers::Offset<reflection::Enum>, unsigned short) Line | Count | Source | 505 | 150k | void Required(Offset<T> table, voffset_t field) { | 506 | 150k | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 150k | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 150k | FLATBUFFERS_ASSERT(ok); | 510 | 150k | (void)ok; | 511 | 150k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::Field>(flatbuffers::Offset<reflection::Field>, unsigned short) Line | Count | Source | 505 | 45.0k | void Required(Offset<T> table, voffset_t field) { | 506 | 45.0k | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 45.0k | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 45.0k | FLATBUFFERS_ASSERT(ok); | 510 | 45.0k | (void)ok; | 511 | 45.0k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::Object>(flatbuffers::Offset<reflection::Object>, unsigned short) Line | Count | Source | 505 | 58.6k | void Required(Offset<T> table, voffset_t field) { | 506 | 58.6k | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 58.6k | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 58.6k | FLATBUFFERS_ASSERT(ok); | 510 | 58.6k | (void)ok; | 511 | 58.6k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::RPCCall>(flatbuffers::Offset<reflection::RPCCall>, unsigned short) Line | Count | Source | 505 | 3.67k | void Required(Offset<T> table, voffset_t field) { | 506 | 3.67k | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 3.67k | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 3.67k | FLATBUFFERS_ASSERT(ok); | 510 | 3.67k | (void)ok; | 511 | 3.67k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::Service>(flatbuffers::Offset<reflection::Service>, unsigned short) Line | Count | Source | 505 | 810 | void Required(Offset<T> table, voffset_t field) { | 506 | 810 | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 810 | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 810 | FLATBUFFERS_ASSERT(ok); | 510 | 810 | (void)ok; | 511 | 810 | } |
Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::SchemaFile>(flatbuffers::Offset<reflection::SchemaFile>, unsigned short) void flatbuffers::FlatBufferBuilderImpl<false>::Required<reflection::Schema>(flatbuffers::Offset<reflection::Schema>, unsigned short) Line | Count | Source | 505 | 7.57k | void Required(Offset<T> table, voffset_t field) { | 506 | 7.57k | auto table_ptr = reinterpret_cast<const Table*>(buf_.data_at(table.o)); | 507 | 7.57k | bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; | 508 | | // If this fails, the caller will show what field needs to be set. | 509 | 7.57k | FLATBUFFERS_ASSERT(ok); | 510 | 7.57k | (void)ok; | 511 | 7.57k | } |
|
512 | | |
513 | 61.9k | uoffset_t StartStruct(size_t alignment) { |
514 | 61.9k | Align(alignment); |
515 | 61.9k | return GetSizeRelative32BitRegion(); |
516 | 61.9k | } |
517 | | |
518 | 61.5k | uoffset_t EndStruct() { return GetSizeRelative32BitRegion(); } |
519 | | |
520 | 1.90M | void ClearOffsets() { |
521 | 1.90M | buf_.scratch_pop(num_field_loc * sizeof(FieldLoc)); |
522 | 1.90M | num_field_loc = 0; |
523 | 1.90M | max_voffset_ = 0; |
524 | 1.90M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::ClearOffsets() flatbuffers::FlatBufferBuilderImpl<false>::ClearOffsets() Line | Count | Source | 520 | 1.90M | void ClearOffsets() { | 521 | 1.90M | buf_.scratch_pop(num_field_loc * sizeof(FieldLoc)); | 522 | 1.90M | num_field_loc = 0; | 523 | 1.90M | max_voffset_ = 0; | 524 | 1.90M | } |
|
525 | | |
526 | | // Aligns such that when "len" bytes are written, an object can be written |
527 | | // after it (forward in the buffer) with "alignment" without padding. |
528 | 1.07M | void PreAlign(size_t len, size_t alignment) { |
529 | 1.07M | if (len == 0) return; |
530 | 972k | TrackMinAlign(alignment); |
531 | 972k | buf_.fill(PaddingBytes(GetSize() + len, alignment)); |
532 | 972k | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::PreAlign(unsigned long, unsigned long) flatbuffers::FlatBufferBuilderImpl<false>::PreAlign(unsigned long, unsigned long) Line | Count | Source | 528 | 1.07M | void PreAlign(size_t len, size_t alignment) { | 529 | 1.07M | if (len == 0) return; | 530 | 972k | TrackMinAlign(alignment); | 531 | 972k | buf_.fill(PaddingBytes(GetSize() + len, alignment)); | 532 | 972k | } |
|
533 | | |
534 | | // Aligns such than when "len" bytes are written, an object of type `AlignT` |
535 | | // can be written after it (forward in the buffer) without padding. |
536 | | template <typename AlignT> |
537 | 559k | void PreAlign(size_t len) { |
538 | 559k | AssertScalarT<AlignT>(); |
539 | 559k | PreAlign(len, AlignOf<AlignT>()); |
540 | 559k | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::PreAlign<unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::PreAlign<unsigned long>(unsigned long) void flatbuffers::FlatBufferBuilderImpl<false>::PreAlign<unsigned int>(unsigned long) Line | Count | Source | 537 | 559k | void PreAlign(size_t len) { | 538 | 559k | AssertScalarT<AlignT>(); | 539 | 559k | PreAlign(len, AlignOf<AlignT>()); | 540 | 559k | } |
|
541 | | /// @endcond |
542 | | |
543 | | /// @brief Store a string in the buffer, which can contain any binary data. |
544 | | /// @param[in] str A const char pointer to the data to be stored as a string. |
545 | | /// @param[in] len The number of bytes that should be stored from `str`. |
546 | | /// @return Returns the offset in the buffer where the string starts. |
547 | | template <template <typename> class OffsetT = Offset> |
548 | 383k | OffsetT<String> CreateString(const char* str, size_t len) { |
549 | 383k | CreateStringImpl(str, len); |
550 | 383k | return OffsetT<String>( |
551 | 383k | CalculateOffset<typename OffsetT<String>::offset_type>()); |
552 | 383k | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<true>::CreateString<flatbuffers::Offset>(char const*, unsigned long) flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<false>::CreateString<flatbuffers::Offset>(char const*, unsigned long) Line | Count | Source | 548 | 383k | OffsetT<String> CreateString(const char* str, size_t len) { | 549 | 383k | CreateStringImpl(str, len); | 550 | 383k | return OffsetT<String>( | 551 | 383k | CalculateOffset<typename OffsetT<String>::offset_type>()); | 552 | 383k | } |
|
553 | | |
554 | | /// @brief Store a string in the buffer, which is null-terminated. |
555 | | /// @param[in] str A const char pointer to a C-string to add to the buffer. |
556 | | /// @return Returns the offset in the buffer where the string starts. |
557 | | template <template <typename> class OffsetT = Offset> |
558 | 0 | OffsetT<String> CreateString(const char* str) { |
559 | 0 | return CreateString<OffsetT>(str, strlen(str)); |
560 | 0 | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<false>::CreateString<flatbuffers::Offset>(char const*) Unexecuted instantiation: flatbuffers::Offset64<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<true>::CreateString<flatbuffers::Offset64>(char const*) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<true>::CreateString<flatbuffers::Offset>(char const*) |
561 | | |
562 | | /// @brief Store a string in the buffer, which is null-terminated. |
563 | | /// @param[in] str A char pointer to a C-string to add to the buffer. |
564 | | /// @return Returns the offset in the buffer where the string starts. |
565 | | template <template <typename> class OffsetT = Offset> |
566 | | OffsetT<String> CreateString(char* str) { |
567 | | return CreateString<OffsetT>(str, strlen(str)); |
568 | | } |
569 | | |
570 | | /// @brief Store a string in the buffer, which can contain any binary data. |
571 | | /// @param[in] str A const reference to a std::string to store in the buffer. |
572 | | /// @return Returns the offset in the buffer where the string starts. |
573 | | template <template <typename> class OffsetT = Offset> |
574 | 301k | OffsetT<String> CreateString(const std::string& str) { |
575 | 301k | return CreateString<OffsetT>(str.c_str(), str.length()); |
576 | 301k | } Unexecuted instantiation: flatbuffers::Offset64<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<true>::CreateString<flatbuffers::Offset64>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<true>::CreateString<flatbuffers::Offset>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilderImpl<false>::CreateString<flatbuffers::Offset>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 574 | 301k | OffsetT<String> CreateString(const std::string& str) { | 575 | 301k | return CreateString<OffsetT>(str.c_str(), str.length()); | 576 | 301k | } |
|
577 | | |
578 | | // clang-format off |
579 | | #ifdef FLATBUFFERS_HAS_STRING_VIEW |
580 | | /// @brief Store a string in the buffer, which can contain any binary data. |
581 | | /// @param[in] str A const string_view to copy in to the buffer. |
582 | | /// @return Returns the offset in the buffer where the string starts. |
583 | | template<template <typename> class OffsetT = Offset> |
584 | | OffsetT<String>CreateString(flatbuffers::string_view str) { |
585 | | return CreateString<OffsetT>(str.data(), str.size()); |
586 | | } |
587 | | #endif // FLATBUFFERS_HAS_STRING_VIEW |
588 | | // clang-format on |
589 | | |
590 | | /// @brief Store a string in the buffer, which can contain any binary data. |
591 | | /// @param[in] str A const pointer to a `String` struct to add to the buffer. |
592 | | /// @return Returns the offset in the buffer where the string starts |
593 | | template <template <typename> class OffsetT = Offset> |
594 | 0 | OffsetT<String> CreateString(const String* str) { |
595 | 0 | return str ? CreateString<OffsetT>(str->c_str(), str->size()) : 0; |
596 | 0 | } |
597 | | |
598 | | /// @brief Store a string in the buffer, which can contain any binary data. |
599 | | /// @param[in] str A const reference to a std::string like type with support |
600 | | /// of T::data() and T::length() to store in the buffer. |
601 | | /// @return Returns the offset in the buffer where the string starts. |
602 | | template <template <typename> class OffsetT = Offset, |
603 | | // No need to explicitly declare the T type, let the compiler deduce |
604 | | // it. |
605 | | int&... ExplicitArgumentBarrier, typename T> |
606 | | OffsetT<String> CreateString(const T& str) { |
607 | | return CreateString<OffsetT>(str.data(), str.length()); |
608 | | } |
609 | | |
610 | | /// @brief Store a string in the buffer, which can contain any binary data. |
611 | | /// If a string with this exact contents has already been serialized before, |
612 | | /// instead simply returns the offset of the existing string. This uses a map |
613 | | /// stored on the heap, but only stores the numerical offsets. |
614 | | /// @param[in] str A const char pointer to the data to be stored as a string. |
615 | | /// @param[in] len The number of bytes that should be stored from `str`. |
616 | | /// @return Returns the offset in the buffer where the string starts. |
617 | 82.0k | Offset<String> CreateSharedString(const char* str, size_t len) { |
618 | 82.0k | FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK); |
619 | 82.0k | if (!string_pool) { |
620 | 3.80k | string_pool = new StringOffsetMap(StringOffsetCompare(buf_)); |
621 | 3.80k | } |
622 | | |
623 | 82.0k | const size_t size_before_string = buf_.size(); |
624 | | // Must first serialize the string, since the set is all offsets into |
625 | | // buffer. |
626 | 82.0k | const Offset<String> off = CreateString<Offset>(str, len); |
627 | 82.0k | auto it = string_pool->find(off); |
628 | | // If it exists we reuse existing serialized data! |
629 | 82.0k | if (it != string_pool->end()) { |
630 | | // We can remove the string we serialized. |
631 | 77.0k | buf_.pop(buf_.size() - size_before_string); |
632 | 77.0k | return *it; |
633 | 77.0k | } |
634 | | // Record this string for future use. |
635 | 4.95k | string_pool->insert(off); |
636 | 4.95k | return off; |
637 | 82.0k | } |
638 | | |
639 | | #ifdef FLATBUFFERS_HAS_STRING_VIEW |
640 | | /// @brief Store a string in the buffer, which can contain any binary data. |
641 | | /// If a string with this exact contents has already been serialized before, |
642 | | /// instead simply returns the offset of the existing string. This uses a map |
643 | | /// stored on the heap, but only stores the numerical offsets. |
644 | | /// @param[in] str A const std::string_view to store in the buffer. |
645 | | /// @return Returns the offset in the buffer where the string starts |
646 | 82.0k | Offset<String> CreateSharedString(const flatbuffers::string_view str) { |
647 | 82.0k | return CreateSharedString(str.data(), str.size()); |
648 | 82.0k | } |
649 | | #else |
650 | | /// @brief Store a string in the buffer, which null-terminated. |
651 | | /// If a string with this exact contents has already been serialized before, |
652 | | /// instead simply returns the offset of the existing string. This uses a map |
653 | | /// stored on the heap, but only stores the numerical offsets. |
654 | | /// @param[in] str A const char pointer to a C-string to add to the buffer. |
655 | | /// @return Returns the offset in the buffer where the string starts. |
656 | | Offset<String> CreateSharedString(const char* str) { |
657 | | return CreateSharedString(str, strlen(str)); |
658 | | } |
659 | | |
660 | | /// @brief Store a string in the buffer, which can contain any binary data. |
661 | | /// If a string with this exact contents has already been serialized before, |
662 | | /// instead simply returns the offset of the existing string. This uses a map |
663 | | /// stored on the heap, but only stores the numerical offsets. |
664 | | /// @param[in] str A const reference to a std::string to store in the buffer. |
665 | | /// @return Returns the offset in the buffer where the string starts. |
666 | | Offset<String> CreateSharedString(const std::string& str) { |
667 | | return CreateSharedString(str.c_str(), str.length()); |
668 | | } |
669 | | #endif |
670 | | |
671 | | /// @brief Store a string in the buffer, which can contain any binary data. |
672 | | /// If a string with this exact contents has already been serialized before, |
673 | | /// instead simply returns the offset of the existing string. This uses a map |
674 | | /// stored on the heap, but only stores the numerical offsets. |
675 | | /// @param[in] str A const pointer to a `String` struct to add to the buffer. |
676 | | /// @return Returns the offset in the buffer where the string starts |
677 | 0 | Offset<String> CreateSharedString(const String* str) { |
678 | 0 | return str ? CreateSharedString(str->c_str(), str->size()) : 0; |
679 | 0 | } |
680 | | |
681 | | /// @cond FLATBUFFERS_INTERNAL |
682 | | template <typename LenT = uoffset_t, typename ReturnT = uoffset_t> |
683 | 176k | ReturnT EndVector(size_t len) { |
684 | 176k | FLATBUFFERS_ASSERT(nested); // Hit if no corresponding StartVector. |
685 | 176k | nested = false; |
686 | 176k | return PushElement<LenT, ReturnT>(static_cast<LenT>(len)); |
687 | 176k | } Unexecuted instantiation: unsigned long flatbuffers::FlatBufferBuilderImpl<true>::EndVector<unsigned int, unsigned long>(unsigned long) Unexecuted instantiation: unsigned long flatbuffers::FlatBufferBuilderImpl<true>::EndVector<unsigned long, unsigned long>(unsigned long) Unexecuted instantiation: unsigned int flatbuffers::FlatBufferBuilderImpl<true>::EndVector<unsigned int, unsigned int>(unsigned long) unsigned int flatbuffers::FlatBufferBuilderImpl<false>::EndVector<unsigned int, unsigned int>(unsigned long) Line | Count | Source | 683 | 168k | ReturnT EndVector(size_t len) { | 684 | 168k | FLATBUFFERS_ASSERT(nested); // Hit if no corresponding StartVector. | 685 | 168k | nested = false; | 686 | 168k | return PushElement<LenT, ReturnT>(static_cast<LenT>(len)); | 687 | 168k | } |
unsigned int flatbuffers::FlatBufferBuilderImpl<false>::EndVector<unsigned long, unsigned int>(unsigned long) Line | Count | Source | 683 | 7.37k | ReturnT EndVector(size_t len) { | 684 | 7.37k | FLATBUFFERS_ASSERT(nested); // Hit if no corresponding StartVector. | 685 | 7.37k | nested = false; | 686 | 7.37k | return PushElement<LenT, ReturnT>(static_cast<LenT>(len)); | 687 | 7.37k | } |
|
688 | | |
689 | | template <template <typename> class OffsetT = Offset, |
690 | | typename LenT = uint32_t> |
691 | 176k | void StartVector(size_t len, size_t elemsize, size_t alignment) { |
692 | 176k | NotNested(); |
693 | 176k | nested = true; |
694 | | // Align to the Length type of the vector (either 32-bit or 64-bit), so |
695 | | // that the length of the buffer can be added without padding. |
696 | 176k | PreAlign<LenT>(len * elemsize); |
697 | 176k | PreAlign(len * elemsize, alignment); // Just in case elemsize > uoffset_t. |
698 | 176k | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::StartVector<flatbuffers::EmptyOffset, unsigned int>(unsigned long, unsigned long, unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::StartVector<flatbuffers::EmptyOffset, unsigned long>(unsigned long, unsigned long, unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::StartVector<flatbuffers::Offset, unsigned int>(unsigned long, unsigned long, unsigned long) void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset, unsigned int>(unsigned long, unsigned long, unsigned long) Line | Count | Source | 691 | 176k | void StartVector(size_t len, size_t elemsize, size_t alignment) { | 692 | 176k | NotNested(); | 693 | 176k | nested = true; | 694 | | // Align to the Length type of the vector (either 32-bit or 64-bit), so | 695 | | // that the length of the buffer can be added without padding. | 696 | 176k | PreAlign<LenT>(len * elemsize); | 697 | 176k | PreAlign(len * elemsize, alignment); // Just in case elemsize > uoffset_t. | 698 | 176k | } |
|
699 | | |
700 | | template <typename T, template <typename> class OffsetT = Offset, |
701 | | typename LenT = uint32_t> |
702 | 116k | void StartVector(size_t len) { |
703 | 116k | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); |
704 | 116k | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<flatbuffers::String>, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<MyGame::Example::Monster>, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<long, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<double, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<MyGame::Example::Referrable>, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<unsigned long, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<MyGame::Example::Color, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<MyGame::Example::Stat>, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<signed char, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::StartVector<signed char, flatbuffers::Offset64, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::StartVector<unsigned char, flatbuffers::Offset64, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::StartVector<unsigned char, flatbuffers::Offset64, unsigned long>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::StartVector<flatbuffers::Offset<WrapperTable>, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::SchemaFile>, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<flatbuffers::String const*>, flatbuffers::Offset, unsigned int>(unsigned long) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<flatbuffers::Table const*>, flatbuffers::Offset, unsigned int>(unsigned long) void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<unsigned char, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 25.2k | void StartVector(size_t len) { | 703 | 25.2k | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 25.2k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::KeyValue>, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 183 | void StartVector(size_t len) { | 703 | 183 | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 183 | } |
void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::EnumVal>, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 50.0k | void StartVector(size_t len) { | 703 | 50.0k | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 50.0k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::Field>, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 29.3k | void StartVector(size_t len) { | 703 | 29.3k | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 29.3k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::RPCCall>, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 810 | void StartVector(size_t len) { | 703 | 810 | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 810 | } |
void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::Object>, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 3.78k | void StartVector(size_t len) { | 703 | 3.78k | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 3.78k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::Enum>, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 3.78k | void StartVector(size_t len) { | 703 | 3.78k | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 3.78k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::StartVector<flatbuffers::Offset<reflection::Service>, flatbuffers::Offset, unsigned int>(unsigned long) Line | Count | Source | 702 | 3.78k | void StartVector(size_t len) { | 703 | 3.78k | return StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); | 704 | 3.78k | } |
|
705 | | |
706 | | // Call this right before StartVector/CreateVector if you want to force the |
707 | | // alignment to be something different than what the element size would |
708 | | // normally dictate. |
709 | | // This is useful when storing a nested_flatbuffer in a vector of bytes, |
710 | | // or when storing SIMD floats, etc. |
711 | | void ForceVectorAlignment(const size_t len, const size_t elemsize, |
712 | 36.4k | const size_t alignment) { |
713 | 36.4k | if (len == 0) return; |
714 | 33.1k | FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); |
715 | 33.1k | PreAlign(len * elemsize, alignment); |
716 | 33.1k | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::ForceVectorAlignment(unsigned long, unsigned long, unsigned long) flatbuffers::FlatBufferBuilderImpl<false>::ForceVectorAlignment(unsigned long, unsigned long, unsigned long) Line | Count | Source | 712 | 36.4k | const size_t alignment) { | 713 | 36.4k | if (len == 0) return; | 714 | 33.1k | FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); | 715 | 33.1k | PreAlign(len * elemsize, alignment); | 716 | 33.1k | } |
|
717 | | |
718 | | template <bool is_64 = Is64Aware> |
719 | | typename std::enable_if<is_64, void>::type ForceVectorAlignment64( |
720 | 0 | const size_t len, const size_t elemsize, const size_t alignment) { |
721 | 0 | // If you hit this assertion, you are trying to force alignment on a |
722 | 0 | // vector with offset64 after serializing a 32-bit offset. |
723 | 0 | FLATBUFFERS_ASSERT(GetSize() == length_of_64_bit_region_); |
724 | 0 |
|
725 | 0 | // Call through. |
726 | 0 | ForceVectorAlignment(len, elemsize, alignment); |
727 | 0 |
|
728 | 0 | // Update the 64 bit region. |
729 | 0 | length_of_64_bit_region_ = GetSize(); |
730 | 0 | } |
731 | | |
732 | | // Similar to ForceVectorAlignment but for String fields. |
733 | | void ForceStringAlignment(size_t len, size_t alignment) { |
734 | | if (len == 0) return; |
735 | | FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); |
736 | | PreAlign((len + 1) * sizeof(char), alignment); |
737 | | } |
738 | | |
739 | | /// @endcond |
740 | | |
741 | | /// @brief Serialize an array into a FlatBuffer `vector`. |
742 | | /// @tparam T The data type of the array elements. |
743 | | /// @tparam OffsetT the type of offset to return |
744 | | /// @tparam VectorT the type of vector to cast to. |
745 | | /// @param[in] v A pointer to the array of type `T` to serialize into the |
746 | | /// buffer as a `vector`. |
747 | | /// @param[in] len The number of elements to serialize. |
748 | | /// @return Returns a typed `TOffset` into the serialized data indicating |
749 | | /// where the vector is stored. |
750 | | template <typename T, template <typename...> class OffsetT = Offset, |
751 | | template <typename...> class VectorT = Vector> |
752 | 25.2k | OffsetT<VectorT<T>> CreateVector(const T* v, size_t len) { |
753 | | // The type of the length field in the vector. |
754 | 25.2k | typedef typename VectorT<T>::size_type LenT; |
755 | 25.2k | typedef typename OffsetT<VectorT<T>>::offset_type offset_type; |
756 | | // If this assert hits, you're specifying a template argument that is |
757 | | // causing the wrong overload to be selected, remove it. |
758 | 25.2k | AssertScalarT<T>(); |
759 | 25.2k | StartVector<T, OffsetT, LenT>(len); |
760 | 25.2k | if (len > 0) { |
761 | | // clang-format off |
762 | 25.2k | #if FLATBUFFERS_LITTLEENDIAN |
763 | 25.2k | PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T)); |
764 | | #else |
765 | | if (sizeof(T) == 1) { |
766 | | PushBytes(reinterpret_cast<const uint8_t *>(v), len); |
767 | | } else { |
768 | | for (auto i = len; i > 0; ) { |
769 | | PushElement(v[--i]); |
770 | | } |
771 | | } |
772 | | #endif |
773 | | // clang-format on |
774 | 25.2k | } |
775 | 25.2k | return OffsetT<VectorT<T>>(EndVector<LenT, offset_type>(len)); |
776 | 25.2k | } Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE12CreateVectorIlTtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKS7_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE12CreateVectorIdTtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKS7_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE12CreateVectorImTtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKS7_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE12CreateVectorIN6MyGame7Example5ColorETtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKSA_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE12CreateVectorIaTtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKS7_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE12CreateVectorIaTtTpTyENS_8Offset64ETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKS7_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE12CreateVectorIhTtTpTyENS_8Offset64ETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKS7_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE12CreateVectorIhTtTpTyENS_8Offset64ETtTpTyENS_8Vector64EEET0_IJT1_IJT_EEEEPKS7_m _ZN11flatbuffers21FlatBufferBuilderImplILb0EE12CreateVectorIhTtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJT_EEEEPKS7_m Line | Count | Source | 752 | 25.2k | OffsetT<VectorT<T>> CreateVector(const T* v, size_t len) { | 753 | | // The type of the length field in the vector. | 754 | 25.2k | typedef typename VectorT<T>::size_type LenT; | 755 | 25.2k | typedef typename OffsetT<VectorT<T>>::offset_type offset_type; | 756 | | // If this assert hits, you're specifying a template argument that is | 757 | | // causing the wrong overload to be selected, remove it. | 758 | 25.2k | AssertScalarT<T>(); | 759 | 25.2k | StartVector<T, OffsetT, LenT>(len); | 760 | 25.2k | if (len > 0) { | 761 | | // clang-format off | 762 | 25.2k | #if FLATBUFFERS_LITTLEENDIAN | 763 | 25.2k | PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T)); | 764 | | #else | 765 | | if (sizeof(T) == 1) { | 766 | | PushBytes(reinterpret_cast<const uint8_t *>(v), len); | 767 | | } else { | 768 | | for (auto i = len; i > 0; ) { | 769 | | PushElement(v[--i]); | 770 | | } | 771 | | } | 772 | | #endif | 773 | | // clang-format on | 774 | 25.2k | } | 775 | 25.2k | return OffsetT<VectorT<T>>(EndVector<LenT, offset_type>(len)); | 776 | 25.2k | } |
|
777 | | |
778 | | /// @brief Serialize an array like object into a FlatBuffer `vector`. |
779 | | /// @tparam T The data type of the array elements. |
780 | | /// @tparam C The type of the array. |
781 | | /// @param[in] array A reference to an array like object of type `T` to |
782 | | /// serialize into the buffer as a `vector`. |
783 | | /// @return Returns a typed `Offset` into the serialized data indicating |
784 | | /// where the vector is stored. |
785 | | template <typename T, class C> |
786 | | Offset<Vector<T>> CreateVector(const C& array) { |
787 | | return CreateVector(array.data(), array.size()); |
788 | | } |
789 | | |
790 | | /// @brief Serialize an initializer list into a FlatBuffer `vector`. |
791 | | /// @tparam T The data type of the initializer list elements. |
792 | | /// @param[in] v The value of the initializer list. |
793 | | /// @return Returns a typed `Offset` into the serialized data indicating |
794 | | /// where the vector is stored. |
795 | | template <typename T> |
796 | | Offset<Vector<T>> CreateVector(std::initializer_list<T> v) { |
797 | | return CreateVector(v.begin(), v.size()); |
798 | | } |
799 | | |
800 | | template <typename T> |
801 | 91.7k | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { |
802 | 91.7k | StartVector<Offset<T>>(len); |
803 | 280k | for (auto i = len; i > 0;) { |
804 | 188k | PushElement(v[--i]); |
805 | 188k | } |
806 | 91.7k | return Offset<Vector<Offset<T>>>(EndVector(len)); |
807 | 91.7k | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::String>(flatbuffers::Offset<flatbuffers::String> const*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<MyGame::Example::Monster>(flatbuffers::Offset<MyGame::Example::Monster> const*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<MyGame::Example::Referrable>(flatbuffers::Offset<MyGame::Example::Referrable> const*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<MyGame::Example::Stat>(flatbuffers::Offset<MyGame::Example::Stat> const*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<WrapperTable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<true>::CreateVector<WrapperTable>(flatbuffers::Offset<WrapperTable> const*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::SchemaFile>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::SchemaFile>(flatbuffers::Offset<reflection::SchemaFile> const*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String const*>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::String const*>(flatbuffers::Offset<flatbuffers::String const*> const*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::Table const*>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Table const*>(flatbuffers::Offset<flatbuffers::Table const*> const*, unsigned long) flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::KeyValue>(flatbuffers::Offset<reflection::KeyValue> const*, unsigned long) Line | Count | Source | 801 | 183 | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { | 802 | 183 | StartVector<Offset<T>>(len); | 803 | 366 | for (auto i = len; i > 0;) { | 804 | 183 | PushElement(v[--i]); | 805 | 183 | } | 806 | 183 | return Offset<Vector<Offset<T>>>(EndVector(len)); | 807 | 183 | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::EnumVal>(flatbuffers::Offset<reflection::EnumVal> const*, unsigned long) Line | Count | Source | 801 | 50.0k | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { | 802 | 50.0k | StartVector<Offset<T>>(len); | 803 | 134k | for (auto i = len; i > 0;) { | 804 | 84.1k | PushElement(v[--i]); | 805 | 84.1k | } | 806 | 50.0k | return Offset<Vector<Offset<T>>>(EndVector(len)); | 807 | 50.0k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Field>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::Field>(flatbuffers::Offset<reflection::Field> const*, unsigned long) Line | Count | Source | 801 | 29.3k | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { | 802 | 29.3k | StartVector<Offset<T>>(len); | 803 | 51.8k | for (auto i = len; i > 0;) { | 804 | 22.5k | PushElement(v[--i]); | 805 | 22.5k | } | 806 | 29.3k | return Offset<Vector<Offset<T>>>(EndVector(len)); | 807 | 29.3k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::RPCCall>(flatbuffers::Offset<reflection::RPCCall> const*, unsigned long) Line | Count | Source | 801 | 810 | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { | 802 | 810 | StartVector<Offset<T>>(len); | 803 | 2.03k | for (auto i = len; i > 0;) { | 804 | 1.22k | PushElement(v[--i]); | 805 | 1.22k | } | 806 | 810 | return Offset<Vector<Offset<T>>>(EndVector(len)); | 807 | 810 | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Object>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::Object>(flatbuffers::Offset<reflection::Object> const*, unsigned long) Line | Count | Source | 801 | 3.78k | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { | 802 | 3.78k | StartVector<Offset<T>>(len); | 803 | 33.1k | for (auto i = len; i > 0;) { | 804 | 29.3k | PushElement(v[--i]); | 805 | 29.3k | } | 806 | 3.78k | return Offset<Vector<Offset<T>>>(EndVector(len)); | 807 | 3.78k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::Enum>(flatbuffers::Offset<reflection::Enum> const*, unsigned long) Line | Count | Source | 801 | 3.78k | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { | 802 | 3.78k | StartVector<Offset<T>>(len); | 803 | 53.8k | for (auto i = len; i > 0;) { | 804 | 50.0k | PushElement(v[--i]); | 805 | 50.0k | } | 806 | 3.78k | return Offset<Vector<Offset<T>>>(EndVector(len)); | 807 | 3.78k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Service>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<reflection::Service>(flatbuffers::Offset<reflection::Service> const*, unsigned long) Line | Count | Source | 801 | 3.78k | Offset<Vector<Offset<T>>> CreateVector(const Offset<T>* v, size_t len) { | 802 | 3.78k | StartVector<Offset<T>>(len); | 803 | 4.59k | for (auto i = len; i > 0;) { | 804 | 810 | PushElement(v[--i]); | 805 | 810 | } | 806 | 3.78k | return Offset<Vector<Offset<T>>>(EndVector(len)); | 807 | 3.78k | } |
|
808 | | |
809 | | /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. |
810 | | /// @tparam T The data type of the `std::vector` elements. |
811 | | /// @param v A const reference to the `std::vector` to serialize into the |
812 | | /// buffer as a `vector`. |
813 | | /// @return Returns a typed `Offset` into the serialized data indicating |
814 | | /// where the vector is stored. |
815 | | template <typename T, typename Alloc = std::allocator<T>> |
816 | 65.7k | Offset<Vector<T>> CreateVector(const std::vector<T, Alloc>& v) { |
817 | 65.7k | return CreateVector(data(v), v.size()); |
818 | 65.7k | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<flatbuffers::String>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String> > >(std::__1::vector<flatbuffers::Offset<flatbuffers::String>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<long, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<long, std::__1::allocator<long> >(std::__1::vector<long, std::__1::allocator<long> > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<double, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<double, std::__1::allocator<double> >(std::__1::vector<double, std::__1::allocator<double> > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<unsigned long, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<unsigned long, std::__1::allocator<unsigned long> >(std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<MyGame::Example::Color, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<MyGame::Example::Color, std::__1::allocator<MyGame::Example::Color> >(std::__1::vector<MyGame::Example::Color, std::__1::allocator<MyGame::Example::Color> > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<signed char, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<signed char, std::__1::allocator<signed char> >(std::__1::vector<signed char, std::__1::allocator<signed char> > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<MyGame::Example::Monster>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Monster>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<MyGame::Example::Referrable>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Referrable>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<MyGame::Example::Stat>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Stat>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<WrapperTable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<true>::CreateVector<flatbuffers::Offset<WrapperTable>, std::__1::allocator<flatbuffers::Offset<WrapperTable> > >(std::__1::vector<flatbuffers::Offset<WrapperTable>, std::__1::allocator<flatbuffers::Offset<WrapperTable> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String const*>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<flatbuffers::String const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String const*> > >(std::__1::vector<flatbuffers::Offset<flatbuffers::String const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::String const*> > > const&) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::Table const*>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<flatbuffers::Table const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::Table const*> > >(std::__1::vector<flatbuffers::Offset<flatbuffers::Table const*>, std::__1::allocator<flatbuffers::Offset<flatbuffers::Table const*> > > const&) flatbuffers::Offset<flatbuffers::Vector<unsigned char, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<unsigned char, std::__1::allocator<unsigned char> >(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) Line | Count | Source | 816 | 14.8k | Offset<Vector<T>> CreateVector(const std::vector<T, Alloc>& v) { | 817 | 14.8k | return CreateVector(data(v), v.size()); | 818 | 14.8k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<reflection::RPCCall>, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > >(std::__1::vector<flatbuffers::Offset<reflection::RPCCall>, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > > const&) Line | Count | Source | 816 | 810 | Offset<Vector<T>> CreateVector(const std::vector<T, Alloc>& v) { | 817 | 810 | return CreateVector(data(v), v.size()); | 818 | 810 | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<reflection::EnumVal>, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > >(std::__1::vector<flatbuffers::Offset<reflection::EnumVal>, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > > const&) Line | Count | Source | 816 | 50.0k | Offset<Vector<T>> CreateVector(const std::vector<T, Alloc>& v) { | 817 | 50.0k | return CreateVector(data(v), v.size()); | 818 | 50.0k | } |
|
819 | | |
820 | | template <template <typename...> class VectorT = Vector64, |
821 | | int&... ExplicitArgumentBarrier, typename T> |
822 | 0 | Offset64<VectorT<T>> CreateVector64(const std::vector<T>& v) { |
823 | 0 | return CreateVector<T, Offset64, VectorT>(data(v), v.size()); |
824 | 0 | } Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE14CreateVector64ITtTpTyENS_6VectorETpTnRiJEaEENS_8Offset64IT_IJT1_EEEERKNSt3__16vectorIS7_NSA_9allocatorIS7_EEEE Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE14CreateVector64ITtTpTyENS_6VectorETpTnRiJEhEENS_8Offset64IT_IJT1_EEEERKNSt3__16vectorIS7_NSA_9allocatorIS7_EEEE Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE14CreateVector64ITtTpTyENS_8Vector64ETpTnRiJEhEENS_8Offset64IT_IJT1_EEEERKNSt3__16vectorIS7_NSA_9allocatorIS7_EEEE |
825 | | |
826 | | // vector<bool> may be implemented using a bit-set, so we can't access it as |
827 | | // an array. Instead, read elements manually. |
828 | | // Background: https://isocpp.org/blog/2012/11/on-vectorbool |
829 | 0 | Offset<Vector<uint8_t>> CreateVector(const std::vector<bool>& v) { |
830 | 0 | StartVector<uint8_t>(v.size()); |
831 | 0 | for (auto i = v.size(); i > 0;) { |
832 | 0 | PushElement(static_cast<uint8_t>(v[--i])); |
833 | 0 | } |
834 | 0 | return Offset<Vector<uint8_t>>(EndVector(v.size())); |
835 | 0 | } |
836 | | |
837 | | Offset64<Vector64<uint8_t>> CreateVector64(const std::vector<bool>& v) { |
838 | | StartVector<uint8_t, Offset64, Vector64<uint8_t>::size_type>(v.size()); |
839 | | for (auto i = v.size(); i > 0;) { |
840 | | PushElement(static_cast<uint8_t>(v[--i])); |
841 | | } |
842 | | return Offset64<Vector64<uint8_t>>( |
843 | | EndVector<Vector64<uint8_t>::size_type, |
844 | | Offset64<Vector64<uint8_t>>::offset_type>(v.size())); |
845 | | } |
846 | | |
847 | | /// @brief Serialize values returned by a function into a FlatBuffer `vector`. |
848 | | /// This is a convenience function that takes care of iteration for you. |
849 | | /// @tparam T The data type of the `std::vector` elements. |
850 | | /// @param f A function that takes the current iteration 0..vector_size-1 and |
851 | | /// returns any type that you can construct a FlatBuffers vector out of. |
852 | | /// @return Returns a typed `Offset` into the serialized data indicating |
853 | | /// where the vector is stored. |
854 | | template <typename T> |
855 | | Offset<Vector<T>> CreateVector(size_t vector_size, |
856 | | const std::function<T(size_t i)>& f) { |
857 | | FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK); |
858 | | std::vector<T> elems(vector_size); |
859 | | for (size_t i = 0; i < vector_size; i++) elems[i] = f(i); |
860 | | return CreateVector(elems); |
861 | | } |
862 | | |
863 | | /// @brief Serialize values returned by a function into a FlatBuffer `vector`. |
864 | | /// This is a convenience function that takes care of iteration for you. This |
865 | | /// uses a vector stored on the heap to store the intermediate results of the |
866 | | /// iteration. |
867 | | /// @tparam T The data type of the `std::vector` elements. |
868 | | /// @param f A function that takes the current iteration 0..vector_size-1, |
869 | | /// and the state parameter returning any type that you can construct a |
870 | | /// FlatBuffers vector out of. |
871 | | /// @param state State passed to f. |
872 | | /// @return Returns a typed `Offset` into the serialized data indicating |
873 | | /// where the vector is stored. |
874 | | template <typename T, typename F, typename S> |
875 | 0 | Offset<Vector<T>> CreateVector(size_t vector_size, F f, S* state) { |
876 | 0 | FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK); |
877 | 0 | std::vector<T> elems(vector_size); |
878 | 0 | for (size_t i = 0; i < vector_size; i++) elems[i] = f(i, state); |
879 | 0 | return CreateVector(elems); |
880 | 0 | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<MyGame::Example::Monster>, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#1}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#1}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<MyGame::Example::Referrable>, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#2}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#2}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<unsigned long, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#3}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#3}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<MyGame::Example::Referrable>, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#4}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#4}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<unsigned long, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#5}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#5}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<unsigned long, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#6}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#6}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVector<flatbuffers::Offset<MyGame::Example::Stat>, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#7}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#7}, MyGame::Example::Monster::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, MyGame::Example::MonsterT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<WrapperTable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<true>::CreateVector<flatbuffers::Offset<WrapperTable>, RootTable::Pack(flatbuffers::FlatBufferBuilderImpl<true>&, RootTableT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, RootTable::Pack(flatbuffers::FlatBufferBuilderImpl<true>&, RootTableT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#1}, RootTable::Pack(flatbuffers::FlatBufferBuilderImpl<true>&, RootTableT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs>(unsigned long, RootTable::Pack(flatbuffers::FlatBufferBuilderImpl<true>&, RootTableT const*, std::__1::function<unsigned long (void*)> const*)::{lambda(unsigned long, RootTable::Pack(flatbuffers::FlatBufferBuilderImpl<true>&, RootTableT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*)#1}, RootTable::Pack(flatbuffers::FlatBufferBuilderImpl<true>&, RootTableT const*, std::__1::function<unsigned long (void*)> const*)::_VectorArgs*) |
881 | | |
882 | | /// @brief Serialize a `std::vector<StringType>` into a FlatBuffer `vector`. |
883 | | /// whereas StringType is any type that is accepted by the CreateString() |
884 | | /// overloads. |
885 | | /// This is a convenience function for a common case. |
886 | | /// @param v A const reference to the `std::vector` to serialize into the |
887 | | /// buffer as a `vector`. |
888 | | /// @return Returns a typed `Offset` into the serialized data indicating |
889 | | /// where the vector is stored. |
890 | | template <typename StringType = std::string, |
891 | | typename Alloc = std::allocator<StringType>> |
892 | | Offset<Vector<Offset<String>>> CreateVectorOfStrings( |
893 | 0 | const std::vector<StringType, Alloc>& v) { |
894 | 0 | return CreateVectorOfStrings(v.cbegin(), v.cend()); |
895 | 0 | } |
896 | | |
897 | | /// @brief Serialize a collection of Strings into a FlatBuffer `vector`. |
898 | | /// This is a convenience function for a common case. |
899 | | /// @param begin The beginning iterator of the collection |
900 | | /// @param end The ending iterator of the collection |
901 | | /// @return Returns a typed `Offset` into the serialized data indicating |
902 | | /// where the vector is stored. |
903 | | template <class It> |
904 | 0 | Offset<Vector<Offset<String>>> CreateVectorOfStrings(It begin, It end) { |
905 | 0 | auto distance = std::distance(begin, end); |
906 | 0 | FLATBUFFERS_ASSERT(distance >= 0); |
907 | 0 | auto size = static_cast<size_t>(distance); |
908 | 0 | auto scratch_buffer_usage = size * sizeof(Offset<String>); |
909 | | // If there is not enough space to store the offsets, there definitely won't |
910 | | // be enough space to store all the strings. So ensuring space for the |
911 | | // scratch region is OK, for if it fails, it would have failed later. |
912 | 0 | buf_.ensure_space(scratch_buffer_usage); |
913 | 0 | for (auto it = begin; it != end; ++it) { |
914 | 0 | buf_.scratch_push_small(CreateString(*it)); |
915 | 0 | } |
916 | 0 | StartVector<Offset<String>>(size); |
917 | 0 | for (size_t i = 1; i <= size; i++) { |
918 | | // Note we re-evaluate the buf location each iteration to account for any |
919 | | // underlying buffer resizing that may occur. |
920 | 0 | PushElement(*reinterpret_cast<Offset<String>*>( |
921 | 0 | buf_.scratch_end() - i * sizeof(Offset<String>))); |
922 | 0 | } |
923 | 0 | buf_.scratch_pop(scratch_buffer_usage); |
924 | 0 | return Offset<Vector<Offset<String>>>(EndVector(size)); |
925 | 0 | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfStrings<std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*> >(std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*>, std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*>) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfStrings<std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*> >(std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*>, std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*>) |
926 | | |
927 | | /// @brief Serialize an array of structs into a FlatBuffer `vector`. |
928 | | /// @tparam T The data type of the struct array elements. |
929 | | /// @param[in] v A pointer to the array of type `T` to serialize into the |
930 | | /// buffer as a `vector`. |
931 | | /// @param[in] len The number of elements to serialize. |
932 | | /// @return Returns a typed `Offset` into the serialized data indicating |
933 | | /// where the vector is stored. |
934 | | template <typename T, template <typename...> class OffsetT = Offset, |
935 | | template <typename...> class VectorT = Vector> |
936 | 0 | OffsetT<VectorT<const T*>> CreateVectorOfStructs(const T* v, size_t len) { |
937 | 0 | // The type of the length field in the vector. |
938 | 0 | typedef typename VectorT<T>::size_type LenT; |
939 | 0 | typedef typename OffsetT<VectorT<const T*>>::offset_type offset_type; |
940 | 0 |
|
941 | 0 | StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); |
942 | 0 | if (len > 0) { |
943 | 0 | PushBytes(reinterpret_cast<const uint8_t*>(v), sizeof(T) * len); |
944 | 0 | } |
945 | 0 | return OffsetT<VectorT<const T*>>(EndVector<LenT, offset_type>(len)); |
946 | 0 | } Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE21CreateVectorOfStructsIN6MyGame7Example4TestETtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJPKT_EEEESC_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE21CreateVectorOfStructsIN6MyGame7Example7AbilityETtTpTyENS_6OffsetETtTpTyENS_6VectorEEET0_IJT1_IJPKT_EEEESC_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE21CreateVectorOfStructsI10LeafStructTtTpTyENS_8Offset64ETtTpTyENS_6VectorEEET0_IJT1_IJPKT_EEEESA_m Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE21CreateVectorOfStructsI10LeafStructTtTpTyENS_8Offset64ETtTpTyENS_8Vector64EEET0_IJT1_IJPKT_EEEESA_m |
947 | | |
948 | | /// @brief Serialize an array of structs into a FlatBuffer `vector`. |
949 | | /// @tparam T The data type of the struct array elements. |
950 | | /// @param[in] filler A function that takes the current iteration |
951 | | /// 0..vector_size-1 and a pointer to the struct that must be filled. |
952 | | /// @return Returns a typed `Offset` into the serialized data indicating |
953 | | /// where the vector is stored. |
954 | | /// This is mostly useful when flatbuffers are generated with mutation |
955 | | /// accessors. |
956 | | template <typename T> |
957 | | Offset<Vector<const T*>> CreateVectorOfStructs( |
958 | | size_t vector_size, const std::function<void(size_t i, T*)>& filler) { |
959 | | T* structs = StartVectorOfStructs<T>(vector_size); |
960 | | for (size_t i = 0; i < vector_size; i++) { |
961 | | filler(i, structs); |
962 | | structs++; |
963 | | } |
964 | | return EndVectorOfStructs<T>(vector_size); |
965 | | } |
966 | | |
967 | | /// @brief Serialize an array of structs into a FlatBuffer `vector`. |
968 | | /// @tparam T The data type of the struct array elements. |
969 | | /// @param[in] f A function that takes the current iteration 0..vector_size-1, |
970 | | /// a pointer to the struct that must be filled and the state argument. |
971 | | /// @param[in] state Arbitrary state to pass to f. |
972 | | /// @return Returns a typed `Offset` into the serialized data indicating |
973 | | /// where the vector is stored. |
974 | | /// This is mostly useful when flatbuffers are generated with mutation |
975 | | /// accessors. |
976 | | template <typename T, typename F, typename S> |
977 | | Offset<Vector<const T*>> CreateVectorOfStructs(size_t vector_size, F f, |
978 | | S* state) { |
979 | | T* structs = StartVectorOfStructs<T>(vector_size); |
980 | | for (size_t i = 0; i < vector_size; i++) { |
981 | | f(i, structs, state); |
982 | | structs++; |
983 | | } |
984 | | return EndVectorOfStructs<T>(vector_size); |
985 | | } |
986 | | |
987 | | /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector`. |
988 | | /// @tparam T The data type of the `std::vector` struct elements. |
989 | | /// @param[in] v A const reference to the `std::vector` of structs to |
990 | | /// serialize into the buffer as a `vector`. |
991 | | /// @return Returns a typed `Offset` into the serialized data indicating |
992 | | /// where the vector is stored. |
993 | | template <typename T, template <typename...> class OffsetT = Offset, |
994 | | template <typename...> class VectorT = Vector, |
995 | | typename Alloc = std::allocator<T>> |
996 | | OffsetT<VectorT<const T*>> CreateVectorOfStructs( |
997 | 0 | const std::vector<T, Alloc>& v) { |
998 | 0 | return CreateVectorOfStructs<T, OffsetT, VectorT>(data(v), v.size()); |
999 | 0 | } Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE21CreateVectorOfStructsIN6MyGame7Example4TestETtTpTyENS_6OffsetETtTpTyENS_6VectorENSt3__19allocatorIS5_EEEET0_IJT1_IJPKT_EEEERKNS8_6vectorISD_T2_EE Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb0EE21CreateVectorOfStructsIN6MyGame7Example7AbilityETtTpTyENS_6OffsetETtTpTyENS_6VectorENSt3__19allocatorIS5_EEEET0_IJT1_IJPKT_EEEERKNS8_6vectorISD_T2_EE |
1000 | | |
1001 | | template <template <typename...> class VectorT = Vector64, int&..., |
1002 | | typename T> |
1003 | 0 | Offset64<VectorT<const T*>> CreateVectorOfStructs64(const std::vector<T>& v) { |
1004 | 0 | return CreateVectorOfStructs<T, Offset64, VectorT>(data(v), v.size()); |
1005 | 0 | } Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE23CreateVectorOfStructs64ITtTpTyENS_6VectorETpTnRiJE10LeafStructEENS_8Offset64IT_IJPKT1_EEEERKNSt3__16vectorIS8_NSD_9allocatorIS8_EEEE Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE23CreateVectorOfStructs64ITtTpTyENS_8Vector64ETpTnRiJE10LeafStructEENS_8Offset64IT_IJPKT1_EEEERKNSt3__16vectorIS8_NSD_9allocatorIS8_EEEE |
1006 | | |
1007 | | /// @brief Serialize an array of native structs into a FlatBuffer `vector`. |
1008 | | /// @tparam T The data type of the struct array elements. |
1009 | | /// @tparam S The data type of the native struct array elements. |
1010 | | /// @param[in] v A pointer to the array of type `S` to serialize into the |
1011 | | /// buffer as a `vector`. |
1012 | | /// @param[in] len The number of elements to serialize. |
1013 | | /// @param[in] pack_func Pointer to a function to convert the native struct |
1014 | | /// to the FlatBuffer struct. |
1015 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1016 | | /// where the vector is stored. |
1017 | | template <typename T, typename S> |
1018 | | Offset<Vector<const T*>> CreateVectorOfNativeStructs( |
1019 | | const S* v, size_t len, T (*const pack_func)(const S&)) { |
1020 | | FLATBUFFERS_ASSERT(pack_func); |
1021 | | auto structs = StartVectorOfStructs<T>(len); |
1022 | | for (size_t i = 0; i < len; i++) { |
1023 | | structs[i] = pack_func(v[i]); |
1024 | | } |
1025 | | return EndVectorOfStructs<T>(len); |
1026 | | } |
1027 | | |
1028 | | /// @brief Serialize an array of native structs into a FlatBuffer `vector`. |
1029 | | /// @tparam T The data type of the struct array elements. |
1030 | | /// @tparam S The data type of the native struct array elements. |
1031 | | /// @param[in] v A pointer to the array of type `S` to serialize into the |
1032 | | /// buffer as a `vector`. |
1033 | | /// @param[in] len The number of elements to serialize. |
1034 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1035 | | /// where the vector is stored. |
1036 | | template <typename T, typename S> |
1037 | | Offset<Vector<const T*>> CreateVectorOfNativeStructs(const S* v, size_t len) { |
1038 | | extern T Pack(const S&); |
1039 | | return CreateVectorOfNativeStructs(v, len, Pack); |
1040 | | } |
1041 | | |
1042 | | /// @brief Serialize a `std::vector` of native structs into a FlatBuffer |
1043 | | /// `vector`. |
1044 | | /// @tparam T The data type of the `std::vector` struct elements. |
1045 | | /// @tparam S The data type of the `std::vector` native struct elements. |
1046 | | /// @param[in] v A const reference to the `std::vector` of structs to |
1047 | | /// serialize into the buffer as a `vector`. |
1048 | | /// @param[in] pack_func Pointer to a function to convert the native struct |
1049 | | /// to the FlatBuffer struct. |
1050 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1051 | | /// where the vector is stored. |
1052 | | template <typename T, typename S, typename Alloc = std::allocator<T>> |
1053 | | Offset<Vector<const T*>> CreateVectorOfNativeStructs( |
1054 | | const std::vector<S, Alloc>& v, T (*const pack_func)(const S&)) { |
1055 | | return CreateVectorOfNativeStructs<T, S>(data(v), v.size(), pack_func); |
1056 | | } |
1057 | | |
1058 | | /// @brief Serialize a `std::vector` of native structs into a FlatBuffer |
1059 | | /// `vector`. |
1060 | | /// @tparam T The data type of the `std::vector` struct elements. |
1061 | | /// @tparam S The data type of the `std::vector` native struct elements. |
1062 | | /// @param[in] v A const reference to the `std::vector` of structs to |
1063 | | /// serialize into the buffer as a `vector`. |
1064 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1065 | | /// where the vector is stored. |
1066 | | template <typename T, typename S, typename Alloc = std::allocator<S>> |
1067 | | Offset<Vector<const T*>> CreateVectorOfNativeStructs( |
1068 | | const std::vector<S, Alloc>& v) { |
1069 | | return CreateVectorOfNativeStructs<T, S>(data(v), v.size()); |
1070 | | } |
1071 | | |
1072 | | /// @cond FLATBUFFERS_INTERNAL |
1073 | | template <typename T> |
1074 | | struct StructKeyComparator { |
1075 | 0 | bool operator()(const T& a, const T& b) const { |
1076 | 0 | return a.KeyCompareLessThan(&b); |
1077 | 0 | } |
1078 | | }; |
1079 | | /// @endcond |
1080 | | |
1081 | | /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector` |
1082 | | /// in sorted order. |
1083 | | /// @tparam T The data type of the `std::vector` struct elements. |
1084 | | /// @param[in] v A const reference to the `std::vector` of structs to |
1085 | | /// serialize into the buffer as a `vector`. |
1086 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1087 | | /// where the vector is stored. |
1088 | | template <typename T, typename Alloc = std::allocator<T>> |
1089 | | Offset<Vector<const T*>> CreateVectorOfSortedStructs( |
1090 | 0 | std::vector<T, Alloc>* v) { |
1091 | 0 | return CreateVectorOfSortedStructs(data(*v), v->size()); |
1092 | 0 | } |
1093 | | |
1094 | | /// @brief Serialize a `std::vector` of native structs into a FlatBuffer |
1095 | | /// `vector` in sorted order. |
1096 | | /// @tparam T The data type of the `std::vector` struct elements. |
1097 | | /// @tparam S The data type of the `std::vector` native struct elements. |
1098 | | /// @param[in] v A const reference to the `std::vector` of structs to |
1099 | | /// serialize into the buffer as a `vector`. |
1100 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1101 | | /// where the vector is stored. |
1102 | | template <typename T, typename S, typename Alloc = std::allocator<T>> |
1103 | | Offset<Vector<const T*>> CreateVectorOfSortedNativeStructs( |
1104 | | std::vector<S, Alloc>* v) { |
1105 | | return CreateVectorOfSortedNativeStructs<T, S>(data(*v), v->size()); |
1106 | | } |
1107 | | |
1108 | | /// @brief Serialize an array of structs into a FlatBuffer `vector` in sorted |
1109 | | /// order. |
1110 | | /// @tparam T The data type of the struct array elements. |
1111 | | /// @param[in] v A pointer to the array of type `T` to serialize into the |
1112 | | /// buffer as a `vector`. |
1113 | | /// @param[in] len The number of elements to serialize. |
1114 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1115 | | /// where the vector is stored. |
1116 | | template <typename T> |
1117 | 0 | Offset<Vector<const T*>> CreateVectorOfSortedStructs(T* v, size_t len) { |
1118 | 0 | std::stable_sort(v, v + len, StructKeyComparator<T>()); |
1119 | 0 | return CreateVectorOfStructs(v, len); |
1120 | 0 | } |
1121 | | |
1122 | | /// @brief Serialize an array of native structs into a FlatBuffer `vector` in |
1123 | | /// sorted order. |
1124 | | /// @tparam T The data type of the struct array elements. |
1125 | | /// @tparam S The data type of the native struct array elements. |
1126 | | /// @param[in] v A pointer to the array of type `S` to serialize into the |
1127 | | /// buffer as a `vector`. |
1128 | | /// @param[in] len The number of elements to serialize. |
1129 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1130 | | /// where the vector is stored. |
1131 | | template <typename T, typename S> |
1132 | | Offset<Vector<const T*>> CreateVectorOfSortedNativeStructs(S* v, size_t len) { |
1133 | | extern T Pack(const S&); |
1134 | | auto structs = StartVectorOfStructs<T>(len); |
1135 | | for (size_t i = 0; i < len; i++) { |
1136 | | structs[i] = Pack(v[i]); |
1137 | | } |
1138 | | std::stable_sort(structs, structs + len, StructKeyComparator<T>()); |
1139 | | return EndVectorOfStructs<T>(len); |
1140 | | } |
1141 | | |
1142 | | /// @cond FLATBUFFERS_INTERNAL |
1143 | | template <typename T> |
1144 | | struct TableKeyComparator { |
1145 | 40.8k | explicit TableKeyComparator(vector_downward<SizeT>& buf) : buf_(buf) {}flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::KeyValue>::TableKeyComparator(flatbuffers::vector_downward<unsigned int>&) Line | Count | Source | 1145 | 183 | explicit TableKeyComparator(vector_downward<SizeT>& buf) : buf_(buf) {} |
flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Field>::TableKeyComparator(flatbuffers::vector_downward<unsigned int>&) Line | Count | Source | 1145 | 29.3k | explicit TableKeyComparator(vector_downward<SizeT>& buf) : buf_(buf) {} |
flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Object>::TableKeyComparator(flatbuffers::vector_downward<unsigned int>&) Line | Count | Source | 1145 | 3.78k | explicit TableKeyComparator(vector_downward<SizeT>& buf) : buf_(buf) {} |
flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Enum>::TableKeyComparator(flatbuffers::vector_downward<unsigned int>&) Line | Count | Source | 1145 | 3.78k | explicit TableKeyComparator(vector_downward<SizeT>& buf) : buf_(buf) {} |
flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Service>::TableKeyComparator(flatbuffers::vector_downward<unsigned int>&) Line | Count | Source | 1145 | 3.78k | explicit TableKeyComparator(vector_downward<SizeT>& buf) : buf_(buf) {} |
Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::SchemaFile>::TableKeyComparator(flatbuffers::vector_downward<unsigned int>&) |
1146 | 0 | TableKeyComparator(const TableKeyComparator& other) : buf_(other.buf_) {}Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::KeyValue>::TableKeyComparator(flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::KeyValue> const&) Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Field>::TableKeyComparator(flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Field> const&) Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Object>::TableKeyComparator(flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Object> const&) Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Enum>::TableKeyComparator(flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Enum> const&) Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Service>::TableKeyComparator(flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Service> const&) Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::SchemaFile>::TableKeyComparator(flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::SchemaFile> const&) |
1147 | 1.12M | bool operator()(const Offset<T>& a, const Offset<T>& b) const { |
1148 | 1.12M | auto table_a = reinterpret_cast<T*>(buf_.data_at(a.o)); |
1149 | 1.12M | auto table_b = reinterpret_cast<T*>(buf_.data_at(b.o)); |
1150 | 1.12M | return table_a->KeyCompareLessThan(table_b); |
1151 | 1.12M | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<MyGame::Example::Monster>::operator()(flatbuffers::Offset<MyGame::Example::Monster> const&, flatbuffers::Offset<MyGame::Example::Monster> const&) const Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<MyGame::Example::Referrable>::operator()(flatbuffers::Offset<MyGame::Example::Referrable> const&, flatbuffers::Offset<MyGame::Example::Referrable> const&) const Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<MyGame::Example::Stat>::operator()(flatbuffers::Offset<MyGame::Example::Stat> const&, flatbuffers::Offset<MyGame::Example::Stat> const&) const Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::KeyValue>::operator()(flatbuffers::Offset<reflection::KeyValue> const&, flatbuffers::Offset<reflection::KeyValue> const&) const Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::EnumVal>::operator()(flatbuffers::Offset<reflection::EnumVal> const&, flatbuffers::Offset<reflection::EnumVal> const&) const Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::RPCCall>::operator()(flatbuffers::Offset<reflection::RPCCall> const&, flatbuffers::Offset<reflection::RPCCall> const&) const Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::SchemaFile>::operator()(flatbuffers::Offset<reflection::SchemaFile> const&, flatbuffers::Offset<reflection::SchemaFile> const&) const flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Field>::operator()(flatbuffers::Offset<reflection::Field> const&, flatbuffers::Offset<reflection::Field> const&) const Line | Count | Source | 1147 | 75.9k | bool operator()(const Offset<T>& a, const Offset<T>& b) const { | 1148 | 75.9k | auto table_a = reinterpret_cast<T*>(buf_.data_at(a.o)); | 1149 | 75.9k | auto table_b = reinterpret_cast<T*>(buf_.data_at(b.o)); | 1150 | 75.9k | return table_a->KeyCompareLessThan(table_b); | 1151 | 75.9k | } |
flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Object>::operator()(flatbuffers::Offset<reflection::Object> const&, flatbuffers::Offset<reflection::Object> const&) const Line | Count | Source | 1147 | 263k | bool operator()(const Offset<T>& a, const Offset<T>& b) const { | 1148 | 263k | auto table_a = reinterpret_cast<T*>(buf_.data_at(a.o)); | 1149 | 263k | auto table_b = reinterpret_cast<T*>(buf_.data_at(b.o)); | 1150 | 263k | return table_a->KeyCompareLessThan(table_b); | 1151 | 263k | } |
flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Enum>::operator()(flatbuffers::Offset<reflection::Enum> const&, flatbuffers::Offset<reflection::Enum> const&) const Line | Count | Source | 1147 | 779k | bool operator()(const Offset<T>& a, const Offset<T>& b) const { | 1148 | 779k | auto table_a = reinterpret_cast<T*>(buf_.data_at(a.o)); | 1149 | 779k | auto table_b = reinterpret_cast<T*>(buf_.data_at(b.o)); | 1150 | 779k | return table_a->KeyCompareLessThan(table_b); | 1151 | 779k | } |
flatbuffers::FlatBufferBuilderImpl<false>::TableKeyComparator<reflection::Service>::operator()(flatbuffers::Offset<reflection::Service> const&, flatbuffers::Offset<reflection::Service> const&) const Line | Count | Source | 1147 | 2.90k | bool operator()(const Offset<T>& a, const Offset<T>& b) const { | 1148 | 2.90k | auto table_a = reinterpret_cast<T*>(buf_.data_at(a.o)); | 1149 | 2.90k | auto table_b = reinterpret_cast<T*>(buf_.data_at(b.o)); | 1150 | 2.90k | return table_a->KeyCompareLessThan(table_b); | 1151 | 2.90k | } |
|
1152 | | vector_downward<SizeT>& buf_; |
1153 | | |
1154 | | private: |
1155 | | FLATBUFFERS_DELETE_FUNC( |
1156 | | TableKeyComparator& operator=(const TableKeyComparator& other)); |
1157 | | }; |
1158 | | /// @endcond |
1159 | | |
1160 | | /// @brief Serialize an array of `table` offsets as a `vector` in the buffer |
1161 | | /// in sorted order. |
1162 | | /// @tparam T The data type that the offset refers to. |
1163 | | /// @param[in] v An array of type `Offset<T>` that contains the `table` |
1164 | | /// offsets to store in the buffer in sorted order. |
1165 | | /// @param[in] len The number of elements to store in the `vector`. |
1166 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1167 | | /// where the vector is stored. |
1168 | | template <typename T> |
1169 | | Offset<Vector<Offset<T>>> CreateVectorOfSortedTables(Offset<T>* v, |
1170 | 40.8k | size_t len) { |
1171 | 40.8k | std::stable_sort(v, v + len, TableKeyComparator<T>(buf_)); |
1172 | 40.8k | return CreateVector(v, len); |
1173 | 40.8k | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<MyGame::Example::Monster>(flatbuffers::Offset<MyGame::Example::Monster>*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<MyGame::Example::Referrable>(flatbuffers::Offset<MyGame::Example::Referrable>*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<MyGame::Example::Stat>(flatbuffers::Offset<MyGame::Example::Stat>*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::EnumVal>(flatbuffers::Offset<reflection::EnumVal>*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::RPCCall>(flatbuffers::Offset<reflection::RPCCall>*, unsigned long) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::SchemaFile>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::SchemaFile>(flatbuffers::Offset<reflection::SchemaFile>*, unsigned long) flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::KeyValue>(flatbuffers::Offset<reflection::KeyValue>*, unsigned long) Line | Count | Source | 1170 | 183 | size_t len) { | 1171 | 183 | std::stable_sort(v, v + len, TableKeyComparator<T>(buf_)); | 1172 | 183 | return CreateVector(v, len); | 1173 | 183 | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Field>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Field>(flatbuffers::Offset<reflection::Field>*, unsigned long) Line | Count | Source | 1170 | 29.3k | size_t len) { | 1171 | 29.3k | std::stable_sort(v, v + len, TableKeyComparator<T>(buf_)); | 1172 | 29.3k | return CreateVector(v, len); | 1173 | 29.3k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Object>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Object>(flatbuffers::Offset<reflection::Object>*, unsigned long) Line | Count | Source | 1170 | 3.78k | size_t len) { | 1171 | 3.78k | std::stable_sort(v, v + len, TableKeyComparator<T>(buf_)); | 1172 | 3.78k | return CreateVector(v, len); | 1173 | 3.78k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Enum>(flatbuffers::Offset<reflection::Enum>*, unsigned long) Line | Count | Source | 1170 | 3.78k | size_t len) { | 1171 | 3.78k | std::stable_sort(v, v + len, TableKeyComparator<T>(buf_)); | 1172 | 3.78k | return CreateVector(v, len); | 1173 | 3.78k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Service>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Service>(flatbuffers::Offset<reflection::Service>*, unsigned long) Line | Count | Source | 1170 | 3.78k | size_t len) { | 1171 | 3.78k | std::stable_sort(v, v + len, TableKeyComparator<T>(buf_)); | 1172 | 3.78k | return CreateVector(v, len); | 1173 | 3.78k | } |
|
1174 | | |
1175 | | /// @brief Serialize an array of `table` offsets as a `vector` in the buffer |
1176 | | /// in sorted order. |
1177 | | /// @tparam T The data type that the offset refers to. |
1178 | | /// @param[in] v An array of type `Offset<T>` that contains the `table` |
1179 | | /// offsets to store in the buffer in sorted order. |
1180 | | /// @return Returns a typed `Offset` into the serialized data indicating |
1181 | | /// where the vector is stored. |
1182 | | template <typename T, typename Alloc = std::allocator<T>> |
1183 | | Offset<Vector<Offset<T>>> CreateVectorOfSortedTables( |
1184 | 40.8k | std::vector<Offset<T>, Alloc>* v) { |
1185 | 40.8k | return CreateVectorOfSortedTables(data(*v), v->size()); |
1186 | 40.8k | } Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<MyGame::Example::Monster, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Monster>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Monster> > >*) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<MyGame::Example::Referrable, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Referrable>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Referrable> > >*) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<MyGame::Example::Stat, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > >(std::__1::vector<flatbuffers::Offset<MyGame::Example::Stat>, std::__1::allocator<flatbuffers::Offset<MyGame::Example::Stat> > >*) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::EnumVal, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > >(std::__1::vector<flatbuffers::Offset<reflection::EnumVal>, std::__1::allocator<flatbuffers::Offset<reflection::EnumVal> > >*) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::RPCCall, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > >(std::__1::vector<flatbuffers::Offset<reflection::RPCCall>, std::__1::allocator<flatbuffers::Offset<reflection::RPCCall> > >*) Unexecuted instantiation: flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::SchemaFile>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::SchemaFile, std::__1::allocator<flatbuffers::Offset<reflection::SchemaFile> > >(std::__1::vector<flatbuffers::Offset<reflection::SchemaFile>, std::__1::allocator<flatbuffers::Offset<reflection::SchemaFile> > >*) flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::KeyValue, std::__1::allocator<flatbuffers::Offset<reflection::KeyValue> > >(std::__1::vector<flatbuffers::Offset<reflection::KeyValue>, std::__1::allocator<flatbuffers::Offset<reflection::KeyValue> > >*) Line | Count | Source | 1184 | 183 | std::vector<Offset<T>, Alloc>* v) { | 1185 | 183 | return CreateVectorOfSortedTables(data(*v), v->size()); | 1186 | 183 | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Field>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Field, std::__1::allocator<flatbuffers::Offset<reflection::Field> > >(std::__1::vector<flatbuffers::Offset<reflection::Field>, std::__1::allocator<flatbuffers::Offset<reflection::Field> > >*) Line | Count | Source | 1184 | 29.3k | std::vector<Offset<T>, Alloc>* v) { | 1185 | 29.3k | return CreateVectorOfSortedTables(data(*v), v->size()); | 1186 | 29.3k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Object>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Object, std::__1::allocator<flatbuffers::Offset<reflection::Object> > >(std::__1::vector<flatbuffers::Offset<reflection::Object>, std::__1::allocator<flatbuffers::Offset<reflection::Object> > >*) Line | Count | Source | 1184 | 3.78k | std::vector<Offset<T>, Alloc>* v) { | 1185 | 3.78k | return CreateVectorOfSortedTables(data(*v), v->size()); | 1186 | 3.78k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Enum, std::__1::allocator<flatbuffers::Offset<reflection::Enum> > >(std::__1::vector<flatbuffers::Offset<reflection::Enum>, std::__1::allocator<flatbuffers::Offset<reflection::Enum> > >*) Line | Count | Source | 1184 | 3.78k | std::vector<Offset<T>, Alloc>* v) { | 1185 | 3.78k | return CreateVectorOfSortedTables(data(*v), v->size()); | 1186 | 3.78k | } |
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<reflection::Service>, unsigned int> > flatbuffers::FlatBufferBuilderImpl<false>::CreateVectorOfSortedTables<reflection::Service, std::__1::allocator<flatbuffers::Offset<reflection::Service> > >(std::__1::vector<flatbuffers::Offset<reflection::Service>, std::__1::allocator<flatbuffers::Offset<reflection::Service> > >*) Line | Count | Source | 1184 | 3.78k | std::vector<Offset<T>, Alloc>* v) { | 1185 | 3.78k | return CreateVectorOfSortedTables(data(*v), v->size()); | 1186 | 3.78k | } |
|
1187 | | |
1188 | | /// @brief Specialized version of `CreateVector` for non-copying use cases. |
1189 | | /// Write the data any time later to the returned buffer pointer `buf`. |
1190 | | /// @param[in] len The number of elements to store in the `vector`. |
1191 | | /// @param[in] elemsize The size of each element in the `vector`. |
1192 | | /// @param[out] buf A pointer to a `uint8_t` pointer that can be |
1193 | | /// written to at a later time to serialize the data into a `vector` |
1194 | | /// in the buffer. |
1195 | | uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, |
1196 | | size_t alignment, uint8_t** buf) { |
1197 | | NotNested(); |
1198 | | StartVector(len, elemsize, alignment); |
1199 | | buf_.make_space(len * elemsize); |
1200 | | const uoffset_t vec_start = GetSizeRelative32BitRegion(); |
1201 | | auto vec_end = EndVector(len); |
1202 | | *buf = buf_.data_at(vec_start); |
1203 | | return vec_end; |
1204 | | } |
1205 | | |
1206 | | FLATBUFFERS_ATTRIBUTE([[deprecated("call the version above instead")]]) |
1207 | | uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, |
1208 | | uint8_t** buf) { |
1209 | | return CreateUninitializedVector(len, elemsize, elemsize, buf); |
1210 | | } |
1211 | | |
1212 | | /// @brief Specialized version of `CreateVector` for non-copying use cases. |
1213 | | /// Write the data any time later to the returned buffer pointer `buf`. |
1214 | | /// @tparam T The data type of the data that will be stored in the buffer |
1215 | | /// as a `vector`. |
1216 | | /// @param[in] len The number of elements to store in the `vector`. |
1217 | | /// @param[out] buf A pointer to a pointer of type `T` that can be |
1218 | | /// written to at a later time to serialize the data into a `vector` |
1219 | | /// in the buffer. |
1220 | | template <typename T> |
1221 | | Offset<Vector<T>> CreateUninitializedVector(size_t len, T** buf) { |
1222 | | AssertScalarT<T>(); |
1223 | | return CreateUninitializedVector(len, sizeof(T), AlignOf<T>(), |
1224 | | reinterpret_cast<uint8_t**>(buf)); |
1225 | | } |
1226 | | |
1227 | | template <typename T> |
1228 | | Offset<Vector<const T*>> CreateUninitializedVectorOfStructs(size_t len, |
1229 | | T** buf) { |
1230 | | return CreateUninitializedVector(len, sizeof(T), AlignOf<T>(), |
1231 | | reinterpret_cast<uint8_t**>(buf)); |
1232 | | } |
1233 | | |
1234 | | // @brief Create a vector of scalar type T given as input a vector of scalar |
1235 | | // type U, useful with e.g. pre "enum class" enums, or any existing scalar |
1236 | | // data of the wrong type. |
1237 | | template <typename T, typename U> |
1238 | | Offset<Vector<T>> CreateVectorScalarCast(const U* v, size_t len) { |
1239 | | AssertScalarT<T>(); |
1240 | | AssertScalarT<U>(); |
1241 | | StartVector<T>(len); |
1242 | | for (auto i = len; i > 0;) { |
1243 | | PushElement(static_cast<T>(v[--i])); |
1244 | | } |
1245 | | return Offset<Vector<T>>(EndVector(len)); |
1246 | | } |
1247 | | |
1248 | | /// @brief Write a struct by itself, typically to be part of a union. |
1249 | | template <typename T> |
1250 | | Offset<const T*> CreateStruct(const T& structobj) { |
1251 | | NotNested(); |
1252 | | Align(AlignOf<T>()); |
1253 | | buf_.push_small(structobj); |
1254 | | return Offset<const T*>( |
1255 | | CalculateOffset<typename Offset<const T*>::offset_type>()); |
1256 | | } |
1257 | | |
1258 | | /// @brief Finish serializing a buffer by writing the root offset. |
1259 | | /// @param[in] file_identifier If a `file_identifier` is given, the buffer |
1260 | | /// will be prefixed with a standard FlatBuffers file header. |
1261 | | template <typename T> |
1262 | 303k | void Finish(Offset<T> root, const char* file_identifier = nullptr) { |
1263 | 303k | Finish(root.o, file_identifier, false); |
1264 | 303k | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::Finish<MyGame::Example::Monster>(flatbuffers::Offset<MyGame::Example::Monster>, char const*) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::Finish<RootTable>(flatbuffers::Offset<RootTable>, char const*) void flatbuffers::FlatBufferBuilderImpl<false>::Finish<reflection::Schema>(flatbuffers::Offset<reflection::Schema>, char const*) Line | Count | Source | 1262 | 3.78k | void Finish(Offset<T> root, const char* file_identifier = nullptr) { | 1263 | 3.78k | Finish(root.o, file_identifier, false); | 1264 | 3.78k | } |
void flatbuffers::FlatBufferBuilderImpl<false>::Finish<flatbuffers::Table>(flatbuffers::Offset<flatbuffers::Table>, char const*) Line | Count | Source | 1262 | 299k | void Finish(Offset<T> root, const char* file_identifier = nullptr) { | 1263 | 299k | Finish(root.o, file_identifier, false); | 1264 | 299k | } |
|
1265 | | |
1266 | | /// @brief Finish a buffer with a 32 bit size field pre-fixed (size of the |
1267 | | /// buffer following the size field). These buffers are NOT compatible |
1268 | | /// with standard buffers created by Finish, i.e. you can't call GetRoot |
1269 | | /// on them, you have to use GetSizePrefixedRoot instead. |
1270 | | /// All >32 bit quantities in this buffer will be aligned when the whole |
1271 | | /// size pre-fixed buffer is aligned. |
1272 | | /// These kinds of buffers are useful for creating a stream of FlatBuffers. |
1273 | | template <typename T> |
1274 | | void FinishSizePrefixed(Offset<T> root, |
1275 | 0 | const char* file_identifier = nullptr) { |
1276 | 0 | Finish(root.o, file_identifier, true); |
1277 | 0 | } Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::FinishSizePrefixed<MyGame::Example::Monster>(flatbuffers::Offset<MyGame::Example::Monster>, char const*) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<true>::FinishSizePrefixed<RootTable>(flatbuffers::Offset<RootTable>, char const*) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::FinishSizePrefixed<reflection::Schema>(flatbuffers::Offset<reflection::Schema>, char const*) Unexecuted instantiation: void flatbuffers::FlatBufferBuilderImpl<false>::FinishSizePrefixed<flatbuffers::Table>(flatbuffers::Offset<flatbuffers::Table>, char const*) |
1278 | | |
1279 | | void SwapBufAllocator(FlatBufferBuilderImpl& other) { |
1280 | | buf_.swap_allocator(other.buf_); |
1281 | | } |
1282 | | |
1283 | | /// @brief The length of a FlatBuffer file header. |
1284 | | static const size_t kFileIdentifierLength = |
1285 | | ::flatbuffers::kFileIdentifierLength; |
1286 | | |
1287 | | protected: |
1288 | | // You shouldn't really be copying instances of this class. |
1289 | | FlatBufferBuilderImpl(const FlatBufferBuilderImpl&); |
1290 | | FlatBufferBuilderImpl& operator=(const FlatBufferBuilderImpl&); |
1291 | | |
1292 | 303k | void Finish(uoffset_t root, const char* file_identifier, bool size_prefix) { |
1293 | | // A buffer can only be finished once. To reuse a builder use `clear()`. |
1294 | 303k | FLATBUFFERS_ASSERT(!finished); |
1295 | | |
1296 | 303k | NotNested(); |
1297 | 303k | buf_.clear_scratch(); |
1298 | | |
1299 | 303k | const size_t prefix_size = size_prefix ? sizeof(SizeT) : 0; |
1300 | | // Make sure we track the alignment of the size prefix. |
1301 | 303k | TrackMinAlign(prefix_size); |
1302 | | |
1303 | 303k | const size_t root_offset_size = sizeof(uoffset_t); |
1304 | 303k | const size_t file_id_size = file_identifier ? kFileIdentifierLength : 0; |
1305 | | |
1306 | | // This will cause the whole buffer to be aligned. |
1307 | 303k | PreAlign(prefix_size + root_offset_size + file_id_size, minalign_); |
1308 | | |
1309 | 303k | if (file_identifier) { |
1310 | 10.6k | FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength); |
1311 | 10.6k | PushBytes(reinterpret_cast<const uint8_t*>(file_identifier), |
1312 | 10.6k | kFileIdentifierLength); |
1313 | 10.6k | } |
1314 | 303k | PushElement(ReferTo(root)); // Location of root. |
1315 | 303k | if (size_prefix) { |
1316 | 0 | PushElement(GetSize()); |
1317 | 0 | } |
1318 | 303k | finished = true; |
1319 | 303k | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::Finish(unsigned int, char const*, bool) flatbuffers::FlatBufferBuilderImpl<false>::Finish(unsigned int, char const*, bool) Line | Count | Source | 1292 | 303k | void Finish(uoffset_t root, const char* file_identifier, bool size_prefix) { | 1293 | | // A buffer can only be finished once. To reuse a builder use `clear()`. | 1294 | 303k | FLATBUFFERS_ASSERT(!finished); | 1295 | | | 1296 | 303k | NotNested(); | 1297 | 303k | buf_.clear_scratch(); | 1298 | | | 1299 | 303k | const size_t prefix_size = size_prefix ? sizeof(SizeT) : 0; | 1300 | | // Make sure we track the alignment of the size prefix. | 1301 | 303k | TrackMinAlign(prefix_size); | 1302 | | | 1303 | 303k | const size_t root_offset_size = sizeof(uoffset_t); | 1304 | 303k | const size_t file_id_size = file_identifier ? kFileIdentifierLength : 0; | 1305 | | | 1306 | | // This will cause the whole buffer to be aligned. | 1307 | 303k | PreAlign(prefix_size + root_offset_size + file_id_size, minalign_); | 1308 | | | 1309 | 303k | if (file_identifier) { | 1310 | 10.6k | FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength); | 1311 | 10.6k | PushBytes(reinterpret_cast<const uint8_t*>(file_identifier), | 1312 | 10.6k | kFileIdentifierLength); | 1313 | 10.6k | } | 1314 | 303k | PushElement(ReferTo(root)); // Location of root. | 1315 | 303k | if (size_prefix) { | 1316 | 0 | PushElement(GetSize()); | 1317 | 0 | } | 1318 | 303k | finished = true; | 1319 | 303k | } |
|
1320 | | |
1321 | | struct FieldLoc { |
1322 | | uoffset_t off; |
1323 | | voffset_t id; |
1324 | | }; |
1325 | | |
1326 | | vector_downward<SizeT> buf_; |
1327 | | |
1328 | | // Accumulating offsets of table members while it is being built. |
1329 | | // We store these in the scratch pad of buf_, after the vtable offsets. |
1330 | | uoffset_t num_field_loc; |
1331 | | // Track how much of the vtable is in use, so we can output the most compact |
1332 | | // possible vtable. |
1333 | | voffset_t max_voffset_; |
1334 | | |
1335 | | // This is the length of the 64-bit region of the buffer. The buffer supports |
1336 | | // 64-bit offsets by forcing serialization of those elements in the "tail" |
1337 | | // region of the buffer (i.e. "64-bit region"). To properly keep track of |
1338 | | // offsets that are referenced from the tail of the buffer to not overflow |
1339 | | // their size (e.g. Offset is a uint32_t type), the boundary of the 32-/64-bit |
1340 | | // regions must be tracked. |
1341 | | // |
1342 | | // [ Complete FlatBuffer ] |
1343 | | // [32-bit region][64-bit region] |
1344 | | // ^ ^ |
1345 | | // | Tail of the buffer. |
1346 | | // | |
1347 | | // Tail of the 32-bit region of the buffer. |
1348 | | // |
1349 | | // This keeps track of the size of the 64-bit region so that the tail of the |
1350 | | // 32-bit region can be calculated as `GetSize() - length_of_64_bit_region_`. |
1351 | | // |
1352 | | // This will remain 0 if no 64-bit offset types are added to the buffer. |
1353 | | size_t length_of_64_bit_region_; |
1354 | | |
1355 | | // Ensure objects are not nested. |
1356 | | bool nested; |
1357 | | |
1358 | | // Ensure the buffer is finished before it is being accessed. |
1359 | | bool finished; |
1360 | | |
1361 | | size_t minalign_; |
1362 | | |
1363 | | bool force_defaults_; // Serialize values equal to their defaults anyway. |
1364 | | |
1365 | | bool dedup_vtables_; |
1366 | | |
1367 | | struct StringOffsetCompare { |
1368 | | explicit StringOffsetCompare(const vector_downward<SizeT>& buf) |
1369 | 3.80k | : buf_(&buf) {} |
1370 | 167k | bool operator()(const Offset<String>& a, const Offset<String>& b) const { |
1371 | 167k | auto stra = reinterpret_cast<const String*>(buf_->data_at(a.o)); |
1372 | 167k | auto strb = reinterpret_cast<const String*>(buf_->data_at(b.o)); |
1373 | 167k | return StringLessThan(stra->data(), stra->size(), strb->data(), |
1374 | 167k | strb->size()); |
1375 | 167k | } |
1376 | | const vector_downward<SizeT>* buf_; |
1377 | | }; |
1378 | | |
1379 | | // For use with CreateSharedString. Instantiated on first use only. |
1380 | | typedef std::set<Offset<String>, StringOffsetCompare> StringOffsetMap; |
1381 | | StringOffsetMap* string_pool; |
1382 | | |
1383 | | private: |
1384 | 0 | void CanAddOffset64() { |
1385 | 0 | // If you hit this assertion, you are attempting to add a 64-bit offset to |
1386 | 0 | // a 32-bit only builder. This is because the builder has overloads that |
1387 | 0 | // differ only on the offset size returned: e.g.: |
1388 | 0 | // |
1389 | 0 | // FlatBufferBuilder builder; |
1390 | 0 | // Offset64<String> string_offset = builder.CreateString<Offset64>(); |
1391 | 0 | // |
1392 | 0 | // Either use a 64-bit aware builder, or don't try to create an Offset64 |
1393 | 0 | // return type. |
1394 | 0 | // |
1395 | 0 | // TODO(derekbailey): we can probably do more enable_if to avoid this |
1396 | 0 | // looking like its possible to the user. |
1397 | 0 | static_assert(Is64Aware, "cannot add 64-bit offset to a 32-bit builder"); |
1398 | 0 |
|
1399 | 0 | // If you hit this assertion, you are attempting to add an 64-bit offset |
1400 | 0 | // item after already serializing a 32-bit item. All 64-bit offsets have to |
1401 | 0 | // added to the tail of the buffer before any 32-bit items can be added. |
1402 | 0 | // Otherwise some items might not be addressable due to the maximum range of |
1403 | 0 | // the 32-bit offset. |
1404 | 0 | FLATBUFFERS_ASSERT(GetSize() == length_of_64_bit_region_); |
1405 | 0 | } |
1406 | | |
1407 | | /// @brief Store a string in the buffer, which can contain any binary data. |
1408 | | /// @param[in] str A const char pointer to the data to be stored as a string. |
1409 | | /// @param[in] len The number of bytes that should be stored from `str`. |
1410 | | /// @return Returns the offset in the buffer where the string starts. |
1411 | 383k | void CreateStringImpl(const char* str, size_t len) { |
1412 | 383k | NotNested(); |
1413 | 383k | PreAlign<uoffset_t>(len + 1); // Always 0-terminated. |
1414 | 383k | buf_.fill(1); |
1415 | 383k | PushBytes(reinterpret_cast<const uint8_t*>(str), len); |
1416 | 383k | PushElement(static_cast<uoffset_t>(len)); |
1417 | 383k | } Unexecuted instantiation: flatbuffers::FlatBufferBuilderImpl<true>::CreateStringImpl(char const*, unsigned long) flatbuffers::FlatBufferBuilderImpl<false>::CreateStringImpl(char const*, unsigned long) Line | Count | Source | 1411 | 383k | void CreateStringImpl(const char* str, size_t len) { | 1412 | 383k | NotNested(); | 1413 | 383k | PreAlign<uoffset_t>(len + 1); // Always 0-terminated. | 1414 | 383k | buf_.fill(1); | 1415 | 383k | PushBytes(reinterpret_cast<const uint8_t*>(str), len); | 1416 | 383k | PushElement(static_cast<uoffset_t>(len)); | 1417 | 383k | } |
|
1418 | | |
1419 | | // Allocates space for a vector of structures. |
1420 | | // Must be completed with EndVectorOfStructs(). |
1421 | | template <typename T, template <typename> class OffsetT = Offset> |
1422 | | T* StartVectorOfStructs(size_t vector_size) { |
1423 | | StartVector<OffsetT>(vector_size, sizeof(T), AlignOf<T>()); |
1424 | | return reinterpret_cast<T*>(buf_.make_space(vector_size * sizeof(T))); |
1425 | | } |
1426 | | |
1427 | | // End the vector of structures in the flatbuffers. |
1428 | | // Vector should have previously be started with StartVectorOfStructs(). |
1429 | | template <typename T, template <typename> class OffsetT = Offset> |
1430 | | OffsetT<Vector<const T*>> EndVectorOfStructs(size_t vector_size) { |
1431 | | return OffsetT<Vector<const T*>>( |
1432 | | EndVector<typename Vector<const T*>::size_type, |
1433 | | typename OffsetT<Vector<const T*>>::offset_type>( |
1434 | | vector_size)); |
1435 | | } |
1436 | | |
1437 | | template <typename T> |
1438 | | typename std::enable_if<std::is_same<T, uoffset_t>::value, T>::type |
1439 | 4.84M | CalculateOffset() { |
1440 | | // Default to the end of the 32-bit region. This may or may not be the end |
1441 | | // of the buffer, depending on if any 64-bit offsets have been added. |
1442 | 4.84M | return GetSizeRelative32BitRegion(); |
1443 | 4.84M | } Unexecuted instantiation: _ZN11flatbuffers21FlatBufferBuilderImplILb1EE15CalculateOffsetIjEENSt3__19enable_ifIXsr3std7is_sameIT_jEE5valueES5_E4typeEv _ZN11flatbuffers21FlatBufferBuilderImplILb0EE15CalculateOffsetIjEENSt3__19enable_ifIXsr3std7is_sameIT_jEE5valueES5_E4typeEv Line | Count | Source | 1439 | 4.84M | CalculateOffset() { | 1440 | | // Default to the end of the 32-bit region. This may or may not be the end | 1441 | | // of the buffer, depending on if any 64-bit offsets have been added. | 1442 | 4.84M | return GetSizeRelative32BitRegion(); | 1443 | 4.84M | } |
|
1444 | | |
1445 | | // Specializations to handle the 64-bit CalculateOffset, which is relative to |
1446 | | // end of the buffer. |
1447 | | template <typename T> |
1448 | | typename std::enable_if<std::is_same<T, uoffset64_t>::value, T>::type |
1449 | 0 | CalculateOffset() { |
1450 | 0 | // This should never be compiled in when not using a 64-bit builder. |
1451 | 0 | static_assert(Is64Aware, "invalid 64-bit offset in 32-bit builder"); |
1452 | 0 |
|
1453 | 0 | // Store how big the 64-bit region of the buffer is, so we can determine |
1454 | 0 | // where the 32/64 bit boundary is. |
1455 | 0 | length_of_64_bit_region_ = GetSize(); |
1456 | 0 |
|
1457 | 0 | return length_of_64_bit_region_; |
1458 | 0 | } |
1459 | | }; |
1460 | | /// @} |
1461 | | |
1462 | | // Hack to `FlatBufferBuilder` mean `FlatBufferBuilder<false>` or |
1463 | | // `FlatBufferBuilder<>`, where the template < > syntax is required. |
1464 | | using FlatBufferBuilder = FlatBufferBuilderImpl<false>; |
1465 | | using FlatBufferBuilder64 = FlatBufferBuilderImpl<true>; |
1466 | | |
1467 | | // These are external due to GCC not allowing them in the class. |
1468 | | // See: https://stackoverflow.com/q/8061456/868247 |
1469 | | template <> |
1470 | | template <> |
1471 | | inline Offset64<String> FlatBufferBuilder64::CreateString(const char* str, |
1472 | 0 | size_t len) { |
1473 | 0 | CanAddOffset64(); |
1474 | 0 | CreateStringImpl(str, len); |
1475 | 0 | return Offset64<String>( |
1476 | 0 | CalculateOffset<typename Offset64<String>::offset_type>()); |
1477 | 0 | } |
1478 | | |
1479 | | // Used to distinguish from real Offsets. |
1480 | | template <typename T = void> |
1481 | | struct EmptyOffset {}; |
1482 | | |
1483 | | // TODO(derekbailey): it would be nice to combine these two methods. |
1484 | | template <> |
1485 | | template <> |
1486 | | inline void FlatBufferBuilder64::StartVector<Offset64, uint32_t>( |
1487 | 0 | size_t len, size_t elemsize, size_t alignment) { |
1488 | 0 | CanAddOffset64(); |
1489 | 0 | StartVector<EmptyOffset, uint32_t>(len, elemsize, alignment); |
1490 | 0 | } |
1491 | | |
1492 | | template <> |
1493 | | template <> |
1494 | | inline void FlatBufferBuilder64::StartVector<Offset64, uint64_t>( |
1495 | 0 | size_t len, size_t elemsize, size_t alignment) { |
1496 | 0 | CanAddOffset64(); |
1497 | 0 | StartVector<EmptyOffset, uint64_t>(len, elemsize, alignment); |
1498 | 0 | } |
1499 | | |
1500 | | /// Helpers to get a typed pointer to objects that are currently being built. |
1501 | | /// @warning Creating new objects will lead to reallocations and invalidates |
1502 | | /// the pointer! |
1503 | | template <typename T> |
1504 | | T* GetMutableTemporaryPointer(FlatBufferBuilder& fbb, Offset<T> offset) { |
1505 | | return reinterpret_cast<T*>(fbb.GetCurrentBufferPointer() + fbb.GetSize() - |
1506 | | offset.o); |
1507 | | } |
1508 | | |
1509 | | template <typename T> |
1510 | | const T* GetTemporaryPointer(const FlatBufferBuilder& fbb, Offset<T> offset) { |
1511 | | return reinterpret_cast<const T*>(fbb.GetCurrentBufferPointer() + |
1512 | | fbb.GetSize() - offset.o); |
1513 | | } |
1514 | | |
1515 | | } // namespace flatbuffers |
1516 | | |
1517 | | #endif // FLATBUFFERS_FLATBUFFER_BUILDER_H_ |