File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,40 @@ provide the following functions to aide in the serialization process:
242
242
}
243
243
```
244
244
245
+ - ` native_type("type") ` (on a table): Tables can also be represented with
246
+ native types. For example, the following schema:
247
+
248
+ ``` cpp
249
+ table Matrix {
250
+ rows: int32;
251
+ columns: int32;
252
+ values: [float];
253
+ }
254
+ ```
255
+
256
+ Could be represented by a user-defined C++ class:
257
+
258
+ ```cpp
259
+ class Matrix { ... }
260
+ ```
261
+
262
+ In this case, the following function declarations are generated by the compiler.
263
+ The user must provide and link the matching function definitions:
264
+
265
+ ``` cpp
266
+ struct Matrix FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
267
+ // ...
268
+ void UnPackTo(
269
+ Native::Matrix * _ o,
270
+ const ::flatbuffers::resolver_function_t * _ resolver = nullptr) const;
271
+ }
272
+
273
+ ::flatbuffers::Offset<Matrix> CreateMatrix(
274
+ ::flatbuffers::FlatBufferBuilder &_fbb,
275
+ const NativeMatrixType *_o,
276
+ const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
277
+ ```
278
+
245
279
Finally, the following top-level attributes:
246
280
247
281
- `native_include("path")` (at file level): Because the `native_type` attribute
@@ -419,7 +453,7 @@ Each root type will have a verification function generated for it,
419
453
e.g. for `Monster`, you can call:
420
454
421
455
```cpp
422
- Verifier verifier (buf, len);
456
+ Verifier verifier(buf, len);
423
457
bool ok = VerifyMonsterBuffer(verifier);
424
458
```
425
459
You can’t perform that action at this time.
0 commit comments