summaryrefslogtreecommitdiff
path: root/docs/source/CppUsage.md
diff options
context:
space:
mode:
authorWouter van Oortmerssen <wvo@google.com>2016-10-12 16:46:03 -0700
committerWouter van Oortmerssen <wvo@google.com>2016-10-17 09:54:52 -0700
commitd9fe4e2769045f0b90f7a82c03c7a3693fd14fff (patch)
treead74223e8f28bffc1d5dfa9d8895b7c744cde4ce /docs/source/CppUsage.md
parent424fc0c3acfeb8ce2d45192565108c7891626c7d (diff)
downloadflatbuffers-d9fe4e2769045f0b90f7a82c03c7a3693fd14fff.tar.gz
flatbuffers-d9fe4e2769045f0b90f7a82c03c7a3693fd14fff.tar.bz2
flatbuffers-d9fe4e2769045f0b90f7a82c03c7a3693fd14fff.zip
Allow other pointer types than unique_ptr for object API.
Change-Id: I945890ce667a2f5a6c0495e78fd5326ed33b9914 Tested: on Linux. Bug: 30135763
Diffstat (limited to 'docs/source/CppUsage.md')
-rwxr-xr-xdocs/source/CppUsage.md11
1 files changed, 10 insertions, 1 deletions
diff --git a/docs/source/CppUsage.md b/docs/source/CppUsage.md
index 88b6e455..4a9c78e6 100755
--- a/docs/source/CppUsage.md
+++ b/docs/source/CppUsage.md
@@ -99,7 +99,7 @@ construction, access and mutation.
To use:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
- auto monsterobj = GetMonster(buffer)->UnPack();
+ auto monsterobj = UnpackMonster(buffer);
cout << monsterobj->name; // This is now a std::string!
monsterobj->name = "Bob"; // Change the name.
FlatBufferBuilder fbb;
@@ -125,6 +125,15 @@ same string (or hash).
When you call `UnPack` (or `Create`), you'll need a function that maps from
hash to the object (see `resolver_function_t` for details).
+# Using different pointer types.
+
+By default the object tree is built out of `std::unique_ptr`, but you can
+influence this either globally (using the `--cpp-ptr-type` argument to
+`flatc`) or per field (using the `cpp_ptr_type` attribute) to by any smart
+pointer type (`my_ptr<T>`), or by specifying `naked` as the type to get `T *`
+pointers. Unlike the smart pointers, naked pointers do not manage memory for
+you, so you'll have to manage their lifecycles manually.
+
## Reflection (& Resizing)
There is experimental support for reflection in FlatBuffers, allowing you to