Lines Matching +full:json +full:- +full:buffer
21 compiler (e.g. `flatc -c mygame.fbs`), you can now start using this in
46 *Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
52 schema with the `--cpp` option to `flatc`. Then you can include both FlatBuffers
79 buffer (root object pointers are not the same as `buffer_pointer` \!).
84 std::cout << "hp : " << monster->hp() << std::endl; // '80'
85 std::cout << "mana : " << monster->mana() << std::endl; // default value of '150'
86 std::cout << "name : " << monster->name()->c_str() << std::endl; // "MyMonster"
93 - `shared` (on a field): For string fields, this enables the usage of string
103 (requiring pre-order construction of all data, and making mutation harder).
106 can be used (through `--gen-object-api`) that is able to unpack & pack a
116 // Deserialize from buffer into object.
117 GetMonster(flatbuffer)->UnPackTo(&monsterobj);
128 The following attributes are specific to the object-based API code generation:
130 - `native_inline` (on a field): Because FlatBuffer tables and structs are
131 optionally present in a given buffer, they are best represented as pointers
136 - `native_default("value")` (on a field): For members that are declared
140 - `native_custom_alloc("custom_allocator")` (on a table or struct): When using the
141 object-based API all generated NativeTables that are allocated when unpacking
145 unpacking when using the object-based API.
184 - `native_type("type")` (on a struct): In some cases, a more optimal C++ data
194 generates the following Object-Based API class:
203 However, it can be useful to instead use a user-defined C++ type since it
210 vector2 operator-(vector2 rhs) const { ... }
219 the Object-Based API.
231 - `native_type_pack_name("name")` (on a struct when `native_type` is
246 Finally, the following top-level attributes:
248 - `native_include("path")` (at file level): Because the `native_type` attribute
254 - `force_align`: this attribute may not be respected in the object API,
270 Then, in JSON or however you create these buffers, make sure they use the
279 influence this either globally (using the `--cpp-ptr-type` argument to
284 pointer type specified by the `--cpp-ptr-type` argument to `flatc` from a
290 influence this either globally (using the `--cpp-str-type` argument to
297 string type. This behavior impedes efficient and zero-copy construction of
298 custom string types; the `--cpp-str-flex-ctor` argument to `flatc` or the
309 read and write data even if you don't know the exact format of a buffer, and
310 even allows you to change sizes of strings and vectors in-place.
315 FlatBuffer, corresponding to this meta-schema.
332 to keep the overhead of reflection as low as possible (on the order of 2-6
336 You add this information to your generated code by specifying `--reflect-types`
337 (or instead `--reflect-names` if you also want field / enum names).
344 string produced is very similar to the JSON produced by the `Parser` based
360 - Designate one of the fields in a table as they "key" field. You do this
364 - Write out tables of this type as usual, collect their offsets in an
366 - Instead of `CreateVector`, call `CreateVectorOfSortedTables`,
369 - Now when you're accessing the FlatBuffer, you can use `Vector::LookupByKey`
371 `myvector->LookupByKey("Fred")`, which returns a pointer to the
380 As you can see from the above examples, all elements in a buffer are
392 To compute offsets to sub-elements of a struct, make sure they
406 very quick. These offsets are not verified at run-time, so a malformed
407 buffer could cause a program to crash by accessing random memory.
414 For this reason, you can optionally use a buffer verifier before you
416 fields, and null termination of strings to ensure that when a buffer
417 is accessed, all reads will end up inside the buffer.
426 if `ok` is true, the buffer is safe to read.
432 While verifying a buffer isn't "free", it is typically faster than
434 and since it may cause the buffer to be brought into cache before
440 verifier may encounter before declaring the buffer malformed. The default is
451 Another reason might be that you already have a lot of data in JSON
452 format, or a tool that generates JSON, and if you can write a schema for
455 (see the schema documentation for some specifics on the JSON format
458 Schema evolution compatibility for the JSON format follows the same rules as the binary format (JSO…
469 flatc -b myschema.fbs mydata.json
486 Load text (either a schema or json) into an in-memory buffer (there is a
500 This works similarly to how the command-line compiler works: a sequence
504 by one or more JSON files.
506 As optional argument to `Parse`, you may specify a null-terminated list of
514 After each JSON file, the `Parser::fbb` member variable is the
515 `FlatBufferBuilder` that contains the binary buffer version of that
522 Reading a FlatBuffer does not touch any memory outside the original buffer,
523 and is entirely read-only (all const), so is safe to access from multiple
532 of a single buffer will be rare, and synchronisation overhead would be costly.
552 ## Depth limit of nested objects and stack-overflow control
553 The parser of Flatbuffers schema or json-files is kind of recursive parser.
554 To avoid stack-overflow problem the parser has a built-in limiter of
556 nested json-objects is limited. By default, this depth limit set to `64`.
560 CMake-based projects.
562 ## Dependence from C-locale {#flatbuffers_locale_cpp}
567 depend from C-locale: `strtod()` or `strtof()`, for example.
571 and may lead to an error while parsing a Flatbuffers schema or a json file.
575 locale-independent or locale-narrow functions `strtof_l`, `strtod_l`,
577 These functions use specified locale rather than the global or per-thread
578 locale instead. They are part of POSIX-2008 but not part of the C/C++
582 - CMake `"CMakeLists.txt"`:
583 - Check existence of `strtol_l` and `strtod_l` in the `<stdlib.h>`.
584 - Compile-time `"/include/base.h"`:
585 - `_MSC_VER >= 1900`: MSVC2012 or higher if build with MSVC.
586 - `_XOPEN_SOURCE>=700`: POSIX-2008 if build with GCC/Clang.
590 To override or stop this detection use CMake `-DFLATBUFFERS_LOCALE_INDEPENDENT={0|1}`
600 ## Support of floating-point numbers
602 compatible with the `IEEE-754` floating-point standard.
603 The schema and json parser may fail if `fast-math` or `/fp:fast` mode is active.
605 ### Support of hexadecimal and special floating-point numbers
606 According to the [grammar](@ref flatbuffers_grammar) `fbs` and `json` files
607 may use hexadecimal and special (`NaN`, `Inf`) floating-point literals.
608 The Flatbuffers uses `strtof` and `strtod` functions to parse floating-point
612 The support of floating-point literals will be limited at compile time
616 ### Comparison of floating-point NaN values
617 The floating-point `NaN` (`not a number`) is special value which
621 The `IEEE-754` defines two kind of `NaNs`:
622 - Quiet NaNs, or `qNaNs`.
623 - Signaling NaNs, or `sNaNs`.
625 According to the `IEEE-754`, a comparison with `NaN` always returns
632 the unordered comparison by the ordered: `(NaN==NaN)->true`.
636 if GCC or Clang used. These compilers have a compile-time implementation