Compare commits
494 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38662548c7 | ||
|
|
5973b778b1 | ||
|
|
ac655b3ff0 | ||
|
|
0b3cd33e55 | ||
|
|
d7a86eb029 | ||
|
|
757d830f4e | ||
|
|
e43d127eff | ||
|
|
9b8a814c3f | ||
|
|
8b4c0b94dc | ||
|
|
dbf6702371 | ||
|
|
491e970943 | ||
|
|
9a54c44742 | ||
|
|
9dfc3d61ee | ||
|
|
db0727e943 | ||
|
|
abd6a1427e | ||
|
|
0afac8f75a | ||
|
|
519dcdd0b2 | ||
|
|
112a619ec1 | ||
|
|
fff4590faf | ||
|
|
41395d981d | ||
|
|
b7d97ff3de | ||
|
|
bf07c37a53 | ||
|
|
2ab7ebc82b | ||
|
|
0ece042162 | ||
|
|
69a31b807a | ||
|
|
d75d29e2fe | ||
|
|
049f3f7907 | ||
|
|
e848137ded | ||
|
|
f8c1980fdf | ||
|
|
7d70082590 | ||
|
|
8472b5f224 | ||
|
|
6136dd490a | ||
|
|
3de82050ce | ||
|
|
f1ab30a490 | ||
|
|
cbe8747b59 | ||
|
|
eaa2b414b2 | ||
|
|
77a6a786b8 | ||
|
|
b63ebad49d | ||
|
|
42c20d7a69 | ||
|
|
63b526db52 | ||
|
|
514d274a45 | ||
|
|
6beafd14e0 | ||
|
|
b4d29970f4 | ||
|
|
586fdee89b | ||
|
|
178f768f7f | ||
|
|
316854c26f | ||
|
|
6532bfce34 | ||
|
|
e1e7dfa625 | ||
|
|
a3363def52 | ||
|
|
b4fef31d84 | ||
|
|
cfd6e7dea8 | ||
|
|
56f9b2d142 | ||
|
|
01025fa22b | ||
|
|
30013b4ff8 | ||
|
|
4731c7e502 | ||
|
|
e0b2f81885 | ||
|
|
0e1601b80d | ||
|
|
a6a38f6035 | ||
|
|
4e4a5142fb | ||
|
|
17c0b677e0 | ||
|
|
af23683311 | ||
|
|
451272b618 | ||
|
|
8f13c828f5 | ||
|
|
e6240f4039 | ||
|
|
4691558ee3 | ||
|
|
7fbd9b8de4 | ||
|
|
f243109524 | ||
|
|
13d0594b4c | ||
|
|
6bfcb286b1 | ||
|
|
1891537236 | ||
|
|
d7d527d154 | ||
|
|
995ee86a6e | ||
|
|
40a33b1d06 | ||
|
|
c9198dbbb8 | ||
|
|
b974e95ce4 | ||
|
|
99249ada01 | ||
|
|
a9909a0c18 | ||
|
|
2ce5d6c2b6 | ||
|
|
853e34087a | ||
|
|
be11d2b6ef | ||
|
|
b8187e5b82 | ||
|
|
4dcaec7938 | ||
|
|
c44bc6a719 | ||
|
|
6fba6b6e71 | ||
|
|
96cd275603 | ||
|
|
42b48bd55f | ||
|
|
8bb45dc0a6 | ||
|
|
8db90f5073 | ||
|
|
d5a113e5bf | ||
|
|
8e6758d205 | ||
|
|
163d04a5d2 | ||
|
|
b0d5bb1c4b | ||
|
|
f622e5996c | ||
|
|
77fbdd28e2 | ||
|
|
c9ad6d5496 | ||
|
|
e083e466b8 | ||
|
|
fe2f8d32aa | ||
|
|
45bda6e08d | ||
|
|
47478117d8 | ||
|
|
d7f2488099 | ||
|
|
3881bbd651 | ||
|
|
7b06041a7c | ||
|
|
3fc5387db7 | ||
|
|
fc1cfd287a | ||
|
|
54dc4395b9 | ||
|
|
1d457a0271 | ||
|
|
671c9495d9 | ||
|
|
d7b4a31e93 | ||
|
|
b7d8c2af1a | ||
|
|
1075c80e8a | ||
|
|
947a5b4ea3 | ||
|
|
e10b8d6f2a | ||
|
|
644bcbde91 | ||
|
|
6775a0a941 | ||
|
|
20c712f31b | ||
|
|
e6d51b54b6 | ||
|
|
c7482832b8 | ||
|
|
6fe6532673 | ||
|
|
8212da5d5d | ||
|
|
a7b5f92f51 | ||
|
|
6266b4f122 | ||
|
|
e4eb286483 | ||
|
|
331d2d835c | ||
|
|
5ce8682671 | ||
|
|
37e28d98ea | ||
|
|
097797bf9f | ||
|
|
4725be015d | ||
|
|
f7d465f990 | ||
|
|
c4966370e2 | ||
|
|
65c9b355c1 | ||
|
|
f2949c3fb1 | ||
|
|
ef53aebf9e | ||
|
|
4f96603e12 | ||
|
|
3232727ace | ||
|
|
2dfff15a9d | ||
|
|
3f1c4b41f6 | ||
|
|
b98f526b8a | ||
|
|
9dc5d378b1 | ||
|
|
b0b39543de | ||
|
|
721d21923e | ||
|
|
3f79e05585 | ||
|
|
4d7810424c | ||
|
|
2107a7d514 | ||
|
|
40b03519c1 | ||
|
|
d236dea13d | ||
|
|
ed88f7de96 | ||
|
|
07478a6700 | ||
|
|
48ff729477 | ||
|
|
7c60937806 | ||
|
|
ace304513f | ||
|
|
1917e577a2 | ||
|
|
9c9fce96c7 | ||
|
|
525130765a | ||
|
|
d890ef9e20 | ||
|
|
9f69d79430 | ||
|
|
9d66af6efc | ||
|
|
8f1729f7df | ||
|
|
4bef5e89c4 | ||
|
|
79222bf100 | ||
|
|
c3bfefca57 | ||
|
|
00fd394d23 | ||
|
|
e1e8d53df6 | ||
|
|
57a6dd472f | ||
|
|
224e33ed09 | ||
|
|
94680f5483 | ||
|
|
b4db88808f | ||
|
|
d9db48257b | ||
|
|
e1e1bced08 | ||
|
|
b56add9520 | ||
|
|
2abe24b9dd | ||
|
|
a35c32e30f | ||
|
|
781c39c708 | ||
|
|
ff9e539cc5 | ||
|
|
feb4816610 | ||
|
|
703b790939 | ||
|
|
811a5c3389 | ||
|
|
2736711d67 | ||
|
|
edb3b9c307 | ||
|
|
477fedccd4 | ||
|
|
5de28c74f9 | ||
|
|
44261ccdf1 | ||
|
|
c02b16e195 | ||
|
|
169df65df4 | ||
|
|
af1487bcfb | ||
|
|
5db12e9907 | ||
|
|
dff07b6f31 | ||
|
|
5dd8795a10 | ||
|
|
be503cb0f2 | ||
|
|
01e06b69a5 | ||
|
|
782e05de55 | ||
|
|
82a71b18f1 | ||
|
|
aeff09d724 | ||
|
|
a5c511576f | ||
|
|
ac10873e26 | ||
|
|
9689d38bef | ||
|
|
d06b2736aa | ||
|
|
a0f3fb44e7 | ||
|
|
d97f628703 | ||
|
|
fb7f27a7c9 | ||
|
|
7bfed4b29a | ||
|
|
a170b69d5d | ||
|
|
33e4ab65e9 | ||
|
|
201699288b | ||
|
|
e9202d85bd | ||
|
|
9a1ab5006f | ||
|
|
25c99273d3 | ||
|
|
7bcbb19569 | ||
|
|
b062af4c8c | ||
|
|
0956719726 | ||
|
|
766eaad4e7 | ||
|
|
3a74c33ba5 | ||
|
|
e4c3bf3d2c | ||
|
|
7196c36842 | ||
|
|
e151160560 | ||
|
|
dac63a227e | ||
|
|
986b52d849 | ||
|
|
45cc503bbd | ||
|
|
6aeb09b297 | ||
|
|
210c0ece54 | ||
|
|
ad84b5b8fa | ||
|
|
7101224d86 | ||
|
|
6be146d67f | ||
|
|
f706a42951 | ||
|
|
e24afd838a | ||
|
|
81c2b185ef | ||
|
|
0e064e415b | ||
|
|
4998ad7365 | ||
|
|
9a30d3d0df | ||
|
|
0b761ece4d | ||
|
|
01249c1d48 | ||
|
|
588564d74f | ||
|
|
6e192fa408 | ||
|
|
12ca3e054e | ||
|
|
62af533820 | ||
|
|
b56020ad3b | ||
|
|
6e160f4c59 | ||
|
|
07e77ad0ff | ||
|
|
b6380aceac | ||
|
|
79d3cb6a6c | ||
|
|
a4de6de700 | ||
|
|
a1d801c375 | ||
|
|
f66e93cd8d | ||
|
|
59a09cb1d0 | ||
|
|
c23c620d26 | ||
|
|
4798456df6 | ||
|
|
147fbb4285 | ||
|
|
a9ae9bdcab | ||
|
|
f7d8102b35 | ||
|
|
d0e9bc6a75 | ||
|
|
d863df8683 | ||
|
|
4834634766 | ||
|
|
a4c893dbe2 | ||
|
|
8833255ed3 | ||
|
|
fb5f9456e9 | ||
|
|
0dacfbbfca | ||
|
|
47aab78233 | ||
|
|
185b9f9792 | ||
|
|
21765bea2e | ||
|
|
36c7e9a962 | ||
|
|
cb2b2be54e | ||
|
|
1c152cc72a | ||
|
|
d67661eb39 | ||
|
|
ea97e1b5e2 | ||
|
|
dca3ccf5fd | ||
|
|
ef7b3ed8f5 | ||
|
|
4d305f5922 | ||
|
|
1e6f8f5b8c | ||
|
|
c967515da5 | ||
|
|
576022c64b | ||
|
|
eab9cfbec9 | ||
|
|
ab4801a82e | ||
|
|
8df4b318bc | ||
|
|
8a98e9ad98 | ||
|
|
eee5628569 | ||
|
|
ad3fd6ecbf | ||
|
|
622b8d05cf | ||
|
|
5faa0ab1be | ||
|
|
81312c2128 | ||
|
|
1808337adc | ||
|
|
5f091c46ce | ||
|
|
a96bfdb369 | ||
|
|
ad3ebb110b | ||
|
|
929105432c | ||
|
|
40fffc8fff | ||
|
|
2f76141813 | ||
|
|
932b22f043 | ||
|
|
ecf5a6a580 | ||
|
|
788acb08d4 | ||
|
|
ddb1d5ffe4 | ||
|
|
7ba29dbe41 | ||
|
|
3b070310f0 | ||
|
|
fbe085601b | ||
|
|
36f9b1ec91 | ||
|
|
7bcd99451f | ||
|
|
2535a3aa3a | ||
|
|
0894c25f2c | ||
|
|
7810fb9ce4 | ||
|
|
c127cf78c2 | ||
|
|
6fffa2a14d | ||
|
|
2b02d330fd | ||
|
|
c8f1682e07 | ||
|
|
f64e040896 | ||
|
|
339376ba67 | ||
|
|
7a1b77322b | ||
|
|
60b6ca5850 | ||
|
|
b8681d8031 | ||
|
|
f8139b05cb | ||
|
|
776c4eb965 | ||
|
|
2746aabcf1 | ||
|
|
04a06781f5 | ||
|
|
48dfc69ee6 | ||
|
|
4d213c2d06 | ||
|
|
361bfb6764 | ||
|
|
3f96eead4c | ||
|
|
8896587faf | ||
|
|
9fa3e2f387 | ||
|
|
e5c21ec666 | ||
|
|
e11da87a24 | ||
|
|
3dd54424c0 | ||
|
|
5d68493df4 | ||
|
|
d322eec3c3 | ||
|
|
221193eaa2 | ||
|
|
f7d24f60a2 | ||
|
|
e5a1a3129d | ||
|
|
39833d7cf0 | ||
|
|
ecb27817ca | ||
|
|
f59bfdd084 | ||
|
|
0ee1b99c5d | ||
|
|
a50711ad13 | ||
|
|
249f71a12b | ||
|
|
1d138fbe07 | ||
|
|
a0bf238b09 | ||
|
|
c49c6da803 | ||
|
|
37e6efe1f9 | ||
|
|
d4d7a84e11 | ||
|
|
fc7e8af55e | ||
|
|
3ec5dddb00 | ||
|
|
f47660f510 | ||
|
|
a8d6962ac2 | ||
|
|
23f75f598e | ||
|
|
e3b432cba8 | ||
|
|
557c57eb9d | ||
|
|
9d368deb05 | ||
|
|
8b99bf614c | ||
|
|
c4a3e2f6bd | ||
|
|
803f9bba27 | ||
|
|
d756efbf76 | ||
|
|
ace7fa8094 | ||
|
|
f02646e357 | ||
|
|
0a3a09aaf3 | ||
|
|
796be3282c | ||
|
|
468124fb9b | ||
|
|
3ad853630c | ||
|
|
b8708beeec | ||
|
|
8fb6c4f764 | ||
|
|
75740c1374 | ||
|
|
e8598950fc | ||
|
|
ca5c9e7496 | ||
|
|
f7818d83d7 | ||
|
|
7ef2fc2517 | ||
|
|
6df9e1c537 | ||
|
|
6a0126340a | ||
|
|
4464405250 | ||
|
|
c3807fa39d | ||
|
|
a360958be3 | ||
|
|
432f3f26a4 | ||
|
|
6ccdfff0af | ||
|
|
71e97b7123 | ||
|
|
c243aa4e15 | ||
|
|
d575321eba | ||
|
|
f353fd8864 | ||
|
|
c9a840e935 | ||
|
|
620fe1c5cf | ||
|
|
69dae32776 | ||
|
|
da0f096ba2 | ||
|
|
36fe9d539f | ||
|
|
6180b5ac7a | ||
|
|
42bfe240e0 | ||
|
|
1fb0f1ef71 | ||
|
|
1c8c9438a2 | ||
|
|
85f64786da | ||
|
|
b0910e75e0 | ||
|
|
ff1ac8ab5a | ||
|
|
4d3db99283 | ||
|
|
72b9501e69 | ||
|
|
9c169083ad | ||
|
|
7bebaab69e | ||
|
|
d8117bb8a3 | ||
|
|
df4909e5f6 | ||
|
|
79c2d80ed4 | ||
|
|
3e1b789d21 | ||
|
|
cf7135ff58 | ||
|
|
f60276f54b | ||
|
|
2b01247b30 | ||
|
|
7cf74cb864 | ||
|
|
4fb5a764df | ||
|
|
6c2dc41e0d | ||
|
|
e568f17096 | ||
|
|
1263e9788e | ||
|
|
f5132b9ee1 | ||
|
|
c95ad9cc55 | ||
|
|
3550899987 | ||
|
|
73582b145c | ||
|
|
b929c62c71 | ||
|
|
3ec8d7f598 | ||
|
|
352b743c71 | ||
|
|
b7cb91c34e | ||
|
|
f79cc460f8 | ||
|
|
757854a6cd | ||
|
|
6f4b4c80a7 | ||
|
|
ae1763e226 | ||
|
|
aa46f0e4c2 | ||
|
|
89d2b0861b | ||
|
|
4390254e6a | ||
|
|
3a27013732 | ||
|
|
d72c478128 | ||
|
|
10f4ecac26 | ||
|
|
27823d5552 | ||
|
|
19361a58ec | ||
|
|
c6c8a9ba29 | ||
|
|
14eaddfdcc | ||
|
|
8833cff911 | ||
|
|
318668aed6 | ||
|
|
9566669245 | ||
|
|
354fd906a5 | ||
|
|
2d9b3ade18 | ||
|
|
ced2cb6ce9 | ||
|
|
285501f7be | ||
|
|
0952143971 | ||
|
|
0ce53c96c3 | ||
|
|
d6f70cdd7d | ||
|
|
07d5965c81 | ||
|
|
6ca102e413 | ||
|
|
8ef6ee2a3e | ||
|
|
118abc2871 | ||
|
|
fbcf063401 | ||
|
|
e97f38e53c | ||
|
|
4cdf3eb19b | ||
|
|
ea592296b8 | ||
|
|
d426890b92 | ||
|
|
1e4d28bf14 | ||
|
|
0eac15c784 | ||
|
|
d38b9af243 | ||
|
|
18cf19f876 | ||
|
|
730c0cadde | ||
|
|
ef03cf46e4 | ||
|
|
7b8053570e | ||
|
|
85c9c83844 | ||
|
|
30642c5a6f | ||
|
|
517c964fe2 | ||
|
|
3f8700b296 | ||
|
|
048638a971 | ||
|
|
d6ed127cf4 | ||
|
|
bdaedebef9 | ||
|
|
557c88c039 | ||
|
|
d01b30cdd6 | ||
|
|
c01c77a7f2 | ||
|
|
0a549e3875 | ||
|
|
e57b86bb9f | ||
|
|
cb58fc6fa1 | ||
|
|
858e9961e2 | ||
|
|
32f2c1c3b9 | ||
|
|
e14bc1d9ac | ||
|
|
9a1f7be6fd | ||
|
|
3f85183c88 | ||
|
|
354aad4bc5 | ||
|
|
f57d012a21 | ||
|
|
f5e343efba | ||
|
|
b5edc2dea5 | ||
|
|
09a2999c66 | ||
|
|
96592d5dbb | ||
|
|
84f86be700 | ||
|
|
417cb878c3 | ||
|
|
11f2538610 | ||
|
|
ea57dfe897 | ||
|
|
9f506f57c0 | ||
|
|
57b614587c | ||
|
|
15dc1a86cd | ||
|
|
766d0df797 | ||
|
|
4507594812 | ||
|
|
8e40902d52 | ||
|
|
bc5fa9d52f | ||
|
|
11b743688c | ||
|
|
ffb3dec573 | ||
|
|
51ba48ae40 | ||
|
|
c553b6b950 | ||
|
|
541b06759f | ||
|
|
30af866e5a | ||
|
|
ebac1e1940 | ||
|
|
f7b0d130b6 | ||
|
|
c2ba7fd251 | ||
|
|
be894f09df | ||
|
|
293a8110c4 | ||
|
|
8c5d7f7dea |
26
.gitignore
vendored
@@ -19,7 +19,9 @@
|
||||
**/*.dir/**
|
||||
**/CMakeFiles/**
|
||||
**/cmake_install.cmake
|
||||
**/install_manifest.txt
|
||||
**/CMakeCache.txt
|
||||
**/CMakeTestfile.cmake
|
||||
**/Debug/**
|
||||
**/Release/**
|
||||
build.xml
|
||||
@@ -29,9 +31,33 @@ proguard-project.txt
|
||||
linklint_results
|
||||
Makefile
|
||||
flatc
|
||||
flatc.exe
|
||||
flathash
|
||||
flathash.exe
|
||||
flattests
|
||||
flattests.exe
|
||||
flatsamplebinary
|
||||
flatsamplebinary.exe
|
||||
flatsampletext
|
||||
flatsampletext.exe
|
||||
snapshot.sh
|
||||
tests/go_gen
|
||||
tests/monsterdata_java_wire.mon
|
||||
tests/monsterdata_go_wire.mon
|
||||
tests/monsterdata_javascript_wire.mon
|
||||
tests/unicode_test.mon
|
||||
CMakeLists.txt.user
|
||||
CMakeScripts/**
|
||||
CTestTestfile.cmake
|
||||
FlatBuffers.cbp
|
||||
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
|
||||
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
|
||||
FlatBuffers.xcodeproj/
|
||||
java/.idea
|
||||
java/*.iml
|
||||
java/target
|
||||
**/*.pyc
|
||||
.idea
|
||||
build/VS2010/FlatBuffers.sdf
|
||||
build/VS2010/FlatBuffers.opensdf
|
||||
build/VS2010/ipch/**/*.ipch
|
||||
|
||||
30
.travis.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
language: cpp
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
#- clang
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BUILD_TYPE=Debug BIICODE=false
|
||||
- BUILD_TYPE=Release BIICODE=false
|
||||
- BUILD_TYPE=Release BIICODE=true
|
||||
- BUILD_TYPE=Debug BIICODE=true
|
||||
global:
|
||||
- GCC_VERSION="4.9"
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
||||
|
||||
script:
|
||||
- if [ "$BIICODE" == "false" ]; then cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE . && make && make test; fi
|
||||
- if [ "$BIICODE" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then ./biicode/support/bii-travis.sh $BUILD_TYPE; fi
|
||||
141
CMake/BuildFlatBuffers.cmake
Normal file
@@ -0,0 +1,141 @@
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# General function to create FlatBuffer build rules for the given list of
|
||||
# schemas.
|
||||
#
|
||||
# flatbuffers_schemas: A list of flatbuffer schema files to process.
|
||||
#
|
||||
# schema_include_dirs: A list of schema file include directories, which will be
|
||||
# passed to flatc via the -I parameter.
|
||||
#
|
||||
# custom_target_name: The generated files will be added as dependencies for a
|
||||
# new custom target with this name. You should add that target as a dependency
|
||||
# for your main target to ensure these files are built. You can also retrieve
|
||||
# various properties from this target, such as GENERATED_INCLUDES_DIR,
|
||||
# BINARY_SCHEMAS_DIR, and COPY_TEXT_SCHEMAS_DIR.
|
||||
#
|
||||
# additional_dependencies: A list of additional dependencies that you'd like
|
||||
# all generated files to depend on. Pass in a blank string if you have none.
|
||||
#
|
||||
# generated_includes_dir: Where to generate the C++ header files for these
|
||||
# schemas. The generated includes directory will automatically be added to
|
||||
# CMake's include directories, and will be where generated header files are
|
||||
# placed. This parameter is optional; pass in empty string if you don't want to
|
||||
# generate include files for these schemas.
|
||||
#
|
||||
# binary_schemas_dir: If you specify an optional binary schema directory, binary
|
||||
# schemas will be generated for these schemas as well, and placed into the given
|
||||
# directory.
|
||||
#
|
||||
# copy_text_schemas_dir: If you want all text schemas (including schemas from
|
||||
# all schema include directories) copied into a directory (for example, if you
|
||||
# need them within your project to build JSON files), you can specify that
|
||||
# folder here. All text schemas will be copied to that folder.
|
||||
#
|
||||
# IMPORTANT: Make sure you quote all list arguments you pass to this function!
|
||||
# Otherwise CMake will only pass in the first element.
|
||||
# Example: build_flatbuffers("${fb_files}" "${include_dirs}" target_name ...)
|
||||
function(build_flatbuffers flatbuffers_schemas
|
||||
schema_include_dirs
|
||||
custom_target_name
|
||||
additional_dependencies
|
||||
generated_includes_dir
|
||||
binary_schemas_dir
|
||||
copy_text_schemas_dir)
|
||||
|
||||
# Test if including from FindFlatBuffers
|
||||
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATC_TARGET "")
|
||||
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||
else()
|
||||
set(FLATC_TARGET flatc)
|
||||
set(FLATC flatc)
|
||||
endif()
|
||||
|
||||
set(schema_glob "*.fbs")
|
||||
# Generate the include files parameters.
|
||||
set(include_params "")
|
||||
set(all_generated_files "")
|
||||
foreach (include_dir ${schema_include_dirs})
|
||||
set(include_params -I ${include_dir} ${include_params})
|
||||
if (NOT ${copy_text_schemas_dir} STREQUAL "")
|
||||
# Copy text schemas from dependent folders.
|
||||
file(GLOB_RECURSE dependent_schemas ${include_dir}/${schema_glob})
|
||||
foreach (dependent_schema ${dependent_schemas})
|
||||
file(COPY ${dependent_schema} DESTINATION ${copy_text_schemas_dir})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(schema ${flatbuffers_schemas})
|
||||
get_filename_component(filename ${schema} NAME_WE)
|
||||
# For each schema, do the things we requested.
|
||||
if (NOT ${generated_includes_dir} STREQUAL "")
|
||||
set(generated_include ${generated_includes_dir}/${filename}_generated.h)
|
||||
add_custom_command(
|
||||
OUTPUT ${generated_include}
|
||||
COMMAND ${FLATC} --gen-mutable
|
||||
-o ${generated_includes_dir}
|
||||
${include_params}
|
||||
-c ${schema}
|
||||
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies})
|
||||
list(APPEND all_generated_files ${generated_include})
|
||||
endif()
|
||||
|
||||
if (NOT ${binary_schemas_dir} STREQUAL "")
|
||||
set(binary_schema ${binary_schemas_dir}/${filename}.bfbs)
|
||||
add_custom_command(
|
||||
OUTPUT ${binary_schema}
|
||||
COMMAND ${FLATC} -b --schema
|
||||
-o ${binary_schemas_dir}
|
||||
${include_params}
|
||||
${schema}
|
||||
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies})
|
||||
list(APPEND all_generated_files ${binary_schema})
|
||||
endif()
|
||||
|
||||
if (NOT ${copy_text_schemas_dir} STREQUAL "")
|
||||
file(COPY ${schema} DESTINATION ${copy_text_schemas_dir})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Create a custom target that depends on all the generated files.
|
||||
# This is the target that you can depend on to trigger all these
|
||||
# to be built.
|
||||
add_custom_target(${custom_target_name}
|
||||
DEPENDS ${all_generated_files} ${additional_dependencies})
|
||||
|
||||
# Register the include directory we are using.
|
||||
if (NOT ${generated_includes_dir} STREQUAL "")
|
||||
include_directories(${generated_includes_dir})
|
||||
set_property(TARGET ${custom_target_name}
|
||||
PROPERTY GENERATED_INCLUDES_DIR
|
||||
${generated_includes_dir})
|
||||
endif()
|
||||
|
||||
# Register the binary schemas dir we are using.
|
||||
if (NOT ${binary_schemas_dir} STREQUAL "")
|
||||
set_property(TARGET ${custom_target_name}
|
||||
PROPERTY BINARY_SCHEMAS_DIR
|
||||
${binary_schemas_dir})
|
||||
endif()
|
||||
|
||||
# Register the text schema copy dir we are using.
|
||||
if (NOT ${copy_text_schemas_dir} STREQUAL "")
|
||||
set_property(TARGET ${custom_target_name}
|
||||
PROPERTY COPY_TEXT_SCHEMAS_DIR
|
||||
${copy_text_schemas_dir})
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -24,6 +24,8 @@
|
||||
# for the given flatbuffer schema files.
|
||||
# Returns the header files in ${Name}_OUTPUTS
|
||||
|
||||
set(FLATBUFFERS_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc)
|
||||
find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h)
|
||||
|
||||
@@ -54,3 +56,5 @@ if(FLATBUFFERS_FOUND)
|
||||
else()
|
||||
set(FLATBUFFERS_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
include("${FLATBUFFERS_CMAKE_DIR}/BuildFlatBuffers.cmake")
|
||||
145
CMakeLists.txt
@@ -4,78 +4,161 @@ project(FlatBuffers)
|
||||
|
||||
# NOTE: Code coverage only works on Linux & OSX.
|
||||
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
|
||||
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
|
||||
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
|
||||
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library" ON)
|
||||
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" ON)
|
||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
||||
|
||||
set(FlatBuffers_Compiler_SRCS
|
||||
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||
message(WARNING
|
||||
"Cannot build tests without building the compiler. Tests will be disabled.")
|
||||
set(FLATBUFFERS_BUILD_TESTS OFF)
|
||||
endif()
|
||||
|
||||
set(FlatBuffers_Library_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/hash.h
|
||||
include/flatbuffers/idl.h
|
||||
include/flatbuffers/util.h
|
||||
include/flatbuffers/reflection.h
|
||||
include/flatbuffers/reflection_generated.h
|
||||
src/idl_parser.cpp
|
||||
src/idl_gen_cpp.cpp
|
||||
src/idl_gen_java.cpp
|
||||
src/idl_gen_go.cpp
|
||||
src/idl_gen_text.cpp
|
||||
src/reflection.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Compiler_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_cpp.cpp
|
||||
src/idl_gen_general.cpp
|
||||
src/idl_gen_go.cpp
|
||||
src/idl_gen_js.cpp
|
||||
src/idl_gen_php.cpp
|
||||
src/idl_gen_python.cpp
|
||||
src/idl_gen_fbs.cpp
|
||||
src/flatc.cpp
|
||||
)
|
||||
|
||||
set(FlatHash_SRCS
|
||||
include/flatbuffers/hash.h
|
||||
src/flathash.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Tests_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/idl.h
|
||||
include/flatbuffers/util.h
|
||||
src/idl_parser.cpp
|
||||
src/idl_gen_text.cpp
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_fbs.cpp
|
||||
src/idl_gen_general.cpp
|
||||
tests/test.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
tests/monster_test_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Binary_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
samples/sample_binary.cpp
|
||||
# file generate by running compiler on samples/monster.fbs
|
||||
samples/monster_generated.h
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Text_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/hash.h
|
||||
include/flatbuffers/idl.h
|
||||
include/flatbuffers/util.h
|
||||
src/idl_parser.cpp
|
||||
src/idl_gen_text.cpp
|
||||
samples/sample_text.cpp
|
||||
# file generate by running compiler on samples/monster.fbs
|
||||
samples/monster_generated.h
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
||||
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wall -pedantic -Werror -Wextra")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -Wunused-result -Werror=unused-result")
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++ -Wall -pedantic -Werror -Wextra")
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra")
|
||||
|
||||
if(FLATBUFFERS_CODE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
if(BIICODE)
|
||||
include(biicode/cmake/biicode.cmake)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
|
||||
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||
endif()
|
||||
|
||||
install(DIRECTORY include/flatbuffers DESTINATION include)
|
||||
install(TARGETS flatc DESTINATION bin)
|
||||
if(FLATBUFFERS_BUILD_FLATC)
|
||||
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
||||
endif()
|
||||
|
||||
add_test(NAME flattest
|
||||
CONFIGURATIONS Debug
|
||||
WORKING_DIRECTORY tests
|
||||
COMMAND flattests)
|
||||
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||
add_executable(flathash ${FlatHash_SRCS})
|
||||
endif()
|
||||
|
||||
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_HEADER}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable -o "${SRC_FBS_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc)
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_BINARY_SCHEMA}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -b --schema -o "${SRC_FBS_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc)
|
||||
endfunction()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||
|
||||
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_INSTALL)
|
||||
install(DIRECTORY include/flatbuffers DESTINATION include)
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
install(TARGETS flatbuffers DESTINATION lib)
|
||||
endif()
|
||||
if(FLATBUFFERS_BUILD_FLATC)
|
||||
install(TARGETS flatc DESTINATION bin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION
|
||||
"${CMAKE_CURRENT_BINARY_DIR}")
|
||||
add_test(NAME flattests COMMAND flattests)
|
||||
endif()
|
||||
|
||||
include(CMake/BuildFlatBuffers.cmake)
|
||||
|
||||
42
CONTRIBUTING
Normal file
@@ -0,0 +1,42 @@
|
||||
Contributing {#contributing}
|
||||
============
|
||||
|
||||
Want to contribute? Great! First, read this page (including the small print at
|
||||
the end).
|
||||
|
||||
# Before you contribute
|
||||
Before we can use your code, you must sign the
|
||||
[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
|
||||
(CLA), which you can do online. The CLA is necessary mainly because you own the
|
||||
copyright to your changes, even after your contribution becomes part of our
|
||||
codebase, so we need your permission to use and distribute your code. We also
|
||||
need to be sure of various other things—for instance that you'll tell us if you
|
||||
know that your code infringes on other people's patents. You don't have to sign
|
||||
the CLA until after you've submitted your code for review and a member has
|
||||
approved it, but you must do it before we can put your code into our codebase.
|
||||
Before you start working on a larger contribution, you should get in touch with
|
||||
us first through the issue tracker with your idea so that we can help out and
|
||||
possibly guide you. Coordinating up front makes it much easier to avoid
|
||||
frustration later on.
|
||||
|
||||
# Code reviews
|
||||
All submissions, including submissions by project members, require review. We
|
||||
use Github pull requests for this purpose.
|
||||
|
||||
Some tips for good pull requests:
|
||||
* Use our code
|
||||
[style guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.html).
|
||||
When in doubt, try to stay true to the existing code of the project.
|
||||
* Write a descriptive commit message. What problem are you solving and what
|
||||
are the consequences? Where and what did you test? Some good tips:
|
||||
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
||||
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
|
||||
* If your PR consists of multiple commits which are successive improvements /
|
||||
fixes to your first commit, consider squashing them into a single commit
|
||||
(`git rebase -i`) such that your PR is a single commit on top of the current
|
||||
HEAD. This make reviewing the code so much easier, and our history more
|
||||
readable.
|
||||
|
||||
# The small print
|
||||
Contributions made by corporations are covered by a different agreement than
|
||||
the one above, the Software Grant and Corporate Contributor License Agreement.
|
||||
2
LICENSE.txt
Executable file → Normal file
@@ -187,7 +187,7 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
Copyright 2014 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -235,10 +235,16 @@ select_android_build_target() {
|
||||
local android_build_target=
|
||||
for android_target in $(echo "${android_targets_installed}" | \
|
||||
awk -F- '{ print $2 }' | sort -n); do
|
||||
if [[ $((android_target)) -ge \
|
||||
local isNumber='^[0-9]+$'
|
||||
# skip preview API releases e.g. 'android-L'
|
||||
if [[ $android_target =~ $isNumber ]]; then
|
||||
if [[ $((android_target)) -ge \
|
||||
$((BUILDAPK_ANDROID_TARGET_MINVERSION)) ]]; then
|
||||
android_build_target="android-${android_target}"
|
||||
break
|
||||
android_build_target="android-${android_target}"
|
||||
break
|
||||
fi
|
||||
# else
|
||||
# The API version is a letter, so skip it.
|
||||
fi
|
||||
done
|
||||
if [[ "${android_build_target}" == "" ]]; then
|
||||
@@ -415,14 +421,18 @@ main() {
|
||||
local build_package=1
|
||||
for opt; do
|
||||
case ${opt} in
|
||||
# NDK_DEBUG=0 tells ndk-build to build this as debuggable but to not
|
||||
# modify the underlying code whereas NDK_DEBUG=1 also builds as debuggable
|
||||
# but does modify the code
|
||||
NDK_DEBUG=1) ant_target=debug ;;
|
||||
NDK_DEBUG=0) ant_target=debug ;;
|
||||
ADB_DEVICE*) adb_device="$(\
|
||||
echo "${opt}" | sed -E 's/^ADB_DEVICE=([^ ]+)$/-s \1/;t;s/.*//')" ;;
|
||||
BUILD=0) disable_build=1 ;;
|
||||
DEPLOY=0) disable_deploy=1 ;;
|
||||
RUN_DEBUGGER=1) run_debugger=1 ;;
|
||||
LAUNCH=0) launch=0 ;;
|
||||
clean) build_package=0 ;;
|
||||
clean) build_package=0 disable_deploy=1 launch=0 ;;
|
||||
-h|--help|help) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -14,20 +14,41 @@
|
||||
# misrepresented as being the original software.
|
||||
# 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
LOCAL_PATH := $(call my-dir)/../..
|
||||
|
||||
include $(LOCAL_PATH)/android/jni/include.mk
|
||||
LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH))
|
||||
|
||||
# Empty static library so that other projects can include just the basic
|
||||
# FlatBuffers headers as a module.
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := flatbuffers
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_CPPFLAGS := -std=c++11 -fexceptions -Wall -Wno-literal-suffix
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
LOCAL_MODULE := FlatBufferTest
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include
|
||||
LOCAL_SRC_FILES := main.cpp ../../tests/test.cpp ../../src/idl_parser.cpp ../../src/idl_gen_text.cpp
|
||||
LOCAL_LDLIBS := -llog -landroid
|
||||
LOCAL_STATIC_LIBRARIES := android_native_app_glue
|
||||
LOCAL_ARM_MODE:=arm
|
||||
LOCAL_CPPFLAGS += -std=c++11 -fexceptions -Wall -Wno-literal-suffix
|
||||
# static library that additionally includes text parsing/generation/reflection
|
||||
# for projects that want richer functionality.
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := flatbuffers_extra
|
||||
LOCAL_SRC_FILES := src/idl_parser.cpp \
|
||||
src/idl_gen_text.cpp \
|
||||
src/reflection.cpp
|
||||
LOCAL_STATIC_LIBRARIES := flatbuffers
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
# FlatBuffers test
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := FlatBufferTest
|
||||
LOCAL_SRC_FILES := android/jni/main.cpp \
|
||||
tests/test.cpp \
|
||||
src/idl_gen_fbs.cpp \
|
||||
src/idl_gen_general.cpp
|
||||
LOCAL_LDLIBS := -llog -landroid
|
||||
LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers_extra
|
||||
LOCAL_ARM_MODE := arm
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,android/native_app_glue)
|
||||
|
||||
$(call import-add-path,../..)
|
||||
$(call import-add-path,$(LOCAL_PATH)/../..)
|
||||
|
||||
68
android/jni/build_flatc.bat
Executable file
@@ -0,0 +1,68 @@
|
||||
@rem Copyright (c) 2013 Google, Inc.
|
||||
@rem
|
||||
@rem This software is provided 'as-is', without any express or implied
|
||||
@rem warranty. In no event will the authors be held liable for any damages
|
||||
@rem arising from the use of this software.
|
||||
@rem Permission is granted to anyone to use this software for any purpose,
|
||||
@rem including commercial applications, and to alter it and redistribute it
|
||||
@rem freely, subject to the following restrictions:
|
||||
@rem 1. The origin of this software must not be misrepresented; you must not
|
||||
@rem claim that you wrote the original software. If you use this software
|
||||
@rem in a product, an acknowledgment in the product documentation would be
|
||||
@rem appreciated but is not required.
|
||||
@rem 2. Altered source versions must be plainly marked as such, and must not be
|
||||
@rem misrepresented as being the original software.
|
||||
@rem 3. This notice may not be removed or altered from any source distribution.
|
||||
@echo off
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set thispath=%~dp0
|
||||
|
||||
rem Path to cmake passed in by caller.
|
||||
set cmake=%1
|
||||
rem Path to cmake project to build.
|
||||
set cmake_project_path=%2
|
||||
|
||||
rem Newest and oldest version of Visual Studio that it's possible to select.
|
||||
set visual_studio_version_max=20
|
||||
set visual_studio_version_min=8
|
||||
|
||||
rem Determine the newest version of Visual Studio installed on this machine.
|
||||
set visual_studio_version=
|
||||
for /L %%a in (%visual_studio_version_max%,-1,%visual_studio_version_min%) do (
|
||||
echo Searching for Visual Studio %%a >&2
|
||||
reg query HKLM\SOFTWARE\Microsoft\VisualStudio\%%a.0 /ve 1>NUL 2>NUL
|
||||
if !ERRORLEVEL! EQU 0 (
|
||||
set visual_studio_version=%%a
|
||||
goto found_vs
|
||||
)
|
||||
)
|
||||
echo Unable to determine whether Visual Studio is installed. >&2
|
||||
exit /B 1
|
||||
:found_vs
|
||||
|
||||
rem Map Visual Studio version to cmake generator name.
|
||||
if "%visual_studio_version%"=="8" (
|
||||
set cmake_generator=Visual Studio 8 2005
|
||||
)
|
||||
if "%visual_studio_version%"=="9" (
|
||||
set cmake_generator=Visual Studio 9 2008
|
||||
)
|
||||
if %visual_studio_version% GEQ 10 (
|
||||
set cmake_generator=Visual Studio %visual_studio_version%
|
||||
)
|
||||
rem Set visual studio version variable for msbuild.
|
||||
set VisualStudioVersion=%visual_studio_version%.0
|
||||
|
||||
rem Generate Visual Studio solution.
|
||||
echo Generating solution for %cmake_generator%. >&2
|
||||
cd "%cmake_project_path%"
|
||||
%cmake% -G"%cmake_generator%"
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
exit /B %ERRORLEVEL%
|
||||
)
|
||||
|
||||
rem Build flatc
|
||||
python %thispath%\msbuild.py flatc.vcxproj
|
||||
if ERRORLEVEL 1 exit /B 1
|
||||
237
android/jni/include.mk
Normal file
@@ -0,0 +1,237 @@
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This file contains utility functions for Android projects using Flatbuffers.
|
||||
# To use this file, include it in your project's Android.mk by calling near the
|
||||
# top of your android makefile like so:
|
||||
#
|
||||
# include $(FLATBUFFERS_DIR)/android/jni/include.mk
|
||||
#
|
||||
# You will also need to import the flatbuffers module using the standard
|
||||
# import-module function.
|
||||
#
|
||||
# The main functionality this file provides are the following functions:
|
||||
# flatbuffers_fbs_to_h: Converts flatbuffer schema paths to header paths.
|
||||
# flatbuffers_header_build_rule:
|
||||
# Creates a build rule for a schema's generated header. This build rule
|
||||
# has a dependency on the flatc compiler which will be built if necessary.
|
||||
# flatbuffers_header_build_rules:
|
||||
# Creates build rules for generated headers for each schema listed and sets
|
||||
# up depenedendies.
|
||||
#
|
||||
# More information and example usage can be found in the comments preceeding
|
||||
# each function.
|
||||
|
||||
# Targets to build the Flatbuffers compiler as well as some utility definitions
|
||||
ifeq (,$(FLATBUFFERS_INCLUDE_MK_))
|
||||
FLATBUFFERS_INCLUDE_MK_ := 1
|
||||
|
||||
# Portable version of $(realpath) that omits drive letters on Windows.
|
||||
realpath-portable = $(join $(filter %:,$(subst :,: ,$1)),\
|
||||
$(realpath $(filter-out %:,$(subst :,: ,$1))))
|
||||
|
||||
PROJECT_OS := $(OS)
|
||||
ifeq (,$(OS))
|
||||
PROJECT_OS := $(shell uname -s)
|
||||
else
|
||||
ifneq ($(findstring Windows,$(PROJECT_OS)),)
|
||||
PROJECT_OS := Windows
|
||||
endif
|
||||
endif
|
||||
|
||||
# The following block generates build rules which result in headers being
|
||||
# rebuilt from flatbuffers schemas.
|
||||
|
||||
FLATBUFFERS_CMAKELISTS_DIR := \
|
||||
$(call realpath-portable,$(dir $(lastword $(MAKEFILE_LIST)))/../..)
|
||||
|
||||
# Directory that contains the FlatBuffers compiler.
|
||||
ifeq (Windows,$(PROJECT_OS))
|
||||
FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR)
|
||||
FLATBUFFERS_FLATC := $(lastword \
|
||||
$(wildcard $(FLATBUFFERS_FLATC_PATH)/*/flatc.exe) \
|
||||
$(wildcard $(FLATBUFFERS_FLATC_PATH)/flatc.exe))
|
||||
endif
|
||||
ifeq (Linux,$(PROJECT_OS))
|
||||
FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR)
|
||||
FLATBUFFERS_FLATC := $(FLATBUFFERS_FLATC_PATH)/flatc
|
||||
endif
|
||||
ifeq (Darwin,$(PROJECT_OS))
|
||||
FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR)
|
||||
FLATBUFFERS_FLATC := $(lastword \
|
||||
$(wildcard $(FLATBUFFERS_FLATC_PATH)/*/flatc) \
|
||||
$(wildcard $(FLATBUFFERS_FLATC_PATH)/flatc))
|
||||
endif
|
||||
|
||||
FLATBUFFERS_FLATC_ARGS?=
|
||||
|
||||
# Search for cmake.
|
||||
CMAKE_ROOT := \
|
||||
$(call realpath-portable,$(LOCAL_PATH)/../../../../../../prebuilts/cmake)
|
||||
ifeq (,$(CMAKE))
|
||||
ifeq (Linux,$(PROJECT_OS))
|
||||
CMAKE := $(wildcard $(CMAKE_ROOT)/linux-x86/current/bin/cmake*)
|
||||
endif
|
||||
ifeq (Darwin,$(PROJECT_OS))
|
||||
CMAKE := \
|
||||
$(wildcard $(CMAKE_ROOT)/darwin-x86_64/current/*.app/Contents/bin/cmake)
|
||||
endif
|
||||
ifeq (Windows,$(PROJECT_OS))
|
||||
CMAKE := $(wildcard $(CMAKE_ROOT)/windows/current/bin/cmake*)
|
||||
endif
|
||||
endif
|
||||
ifeq (,$(CMAKE))
|
||||
CMAKE := cmake
|
||||
endif
|
||||
|
||||
# Windows friendly portable local path.
|
||||
# GNU-make doesn't like : in paths, must use relative paths on Windows.
|
||||
ifeq (Windows,$(PROJECT_OS))
|
||||
PORTABLE_LOCAL_PATH =
|
||||
else
|
||||
PORTABLE_LOCAL_PATH = $(LOCAL_PATH)/
|
||||
endif
|
||||
|
||||
# Generate a host build rule for the flatbuffers compiler.
|
||||
ifeq (Windows,$(PROJECT_OS))
|
||||
define build_flatc_recipe
|
||||
$(FLATBUFFERS_CMAKELISTS_DIR)\android\jni\build_flatc.bat \
|
||||
$(CMAKE) $(FLATBUFFERS_CMAKELISTS_DIR)
|
||||
endef
|
||||
endif
|
||||
ifeq (Linux,$(PROJECT_OS))
|
||||
define build_flatc_recipe
|
||||
+cd $(FLATBUFFERS_CMAKELISTS_DIR) && \
|
||||
$(CMAKE) . && \
|
||||
$(MAKE) flatc
|
||||
endef
|
||||
endif
|
||||
ifeq (Darwin,$(PROJECT_OS))
|
||||
define build_flatc_recipe
|
||||
cd $(FLATBUFFERS_CMAKELISTS_DIR) && "$(CMAKE)" -GXcode . && \
|
||||
xcodebuild -target flatc
|
||||
endef
|
||||
endif
|
||||
ifeq (,$(build_flatc_recipe))
|
||||
ifeq (,$(FLATBUFFERS_FLATC))
|
||||
$(error flatc binary not found!)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Generate a build rule for flatc.
|
||||
ifeq ($(strip $(FLATBUFFERS_FLATC)),)
|
||||
flatc_target := build_flatc
|
||||
.PHONY: $(flatc_target)
|
||||
FLATBUFFERS_FLATC := \
|
||||
python $(FLATBUFFERS_CMAKELISTS_DIR)/android/jni/run_flatc.py \
|
||||
$(FLATBUFFERS_CMAKELISTS_DIR)
|
||||
else
|
||||
flatc_target := $(FLATBUFFERS_FLATC)
|
||||
endif
|
||||
$(flatc_target):
|
||||
$(call build_flatc_recipe)
|
||||
|
||||
# $(flatbuffers_fbs_to_h schema_dir,output_dir,path)
|
||||
#
|
||||
# Convert the specified schema path to a Flatbuffers generated header path.
|
||||
# For example:
|
||||
#
|
||||
# $(call flatbuffers_fbs_to_h,$(MY_PROJ_DIR)/schemas,\
|
||||
# $(MY_PROJ_DIR)/gen/include,$(MY_PROJ_DIR)/schemas/example.fbs)
|
||||
#
|
||||
# This will convert the file path `$(MY_PROJ_DIR)/schemas/example.fbs)` to
|
||||
# `$(MY_PROJ_DIR)/gen/include/example_generated.h`
|
||||
define flatbuffers_fbs_to_h
|
||||
$(subst $(1),$(2),$(patsubst %.fbs,%_generated.h,$(3)))
|
||||
endef
|
||||
|
||||
# $(flatbuffers_header_build_rule schema_file,schema_dir,output_dir,\
|
||||
# schema_include_dirs)
|
||||
#
|
||||
# Generate a build rule that will convert a Flatbuffers schema to a generated
|
||||
# header derived from the schema filename using flatbuffers_fbs_to_h. For
|
||||
# example:
|
||||
#
|
||||
# $(call flatbuffers_header_build_rule,$(MY_PROJ_DIR)/schemas/example.fbs,\
|
||||
# $(MY_PROJ_DIR)/schemas,$(MY_PROJ_DIR)/gen/include)
|
||||
#
|
||||
# The final argument, schema_include_dirs, is optional and is only needed when
|
||||
# the schema files depend on other schema files outside their own directory.
|
||||
define flatbuffers_header_build_rule
|
||||
$(eval \
|
||||
$(call flatbuffers_fbs_to_h,$(2),$(3),$(1)): $(1) $(flatc_target)
|
||||
$(call host-echo-build-step,generic,Generate) \
|
||||
$(subst $(LOCAL_PATH)/,,$(call flatbuffers_fbs_to_h,$(2),$(3),$(1)))
|
||||
$(hide) $$(FLATBUFFERS_FLATC) $(FLATBUFFERS_FLATC_ARGS) \
|
||||
$(foreach include,$(4),-I $(include)) -o $$(dir $$@) -c $$<)
|
||||
endef
|
||||
|
||||
# TODO: Remove when the LOCAL_PATH expansion bug in the NDK is fixed.
|
||||
# Override the default behavior of local-source-file-path to workaround
|
||||
# a bug which prevents the build of deeply nested projects when NDK_OUT is
|
||||
# set.
|
||||
local-source-file-path=\
|
||||
$(if $(call host-path-is-absolute,$1),$1,$(call \
|
||||
realpath-portable,$(LOCAL_PATH)/$1))
|
||||
|
||||
|
||||
# $(flatbuffers_header_build_rules schema_files,schema_dir,output_dir,\
|
||||
# schema_include_dirs,src_files,[build_target],[dependencies]))
|
||||
#
|
||||
# $(1) schema_files: Space separated list of flatbuffer schema files.
|
||||
# $(2) schema_dir: Directory containing the flatbuffer schemas.
|
||||
# $(3) output_dir: Where to place the generated files.
|
||||
# $(4) schema_include_dirs: Directories to include when generating schemas.
|
||||
# $(5) src_files: Files that should depend upon the headers generated from the
|
||||
# flatbuffer schemas.
|
||||
# $(6) build_target: Name of a build target that depends upon all generated
|
||||
# headers.
|
||||
# $(7) dependencies: Space seperated list of additional build targets src_files
|
||||
# should depend upon.
|
||||
#
|
||||
# Use this in your own Android.mk file to generate build rules that will
|
||||
# generate header files for your flatbuffer schemas as well as automatically
|
||||
# set your source files to be dependent on the generated headers. For example:
|
||||
#
|
||||
# $(call flatbuffers_header_build_rules,$(MY_PROJ_SCHEMA_FILES),\
|
||||
# $(MY_PROJ_SCHEMA_DIR),$(MY_PROJ_GENERATED_OUTPUT_DIR),
|
||||
# $(MY_PROJ_SCHEMA_INCLUDE_DIRS),$(LOCAL_SRC_FILES))
|
||||
#
|
||||
# NOTE: Due problesm with path processing in ndk-build when presented with
|
||||
# deeply nested projects must redefine LOCAL_PATH after include this makefile
|
||||
# using:
|
||||
#
|
||||
# LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH))
|
||||
#
|
||||
define flatbuffers_header_build_rules
|
||||
$(foreach schema,$(1),\
|
||||
$(call flatbuffers_header_build_rule,\
|
||||
$(schema),$(strip $(2)),$(strip $(3)),$(strip $(4))))\
|
||||
$(foreach src,$(strip $(5)),\
|
||||
$(eval $(call local-source-file-path,$(src)): \
|
||||
$(foreach schema,$(strip $(1)),\
|
||||
$(call flatbuffers_fbs_to_h,$(strip $(2)),$(strip $(3)),$(schema)))))\
|
||||
$(if $(6),\
|
||||
$(foreach schema,$(strip $(1)),\
|
||||
$(eval $(6): \
|
||||
$(call flatbuffers_fbs_to_h,$(strip $(2)),$(strip $(3)),$(schema)))),)\
|
||||
$(if $(7),\
|
||||
$(foreach src,$(strip $(5)),\
|
||||
$(eval $(call local-source-file-path,$(src)): $(strip $(7)))),)\
|
||||
$(if $(7),\
|
||||
$(foreach dependency,$(strip $(7)),\
|
||||
$(eval $(6): $(dependency))),)
|
||||
endef
|
||||
|
||||
endif # FLATBUFFERS_INCLUDE_MK_
|
||||
0
android/jni/main.cpp
Executable file → Normal file
77
android/jni/msbuild.py
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Simple script that locates the newest MSBuild in one of several locations.
|
||||
|
||||
This script will find the highest version number of MSBuild and run it,
|
||||
passing its arguments through to MSBuild.
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
SYSTEMROOT = os.getenv("SYSTEMROOT", "c:\\windows")
|
||||
PROGRAM_FILES = os.getenv("ProgramFiles", "c:\\Program Files")
|
||||
PROGRAM_FILES_X86 = os.getenv("ProgramFiles(x86)", "c:\\Program Files (x86)")
|
||||
|
||||
SEARCH_FOLDERS = [ PROGRAM_FILES + "\\MSBuild\\*\\Bin\\MSBuild.exe",
|
||||
PROGRAM_FILES_X86 + "\\MSBuild\\*\\Bin\\MSBuild.exe",
|
||||
SYSTEMROOT + "\\Microsoft.NET\Framework\\*\\MSBuild.exe" ]
|
||||
|
||||
def compare_version(a, b):
|
||||
"""Compare two version number strings of the form W.X.Y.Z.
|
||||
|
||||
The numbers are compared most-significant to least-significant.
|
||||
For example, 12.345.67.89 > 2.987.88.99.
|
||||
|
||||
Args:
|
||||
a: First version number string to compare
|
||||
b: Second version number string to compare
|
||||
|
||||
Returns:
|
||||
0 if the numbers are identical, a positive number if 'a' is larger, and
|
||||
a negative number if 'b' is larger.
|
||||
"""
|
||||
aa = string.split(a, ".")
|
||||
bb = string.split(b, ".")
|
||||
for i in range(0, 4):
|
||||
if aa[i] != bb[i]:
|
||||
return cmp(int(aa[i]), int(bb[i]))
|
||||
return 0
|
||||
|
||||
def main():
|
||||
msbuilds = []
|
||||
|
||||
for folder in SEARCH_FOLDERS:
|
||||
for file in glob.glob(folder):
|
||||
p = subprocess.Popen([file, "/version"], stdout=subprocess.PIPE)
|
||||
out, err = p.communicate()
|
||||
match = re.search("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", out, re.M)
|
||||
if match:
|
||||
msbuilds.append({ 'ver':match.group(), 'exe':file })
|
||||
msbuilds.sort(lambda x, y: compare_version(x['ver'], y['ver']), reverse=True)
|
||||
if len(msbuilds) == 0:
|
||||
print "Unable to find MSBuild.\n"
|
||||
return -1;
|
||||
cmd = [msbuilds[0]['exe']]
|
||||
cmd.extend(sys.argv[1:])
|
||||
return subprocess.call(cmd)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
46
android/jni/run_flatc.py
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
EXECUTABLE_EXTENSION = '.exe' if platform.system() == 'Windows' else ''
|
||||
# Paths to search for flatc relative to the current working directory.
|
||||
FLATC_SEARCH_PATHS = [os.path.curdir, 'Release', 'Debug']
|
||||
|
||||
def main():
|
||||
"""Script that finds and runs flatc built from source."""
|
||||
if len(sys.argv) < 2:
|
||||
sys.stderr.write('Usage: run_flatc.py flatbuffers_dir [flatc_args]\n')
|
||||
return 1
|
||||
cwd = os.getcwd()
|
||||
flatc = ''
|
||||
flatbuffers_dir = sys.argv[1]
|
||||
for path in FLATC_SEARCH_PATHS:
|
||||
current = os.path.join(flatbuffers_dir, path,
|
||||
'flatc' + EXECUTABLE_EXTENSION)
|
||||
if os.path.exists(current):
|
||||
flatc = current
|
||||
break
|
||||
if not flatc:
|
||||
sys.stderr.write('flatc not found\n')
|
||||
return 1
|
||||
command = [flatc] + sys.argv[2:]
|
||||
return subprocess.call(command)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
7
biicode.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
# Biicode configuration file
|
||||
[paths]
|
||||
include
|
||||
[mains]
|
||||
!android/*
|
||||
[tests]
|
||||
tests/*
|
||||
21
biicode/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
Biicode C/C++ dependency manager
|
||||
=================================
|
||||
|
||||
[](https://www.biicode.com/fenix/flatbuffers)
|
||||
|
||||
New with biicode? Check the [Getting Started Guide](http://docs.biicode.com/c++/gettingstarted.html).
|
||||
|
||||
How to build it?
|
||||
------------------
|
||||
Building it is too easy:
|
||||
|
||||
$ git clone git@github.com:google/flatbuffers.git
|
||||
$ cd flatbuffers
|
||||
$ bii init -L && bii build
|
||||
$ ./bin/any_executable
|
||||
|
||||
Or run its tests:
|
||||
|
||||
$ bii test
|
||||
|
||||
You can check [the examples/flatbuffers block](https://www.biicode.com/examples/flatbuffers).
|
||||
18
biicode/cmake/biicode.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
set(BII_TESTS_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
# Copying data files to project/bin folder
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/samples")
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/monster.fbs"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/samples/monsterdata.json"
|
||||
DESTINATION
|
||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/samples")
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests"
|
||||
DESTINATION
|
||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
ADD_BIICODE_TARGETS()
|
||||
|
||||
string(REPLACE " " ";" REPLACED_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
target_compile_options(${BII_BLOCK_TARGET} INTERFACE ${REPLACED_FLAGS})
|
||||
16
biicode/support/bii-travis.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install libglu1-mesa-dev xorg-dev
|
||||
wget http://www.biicode.com/downloads/latest/ubuntu64
|
||||
mv ubuntu64 bii-ubuntu64.deb
|
||||
(sudo dpkg -i bii-ubuntu64.deb) && sudo apt-get -f install
|
||||
rm bii-ubuntu64.deb
|
||||
wget https://s3.amazonaws.com/biibinaries/thirdparty/cmake-3.0.2-Linux-64.tar.gz
|
||||
tar -xzf cmake-3.0.2-Linux-64.tar.gz
|
||||
sudo cp -fR cmake-3.0.2-Linux-64/* /usr
|
||||
rm -rf cmake-3.0.2-Linux-64
|
||||
rm cmake-3.0.2-Linux-64.tar.gz
|
||||
|
||||
cmake --version
|
||||
bii init -l && bii configure -DCMAKE_BUILD_TYPE=$1 && bii test
|
||||
@@ -266,12 +266,16 @@
|
||||
<ClInclude Include="..\..\include\flatbuffers\flatbuffers.h" />
|
||||
<ClInclude Include="..\..\include\flatbuffers\idl.h" />
|
||||
<ClInclude Include="..\..\include\flatbuffers\util.h" />
|
||||
<ClCompile Include="..\..\src\idl_gen_fbs.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_general.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_go.cpp">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\idl_gen_js.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_php.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_python.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_parser.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_cpp.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_java.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_text.cpp" />
|
||||
<ClCompile Include="..\..\src\flatc.cpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>..\..\tests</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommandArguments>-j -c -g -b -t monster_test.fbs monsterdata_test.golden</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerCommandArguments>-j -c -n -g --php --no-includes --gen-mutable monster_test.fbs</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommandArguments>-j -c -g -b -t monster_test.fbs monsterdata_test.golden</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerCommandArguments>-j -c -n -g -b -t monster_test.fbs monsterdata_test.golden</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommandArguments>-j -c -g -b -t monster_test.fbs monsterdata_test.golden</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerCommandArguments>-j -c -g -n -b -t monster_test.fbs monsterdata_test.golden</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerWorkingDirectory>..\..\tests</LocalDebuggerWorkingDirectory>
|
||||
|
||||
@@ -265,10 +265,14 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\flatbuffers\flatbuffers.h" />
|
||||
<ClInclude Include="..\..\include\flatbuffers\idl.h" />
|
||||
<ClInclude Include="..\..\include\flatbuffers\reflection.h" />
|
||||
<ClInclude Include="..\..\include\flatbuffers\util.h" />
|
||||
<ClInclude Include="..\..\tests\monster_test_generated.h" />
|
||||
<ClCompile Include="..\..\src\idl_gen_fbs.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_general.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_parser.cpp" />
|
||||
<ClCompile Include="..\..\src\idl_gen_text.cpp" />
|
||||
<ClCompile Include="..\..\src\reflection.cpp" />
|
||||
<ClCompile Include="..\..\tests\test.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -8,15 +8,22 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1963D7D2A57344A3B1C1713F /* idl_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3709AC883348409592530AE6 /* idl_parser.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
3343DD4ED370434BBA148FAB /* idl_gen_java.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3803689175184C7E8CB3EED0 /* idl_gen_java.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
5AC48C391ACA9A0A008132C5 /* idl_gen_general.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CD8717A19CB937D0012A827 /* idl_gen_general.cpp */; };
|
||||
61823BBC53544106B6DBC38E /* idl_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3709AC883348409592530AE6 /* idl_parser.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
61FF3C34FBEC4819A1C30F92 /* sample_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ECCEBFFA6977404F858F9739 /* sample_text.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
8C303C591975D6A700D7C1C5 /* idl_gen_go.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C303C581975D6A700D7C1C5 /* idl_gen_go.cpp */; };
|
||||
8C6905FD19F835B400CB8866 /* idl_gen_fbs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */; };
|
||||
8C78573E1BD5AE2C00C53C34 /* idl_gen_js.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C78573D1BD5AE2C00C53C34 /* idl_gen_js.cpp */; };
|
||||
8C8774631B703D4800E693F5 /* reflection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C8774621B703D4800E693F5 /* reflection.cpp */; };
|
||||
8C8774641B703E1200E693F5 /* idl_gen_fbs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */; };
|
||||
8CA854B31B04244A00040A06 /* idl_gen_python.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CA854B21B04244A00040A06 /* idl_gen_python.cpp */; };
|
||||
8CD8717B19CB937D0012A827 /* idl_gen_general.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CD8717A19CB937D0012A827 /* idl_gen_general.cpp */; };
|
||||
A9C9A99F719A4ED58DC2D2FC /* idl_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3709AC883348409592530AE6 /* idl_parser.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
AA9BACF55EB3456BA2F633BB /* flatc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DFD29781D8E490284B06504 /* flatc.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
AD71FEBEE4E846529002C1F0 /* idl_gen_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
AE5F47A7DCB44781B657F062 /* idl_gen_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
BE03D7B0C9584DD58B50ED34 /* idl_gen_cpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD90A7F6B2BE4D0384294DD1 /* idl_gen_cpp.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
D2DA271D1BFFBC06000F9168 /* idl_gen_php.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2DA271C1BFFBC06000F9168 /* idl_gen_php.cpp */; };
|
||||
E0680D6B5BFD484BA9D88EE8 /* idl_gen_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
E84E4B7612DF4C369DC24843 /* sample_binary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EE44BFFAF8E43F485859145 /* sample_binary.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
EE4AEE138D684B30A1BF5462 /* test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6AD24EEB3D024825A37741FF /* test.cpp */; settings = {COMPILER_FLAGS = ""; }; };
|
||||
@@ -27,50 +34,40 @@
|
||||
0DFD29781D8E490284B06504 /* flatc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = flatc.cpp; path = src/flatc.cpp; sourceTree = SOURCE_ROOT; };
|
||||
18185F364F604E648CF6EE25 /* flatc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = flatc; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3709AC883348409592530AE6 /* idl_parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_parser.cpp; path = src/idl_parser.cpp; sourceTree = SOURCE_ROOT; };
|
||||
3803689175184C7E8CB3EED0 /* idl_gen_java.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_java.cpp; path = src/idl_gen_java.cpp; sourceTree = SOURCE_ROOT; };
|
||||
3863042BCEC64791BFB48625 /* flatsamplebinary */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = flatsamplebinary; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
420E3BC724ED4A008D79297F /* flatsampletext */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = flatsampletext; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
423CA92401AE442B91546E63 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CMakeLists.txt; path = /Users/wvo/flatbuffers_snapshot9/CMakeLists.txt; sourceTree = "<absolute>"; };
|
||||
5EE44BFFAF8E43F485859145 /* sample_binary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sample_binary.cpp; path = samples/sample_binary.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6AD24EEB3D024825A37741FF /* test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = test.cpp; path = tests/test.cpp; sourceTree = SOURCE_ROOT; };
|
||||
8C303C581975D6A700D7C1C5 /* idl_gen_go.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_go.cpp; path = src/idl_gen_go.cpp; sourceTree = "<group>"; };
|
||||
8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_fbs.cpp; path = src/idl_gen_fbs.cpp; sourceTree = "<group>"; };
|
||||
8C78573D1BD5AE2C00C53C34 /* idl_gen_js.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_js.cpp; path = src/idl_gen_js.cpp; sourceTree = "<group>"; };
|
||||
8C8774621B703D4800E693F5 /* reflection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = reflection.cpp; path = src/reflection.cpp; sourceTree = "<group>"; };
|
||||
8CA854B21B04244A00040A06 /* idl_gen_python.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_python.cpp; path = src/idl_gen_python.cpp; sourceTree = "<group>"; };
|
||||
8CD8717A19CB937D0012A827 /* idl_gen_general.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_general.cpp; path = src/idl_gen_general.cpp; sourceTree = "<group>"; };
|
||||
A13F25CDAD23435DA293690D /* flattests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = flattests; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
AB70F1FBA50E4120BCF37C8D /* monster_test_generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = monster_test_generated.h; path = tests/monster_test_generated.h; sourceTree = SOURCE_ROOT; };
|
||||
AD3682C6E1DD4EABB822C0CC /* monster_generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = monster_generated.h; path = samples/monster_generated.h; sourceTree = SOURCE_ROOT; };
|
||||
C0E7B66C3FF849A0AD9A7168 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = util.h; path = include/flatbuffers/util.h; sourceTree = SOURCE_ROOT; };
|
||||
CD90A7F6B2BE4D0384294DD1 /* idl_gen_cpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_cpp.cpp; path = src/idl_gen_cpp.cpp; sourceTree = SOURCE_ROOT; };
|
||||
D2DA271C1BFFBC06000F9168 /* idl_gen_php.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_php.cpp; path = src/idl_gen_php.cpp; sourceTree = "<group>"; };
|
||||
DD8B353D4756412195777FBA /* flatbuffers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = flatbuffers.h; path = include/flatbuffers/flatbuffers.h; sourceTree = SOURCE_ROOT; };
|
||||
ECCEBFFA6977404F858F9739 /* sample_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sample_text.cpp; path = samples/sample_text.cpp; sourceTree = SOURCE_ROOT; };
|
||||
F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_text.cpp; path = src/idl_gen_text.cpp; sourceTree = SOURCE_ROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
194905BCBB5C451DB092EB08 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
28237E300FE042DEADA302D3 /* Source Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D2DA271C1BFFBC06000F9168 /* idl_gen_php.cpp */,
|
||||
8C78573D1BD5AE2C00C53C34 /* idl_gen_js.cpp */,
|
||||
8CA854B21B04244A00040A06 /* idl_gen_python.cpp */,
|
||||
8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */,
|
||||
8CD8717A19CB937D0012A827 /* idl_gen_general.cpp */,
|
||||
8C303C581975D6A700D7C1C5 /* idl_gen_go.cpp */,
|
||||
0DFD29781D8E490284B06504 /* flatc.cpp */,
|
||||
F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */,
|
||||
3709AC883348409592530AE6 /* idl_parser.cpp */,
|
||||
CD90A7F6B2BE4D0384294DD1 /* idl_gen_cpp.cpp */,
|
||||
3803689175184C7E8CB3EED0 /* idl_gen_java.cpp */,
|
||||
F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */,
|
||||
3709AC883348409592530AE6 /* idl_parser.cpp */,
|
||||
);
|
||||
name = "Source Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
355DCA17961E4B2FB2C71403 /* Source Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */,
|
||||
3709AC883348409592530AE6 /* idl_parser.cpp */,
|
||||
6AD24EEB3D024825A37741FF /* test.cpp */,
|
||||
8C8774621B703D4800E693F5 /* reflection.cpp */,
|
||||
);
|
||||
name = "Source Files";
|
||||
sourceTree = "<group>";
|
||||
@@ -78,52 +75,11 @@
|
||||
378446B9D5EF46EF92B35E21 /* flatc */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5FEA84E7D39645988300317C /* Header Files */,
|
||||
28237E300FE042DEADA302D3 /* Source Files */,
|
||||
423CA92401AE442B91546E63 /* CMakeLists.txt */,
|
||||
0DFD29781D8E490284B06504 /* flatc.cpp */,
|
||||
);
|
||||
name = flatc;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
40E30B8480BD493EA459E9B4 /* Header Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DD8B353D4756412195777FBA /* flatbuffers.h */,
|
||||
00154BD8654B4B5B9FF45FA6 /* idl.h */,
|
||||
C0E7B66C3FF849A0AD9A7168 /* util.h */,
|
||||
AD3682C6E1DD4EABB822C0CC /* monster_generated.h */,
|
||||
);
|
||||
name = "Header Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4D1151F6FE594E40A1C177FF /* Header Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DD8B353D4756412195777FBA /* flatbuffers.h */,
|
||||
AD3682C6E1DD4EABB822C0CC /* monster_generated.h */,
|
||||
);
|
||||
name = "Header Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5235469653ED4BC88A6C504D /* Header Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DD8B353D4756412195777FBA /* flatbuffers.h */,
|
||||
00154BD8654B4B5B9FF45FA6 /* idl.h */,
|
||||
C0E7B66C3FF849A0AD9A7168 /* util.h */,
|
||||
AB70F1FBA50E4120BCF37C8D /* monster_test_generated.h */,
|
||||
);
|
||||
name = "Header Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5648A71028E14478841372D3 /* Source Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5EE44BFFAF8E43F485859145 /* sample_binary.cpp */,
|
||||
);
|
||||
name = "Source Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5FEA84E7D39645988300317C /* Header Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -137,6 +93,8 @@
|
||||
866694F9F2F7451382D236B3 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
28237E300FE042DEADA302D3 /* Source Files */,
|
||||
5FEA84E7D39645988300317C /* Header Files */,
|
||||
378446B9D5EF46EF92B35E21 /* flatc */,
|
||||
DB9DE41C20F349F694A488F3 /* flatsamplebinary */,
|
||||
8FA1F43C78914AE5AD04E24E /* flatsampletext */,
|
||||
@@ -148,8 +106,8 @@
|
||||
88421F5F87584EE3B67C979A /* flattests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5235469653ED4BC88A6C504D /* Header Files */,
|
||||
355DCA17961E4B2FB2C71403 /* Source Files */,
|
||||
AB70F1FBA50E4120BCF37C8D /* monster_test_generated.h */,
|
||||
6AD24EEB3D024825A37741FF /* test.cpp */,
|
||||
);
|
||||
name = flattests;
|
||||
sourceTree = "<group>";
|
||||
@@ -158,7 +116,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
866694F9F2F7451382D236B3 /* Sources */,
|
||||
194905BCBB5C451DB092EB08 /* Resources */,
|
||||
99CC11E382B8420AA79A8A14 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
@@ -166,8 +123,7 @@
|
||||
8FA1F43C78914AE5AD04E24E /* flatsampletext */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
40E30B8480BD493EA459E9B4 /* Header Files */,
|
||||
A1C826615F904FDE8F0CA154 /* Source Files */,
|
||||
ECCEBFFA6977404F858F9739 /* sample_text.cpp */,
|
||||
);
|
||||
name = flatsampletext;
|
||||
sourceTree = "<group>";
|
||||
@@ -183,22 +139,10 @@
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A1C826615F904FDE8F0CA154 /* Source Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ECCEBFFA6977404F858F9739 /* sample_text.cpp */,
|
||||
F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */,
|
||||
3709AC883348409592530AE6 /* idl_parser.cpp */,
|
||||
);
|
||||
name = "Source Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
DB9DE41C20F349F694A488F3 /* flatsamplebinary */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4D1151F6FE594E40A1C177FF /* Header Files */,
|
||||
5648A71028E14478841372D3 /* Source Files */,
|
||||
423CA92401AE442B91546E63 /* CMakeLists.txt */,
|
||||
5EE44BFFAF8E43F485859145 /* sample_binary.cpp */,
|
||||
);
|
||||
name = flatsamplebinary;
|
||||
sourceTree = "<group>";
|
||||
@@ -273,7 +217,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastUpgradeCheck = 0510;
|
||||
LastUpgradeCheck = 0700;
|
||||
};
|
||||
buildConfigurationList = 6428BEB363AA4E03A282AA8C /* Build configuration list for PBXProject "FlatBuffers" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
@@ -320,9 +264,13 @@
|
||||
8C303C591975D6A700D7C1C5 /* idl_gen_go.cpp in Sources */,
|
||||
AA9BACF55EB3456BA2F633BB /* flatc.cpp in Sources */,
|
||||
BE03D7B0C9584DD58B50ED34 /* idl_gen_cpp.cpp in Sources */,
|
||||
3343DD4ED370434BBA148FAB /* idl_gen_java.cpp in Sources */,
|
||||
AD71FEBEE4E846529002C1F0 /* idl_gen_text.cpp in Sources */,
|
||||
8C8774641B703E1200E693F5 /* idl_gen_fbs.cpp in Sources */,
|
||||
A9C9A99F719A4ED58DC2D2FC /* idl_parser.cpp in Sources */,
|
||||
8CA854B31B04244A00040A06 /* idl_gen_python.cpp in Sources */,
|
||||
8CD8717B19CB937D0012A827 /* idl_gen_general.cpp in Sources */,
|
||||
8C78573E1BD5AE2C00C53C34 /* idl_gen_js.cpp in Sources */,
|
||||
D2DA271D1BFFBC06000F9168 /* idl_gen_php.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -330,6 +278,9 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8C8774631B703D4800E693F5 /* reflection.cpp in Sources */,
|
||||
5AC48C391ACA9A0A008132C5 /* idl_gen_general.cpp in Sources */,
|
||||
8C6905FD19F835B400CB8866 /* idl_gen_fbs.cpp in Sources */,
|
||||
E0680D6B5BFD484BA9D88EE8 /* idl_gen_text.cpp in Sources */,
|
||||
61823BBC53544106B6DBC38E /* idl_parser.cpp in Sources */,
|
||||
EE4AEE138D684B30A1BF5462 /* test.cpp in Sources */,
|
||||
@@ -344,7 +295,7 @@
|
||||
buildSettings = {
|
||||
CONFIGURATION_BUILD_DIR = .;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk;
|
||||
SDKROOT = macosx;
|
||||
SYMROOT = build;
|
||||
};
|
||||
name = RelWithDebInfo;
|
||||
@@ -352,6 +303,11 @@
|
||||
04681CC521204B3B87BB1E81 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_WARN_ASSIGN_ENUM = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
|
||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
EXECUTABLE_PREFIX = "";
|
||||
EXECUTABLE_SUFFIX = "";
|
||||
@@ -360,6 +316,25 @@
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'";
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
|
||||
GCC_WARN_PEDANTIC = YES;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNKNOWN_PRAGMAS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_LABEL = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/include";
|
||||
INSTALL_PATH = "";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
@@ -457,6 +432,11 @@
|
||||
33335DE09CF844709E9E4AA9 /* RelWithDebInfo */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_WARN_ASSIGN_ENUM = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
|
||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
EXECUTABLE_PREFIX = "";
|
||||
EXECUTABLE_SUFFIX = "";
|
||||
@@ -465,6 +445,25 @@
|
||||
GCC_OPTIMIZATION_LEVEL = 2;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'";
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
|
||||
GCC_WARN_PEDANTIC = YES;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNKNOWN_PRAGMAS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_LABEL = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/include";
|
||||
INSTALL_PATH = "";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
@@ -496,6 +495,11 @@
|
||||
33B3983234F648E28F058235 /* MinSizeRel */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_WARN_ASSIGN_ENUM = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
|
||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
EXECUTABLE_PREFIX = "";
|
||||
EXECUTABLE_SUFFIX = "";
|
||||
@@ -504,6 +508,25 @@
|
||||
GCC_OPTIMIZATION_LEVEL = s;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'";
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
|
||||
GCC_WARN_PEDANTIC = YES;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNKNOWN_PRAGMAS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_LABEL = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/include";
|
||||
INSTALL_PATH = "";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
@@ -574,6 +597,11 @@
|
||||
37C0FFB777CF4C19BD7AA662 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_WARN_ASSIGN_ENUM = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
|
||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
EXECUTABLE_PREFIX = "";
|
||||
EXECUTABLE_SUFFIX = "";
|
||||
@@ -582,6 +610,25 @@
|
||||
GCC_OPTIMIZATION_LEVEL = 3;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'";
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
|
||||
GCC_WARN_PEDANTIC = YES;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNKNOWN_PRAGMAS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_LABEL = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/include";
|
||||
INSTALL_PATH = "";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
@@ -764,8 +811,9 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CONFIGURATION_BUILD_DIR = .;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk;
|
||||
SDKROOT = macosx;
|
||||
SYMROOT = build;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -775,7 +823,7 @@
|
||||
buildSettings = {
|
||||
CONFIGURATION_BUILD_DIR = .;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk;
|
||||
SDKROOT = macosx;
|
||||
SYMROOT = build;
|
||||
};
|
||||
name = Release;
|
||||
@@ -935,7 +983,7 @@
|
||||
buildSettings = {
|
||||
CONFIGURATION_BUILD_DIR = .;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk;
|
||||
SDKROOT = macosx;
|
||||
SYMROOT = build;
|
||||
};
|
||||
name = MinSizeRel;
|
||||
|
||||
18
composer.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "google/flatbuffers",
|
||||
"type": "library",
|
||||
"description": "FlatBuffers for PHP",
|
||||
"keywords": ["google", "flatbuffers", "serialization"],
|
||||
"homepage": "https://github.com/google/flatbuffers",
|
||||
"license": "Apache-2.0",
|
||||
"require": {
|
||||
"php": ">=5.4"
|
||||
},
|
||||
"require-dev": {
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Google\\FlatBuffers\\": "php"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;url=html/index.html">
|
||||
</head>
|
||||
<body>
|
||||
<a href="html/index.html">Click here if you are not redirected.</a>
|
||||
</body>
|
||||
</html>
|
||||
62
docs/header.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<!-- HTML header for doxygen 1.8.6-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,500italic,700,700italic|Roboto+Mono:400,700" rel="stylesheet">
|
||||
$extrastylesheet
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea" style="height: 110px;">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<td id="commonprojectlogo">
|
||||
<img alt="Logo" src="$relpath^fpl_logo_small.png"/>
|
||||
</td>
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">$projectname
|
||||
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<div style="font-size:12px;">
|
||||
An open source project by <a href="https://developers.google.com/games/#Tools">FPL</a>.
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>$searchbox</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
<!-- end header part -->
|
||||
|
Before Width: | Height: | Size: 676 B |
|
Before Width: | Height: | Size: 147 B |
|
Before Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 3.7 KiB |
@@ -1,97 +0,0 @@
|
||||
function toggleVisibility(linkObj)
|
||||
{
|
||||
var base = $(linkObj).attr('id');
|
||||
var summary = $('#'+base+'-summary');
|
||||
var content = $('#'+base+'-content');
|
||||
var trigger = $('#'+base+'-trigger');
|
||||
var src=$(trigger).attr('src');
|
||||
if (content.is(':visible')===true) {
|
||||
content.hide();
|
||||
summary.show();
|
||||
$(linkObj).addClass('closed').removeClass('opened');
|
||||
$(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
|
||||
} else {
|
||||
content.show();
|
||||
summary.hide();
|
||||
$(linkObj).removeClass('closed').addClass('opened');
|
||||
$(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateStripes()
|
||||
{
|
||||
$('table.directory tr').
|
||||
removeClass('even').filter(':visible:even').addClass('even');
|
||||
}
|
||||
|
||||
function toggleLevel(level)
|
||||
{
|
||||
$('table.directory tr').each(function() {
|
||||
var l = this.id.split('_').length-1;
|
||||
var i = $('#img'+this.id.substring(3));
|
||||
var a = $('#arr'+this.id.substring(3));
|
||||
if (l<level+1) {
|
||||
i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
|
||||
a.html('▼');
|
||||
$(this).show();
|
||||
} else if (l==level+1) {
|
||||
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
|
||||
a.html('►');
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
updateStripes();
|
||||
}
|
||||
|
||||
function toggleFolder(id)
|
||||
{
|
||||
// the clicked row
|
||||
var currentRow = $('#row_'+id);
|
||||
|
||||
// all rows after the clicked row
|
||||
var rows = currentRow.nextAll("tr");
|
||||
|
||||
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
|
||||
|
||||
// only match elements AFTER this one (can't hide elements before)
|
||||
var childRows = rows.filter(function() { return this.id.match(re); });
|
||||
|
||||
// first row is visible we are HIDING
|
||||
if (childRows.filter(':first').is(':visible')===true) {
|
||||
// replace down arrow by right arrow for current row
|
||||
var currentRowSpans = currentRow.find("span");
|
||||
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
|
||||
currentRowSpans.filter(".arrow").html('►');
|
||||
rows.filter("[id^=row_"+id+"]").hide(); // hide all children
|
||||
} else { // we are SHOWING
|
||||
// replace right arrow by down arrow for current row
|
||||
var currentRowSpans = currentRow.find("span");
|
||||
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
|
||||
currentRowSpans.filter(".arrow").html('▼');
|
||||
// replace down arrows by right arrows for child rows
|
||||
var childRowsSpans = childRows.find("span");
|
||||
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
|
||||
childRowsSpans.filter(".arrow").html('►');
|
||||
childRows.show(); //show all children
|
||||
}
|
||||
updateStripes();
|
||||
}
|
||||
|
||||
|
||||
function toggleInherit(id)
|
||||
{
|
||||
var rows = $('tr.inherit.'+id);
|
||||
var img = $('tr.inherit_header.'+id+' img');
|
||||
var src = $(img).attr('src');
|
||||
if (rows.filter(':first').is(':visible')===true) {
|
||||
rows.css('display','none');
|
||||
$(img).attr('src',src.substring(0,src.length-8)+'closed.png');
|
||||
} else {
|
||||
rows.css('display','table-row'); // using show() causes jump in firefox
|
||||
$(img).attr('src',src.substring(0,src.length-10)+'open.png');
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 453 B |
|
Before Width: | Height: | Size: 746 B |
|
Before Width: | Height: | Size: 616 B |
|
Before Width: | Height: | Size: 597 B |
|
Before Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 746 B |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 388 B |
|
Before Width: | Height: | Size: 229 B |
|
Before Width: | Height: | Size: 229 B |
|
Before Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 86 B |
@@ -1,116 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Main Page</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('index.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">FlatBuffers Documentation</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>FlatBuffers is an efficient cross platform serialization library for C++, with support for Java and Go. It was created at Google specifically for game development and other performance-critical applications.</p>
|
||||
<p>It is available as open source under the Apache license, v2 (see LICENSE.txt).</p>
|
||||
<h2>Why use FlatBuffers?</h2>
|
||||
<ul>
|
||||
<li><b>Access to serialized data without parsing/unpacking</b> - What sets FlatBuffers apart is that it represents hierarchical data in a flat binary buffer in such a way that it can still be accessed directly without parsing/unpacking, while also still supporting data structure evolution (forwards/backwards compatibility).</li>
|
||||
<li><b>Memory efficiency and speed</b> - The only memory needed to access your data is that of the buffer. It requires 0 additional allocations. FlatBuffers is also very suitable for use with mmap (or streaming), requiring only part of the buffer to be in memory. Access is close to the speed of raw struct access with only one extra indirection (a kind of vtable) to allow for format evolution and optional fields. It is aimed at projects where spending time and space (many memory allocations) to be able to access or construct serialized data is undesirable, such as in games or any other performance sensitive applications. See the <a href="md__benchmarks.html">benchmarks</a> for details.</li>
|
||||
<li><b>Flexible</b> - Optional fields means not only do you get great forwards and backwards compatibility (increasingly important for long-lived games: don't have to update all data with each new version!). It also means you have a lot of choice in what data you write and what data you don't, and how you design data structures.</li>
|
||||
<li><b>Tiny code footprint</b> - Small amounts of generated code, and just a single small header as the minimum dependency, which is very easy to integrate. Again, see the benchmark section for details.</li>
|
||||
<li><b>Strongly typed</b> - Errors happen at compile time rather than manually having to write repetitive and error prone run-time checks. Useful code can be generated for you.</li>
|
||||
<li><p class="startli"><b>Convenient to use</b> - Generated C++ code allows for terse access & construction code. Then there's optional functionality for parsing schemas and JSON-like text representations at runtime efficiently if needed (faster and more memory efficient than other JSON parsers).</p>
|
||||
<p class="startli">Java and Go code supports object-reuse.</p>
|
||||
</li>
|
||||
<li><b>Cross platform C++11/Java/Go code with no dependencies</b> - will work with any recent gcc/clang and VS2010. Comes with build files for the tests & samples (Android .mk files, and cmake for all other platforms).</li>
|
||||
</ul>
|
||||
<h3>Why not use Protocol Buffers, or .. ?</h3>
|
||||
<p>Protocol Buffers is indeed relatively similar to FlatBuffers, with the primary difference being that FlatBuffers does not need a parsing/ unpacking step to a secondary representation before you can access data, often coupled with per-object memory allocation. The code is an order of magnitude bigger, too. Protocol Buffers has neither optional text import/export nor schema language features like unions.</p>
|
||||
<h3>But all the cool kids use JSON!</h3>
|
||||
<p>JSON is very readable (which is why we use it as our optional text format) and very convenient when used together with dynamically typed languages (such as JavaScript). When serializing data from statically typed languages, however, JSON not only has the obvious drawback of runtime inefficiency, but also forces you to write <em>more</em> code to access data (counterintuitively) due to its dynamic-typing serialization system. In this context, it is only a better choice for systems that have very little to no information ahead of time about what data needs to be stored.</p>
|
||||
<p>Read more about the "why" of FlatBuffers in the <a href="md__white_paper.html">white paper</a>.</p>
|
||||
<h2>Usage in brief</h2>
|
||||
<p>This section is a quick rundown of how to use this system. Subsequent sections provide a more in-depth usage guide.</p>
|
||||
<ul>
|
||||
<li>Write a schema file that allows you to define the data structures you may want to serialize. Fields can have a scalar type (ints/floats of all sizes), or they can be a: string; array of any type; reference to yet another object; or, a set of possible objects (unions). Fields are optional and have defaults, so they don't need to be present for every object instance.</li>
|
||||
<li>Use <code>flatc</code> (the FlatBuffer compiler) to generate a C++ header (or Java/Go classes) with helper classes to access and construct serialized data. This header (say <code>mydata_generated.h</code>) only depends on <code>flatbuffers.h</code>, which defines the core functionality.</li>
|
||||
<li>Use the <code>FlatBufferBuilder</code> class to construct a flat binary buffer. The generated functions allow you to add objects to this buffer recursively, often as simply as making a single function call.</li>
|
||||
<li>Store or send your buffer somewhere!</li>
|
||||
<li>When reading it back, you can obtain the pointer to the root object from the binary buffer, and from there traverse it conveniently in-place with <code>object->field()</code>.</li>
|
||||
</ul>
|
||||
<h2>In-depth documentation</h2>
|
||||
<ul>
|
||||
<li>How to <a href="md__building.html">build the compiler</a> and samples on various platforms.</li>
|
||||
<li>How to <a href="md__compiler.html">use the compiler</a>.</li>
|
||||
<li>How to <a href="md__schemas.html">write a schema</a>.</li>
|
||||
<li>How to <a href="md__cpp_usage.html">use the generated C++ code</a> in your own programs.</li>
|
||||
<li>How to <a href="md__java_usage.html">use the generated Java code</a> in your own programs.</li>
|
||||
<li>How to <a href="md__go_usage.html">use the generated Go code</a> in your own programs.</li>
|
||||
<li>Some <a href="md__benchmarks.html">benchmarks</a> showing the advantage of using FlatBuffers.</li>
|
||||
<li>A <a href="md__white_paper.html">white paper</a> explaining the "why" of FlatBuffers.</li>
|
||||
<li>A description of the <a href="md__internals.html">internals</a> of FlatBuffers.</li>
|
||||
<li>A formal <a href="md__grammar.html">grammar</a> of the schema language.</li>
|
||||
</ul>
|
||||
<h2>Online resources</h2>
|
||||
<ul>
|
||||
<li><a href="http://github.com/google/flatbuffers">github repository</a></li>
|
||||
<li><a href="http://google.github.io/flatbuffers">landing page</a></li>
|
||||
<li><a href="http://group.google.com/group/flatbuffers">FlatBuffers Google Group</a></li>
|
||||
<li><a href="http://github.com/google/flatbuffers/issues">FlatBuffers Issues Tracker</a> </li>
|
||||
</ul>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
72
docs/html/jquery.js
vendored
@@ -1,102 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Benchmarks</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__benchmarks.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Benchmarks </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>Comparing against other serialization solutions, running on Windows 7 64bit. We use the LITE runtime for Protocol Buffers (less code / lower overhead), Rapid JSON (one of the fastest C++ JSON parsers around), and pugixml, also one of the fastest XML parsers.</p>
|
||||
<p>We compare against Flatbuffers with the binary wire format (as intended), and also with JSON as the wire format with the optional JSON parser (which, using a schema, parses JSON into a binary buffer that can then be accessed as before).</p>
|
||||
<p>The benchmark object is a set of about 10 objects containing an array, 4 strings, and a large variety of int/float scalar values of all sizes, meant to be representative of game data, e.g. a scene format.</p>
|
||||
<table class="doxtable">
|
||||
<tr>
|
||||
<th></th><th>FlatBuffers (binary) </th><th>Protocol Buffers LITE </th><th>Rapid JSON </th><th>FlatBuffers (JSON) </th><th>pugixml </th></tr>
|
||||
<tr>
|
||||
<td>Decode + Traverse + Dealloc (1 million times, seconds) </td><td>0.08 </td><td>302 </td><td>583 </td><td>105 </td><td>196 </td></tr>
|
||||
<tr>
|
||||
<td>Decode / Traverse / Dealloc (breakdown) </td><td>0 / 0.08 / 0 </td><td>220 / 0.15 / 81 </td><td>294 / 0.9 / 287 </td><td>70 / 0.08 / 35 </td><td>41 / 3.9 / 150 </td></tr>
|
||||
<tr>
|
||||
<td>Encode (1 million times, seconds) </td><td>3.2 </td><td>185 </td><td>650 </td><td>169 </td><td>273 </td></tr>
|
||||
<tr>
|
||||
<td>Wire format size (normal / zlib, bytes) </td><td>344 / 220 </td><td>228 / 174 </td><td>1475 / 322 </td><td>1029 / 298 </td><td>1137 / 341 </td></tr>
|
||||
<tr>
|
||||
<td>Memory needed to store decoded wire (bytes / blocks) </td><td>0 / 0 </td><td>760 / 20 </td><td>65689 / 4 </td><td>328 / 1 </td><td>34194 / 3 </td></tr>
|
||||
<tr>
|
||||
<td>Transient memory allocated during decode (KB) </td><td>0 </td><td>1 </td><td>131 </td><td>4 </td><td>34 </td></tr>
|
||||
<tr>
|
||||
<td>Generated source code size (KB) </td><td>4 </td><td>61 </td><td>0 </td><td>4 </td><td>0 </td></tr>
|
||||
<tr>
|
||||
<td>Field access in handwritten traversal code </td><td>typed accessors </td><td>typed accessors </td><td>manual error checking </td><td>typed accessors </td><td>manual error checking </td></tr>
|
||||
<tr>
|
||||
<td>Library source code (KB) </td><td>15 </td><td>some subset of 3800 </td><td>87 </td><td>43 </td><td>327 </td></tr>
|
||||
</table>
|
||||
<h3>Some other serialization systems we compared against but did not benchmark (yet), in rough order of applicability:</h3>
|
||||
<ul>
|
||||
<li>Cap'n'Proto promises to reduce Protocol Buffers much like FlatBuffers does, though with a more complicated binary encoding and less flexibility (no optional fields to allow deprecating fields or serializing with missing fields for which defaults exist). It currently also isn't fully cross-platform portable (lack of VS support).</li>
|
||||
<li>msgpack: has very minimal forwards/backwards compatability support when used with the typed C++ interface. Also lacks VS2010 support.</li>
|
||||
<li>Thrift: very similar to Protocol Buffers, but appears to be less efficient, and have more dependencies.</li>
|
||||
<li>YAML: a superset of JSON and otherwise very similar. Used by e.g. Unity.</li>
|
||||
<li>C# comes with built-in serialization functionality, as used by Unity also. Being tied to the language, and having no automatic versioning support limits its applicability.</li>
|
||||
<li>Project Anarchy (the free mobile engine by Havok) comes with a serialization system, that however does no automatic versioning (have to code around new fields manually), is very much tied to the rest of the engine, and works without a schema to generate code (tied to your C++ class definition). </li>
|
||||
</ul>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,79 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Building</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__building.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Building </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>There are project files for Visual Studio and Xcode that should allow you to build the compiler <code>flatc</code>, the samples and the tests out of the box.</p>
|
||||
<p>Alternatively, the distribution comes with a <code>cmake</code> file that should allow you to build project/make files for any platform. For details on <code>cmake</code>, see <a href="http://www.cmake.org">http://www.cmake.org</a>. In brief, depending on your platform, use one of e.g.: </p><pre class="fragment">cmake -G "Unix Makefiles"
|
||||
cmake -G "Visual Studio 10"
|
||||
cmake -G "Xcode"
|
||||
</pre><p>Then, build as normal for your platform. This should result in a <code>flatc</code> executable, essential for the next steps. Note that to use clang instead of gcc, you may need to set up your environment variables, e.g. <code>CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -G "Unix Makefiles"</code>.</p>
|
||||
<p>Optionally, run the <code>flattests</code> executable to ensure everything is working correctly on your system. If this fails, please contact us!</p>
|
||||
<p>Note that you MUST be in the root of the FlatBuffers distribution when you run 'flattests' (and the samples), or it will fail to load its files.</p>
|
||||
<p>Building should also produce two sample executables, <code>sample_binary</code> and <code>sample_text</code>, see the corresponding <code>.cpp</code> file in the samples directory.</p>
|
||||
<p>There is an <code>android</code> directory that contains all you need to build the test executable on android (use the included <code>build_apk.sh</code> script, or use <code>ndk_build</code> / <code>adb</code> etc. as usual). Upon running, it will output to the log if tests succeeded or not.</p>
|
||||
<p>There is usually no runtime to compile, as the code consists of a single header, <code>include/flatbuffers/flatbuffers.h</code>. You should add the <code>include</code> folder to your include paths. If you wish to be able to load schemas and/or parse text into binary buffers at runtime, you additionally need the other headers in <code>include/flatbuffers</code>. You must also compile/link <code>src/idl_parser.cpp</code> (and <code>src/idl_gen_text.cpp</code> if you also want to be able convert binary to text).</p>
|
||||
<p>For applications on Google Play that integrate this library, usage is tracked. This tracking is done automatically using the embedded version string (flatbuffer_version_string), and helps us continue to optimize it. Aside from consuming a few extra bytes in your application binary, it shouldn't affect your application at all. We use this information to let us know if FlatBuffers is useful and if we should continue to invest in it. Since this is open source, you are free to remove the version string but we would appreciate if you would leave it in. </p>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,81 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Using the schema compiler</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__compiler.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Using the schema compiler </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>Usage: </p><pre class="fragment">flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -S ] FILES...
|
||||
[ -- FILES...]
|
||||
</pre><p>The files are read and parsed in order, and can contain either schemas or data (see below). Later files can make use of definitions in earlier files.</p>
|
||||
<p><code>--</code> indicates that the following files are binary files in FlatBuffer format conforming to the schema(s) indicated before it. Incompatible binary files currently will give unpredictable results (!)</p>
|
||||
<p>Depending on the flags passed, additional files may be generated for each file processed:</p>
|
||||
<ul>
|
||||
<li><code>-c</code> : Generate a C++ header for all definitions in this file (as <code>filename_generated.h</code>). Skipped for data.</li>
|
||||
<li><code>-j</code> : Generate Java classes. Skipped for data.</li>
|
||||
<li><code>-b</code> : If data is contained in this file, generate a <code>filename.bin</code> containing the binary flatbuffer.</li>
|
||||
<li><code>-t</code> : If data is contained in this file, generate a <code>filename.json</code> representing the data in the flatbuffer.</li>
|
||||
<li><code>-o PATH</code> : Output all generated files to PATH (either absolute, or relative to the current directory). If omitted, PATH will be the current directory. PATH should end in your systems path separator, e.g. <code>/</code> or <code>\</code>.</li>
|
||||
<li><code>-S</code> : Generate strict JSON (field names are enclosed in quotes). By default, no quotes are generated. </li>
|
||||
</ul>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,139 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Use in C++</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__cpp_usage.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Use in C++ </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>Assuming you have written a schema using the above language in say <code>mygame.fbs</code> (FlatBuffer Schema, though the extension doesn't matter), you've generated a C++ header called <code>mygame_generated.h</code> using the compiler (e.g. <code>flatc -c mygame.fbs</code>), you can now start using this in your program by including the header. As noted, this header relies on <code>flatbuffers/flatbuffers.h</code>, which should be in your include path.</p>
|
||||
<h3>Writing in C++</h3>
|
||||
<p>To start creating a buffer, create an instance of <code>FlatBufferBuilder</code> which will contain the buffer as it grows: </p><pre class="fragment">FlatBufferBuilder fbb;
|
||||
</pre><p>Before we serialize a Monster, we need to first serialize any objects that are contained there-in, i.e. we serialize the data tree using depth first, pre-order traversal. This is generally easy to do on any tree structures. For example: </p><pre class="fragment">auto name = fbb.CreateString("MyMonster");
|
||||
|
||||
unsigned char inv[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
auto inventory = fbb.CreateVector(inv, 10);
|
||||
</pre><p><code>CreateString</code> and <code>CreateVector</code> serialize these two built-in datatypes, and return offsets into the serialized data indicating where they are stored, such that <code>Monster</code> below can refer to them.</p>
|
||||
<p><code>CreateString</code> can also take an <code>std::string</code>, or a <code>const char *</code> with an explicit length, and is suitable for holding UTF-8 and binary data if needed.</p>
|
||||
<p><code>CreateVector</code> can also take an <code>std::vector</code>. The offset it returns is typed, i.e. can only be used to set fields of the correct type below. To create a vector of struct objects (which will be stored as contiguous memory in the buffer, use <code>CreateVectorOfStructs</code> instead. </p><pre class="fragment">Vec3 vec(1, 2, 3);
|
||||
</pre><p><code>Vec3</code> is the first example of code from our generated header. Structs (unlike tables) translate to simple structs in C++, so we can construct them in a familiar way.</p>
|
||||
<p>We have now serialized the non-scalar components of of the monster example, so we could create the monster something like this: </p><pre class="fragment">auto mloc = CreateMonster(fbb, &vec, 150, 80, name, inventory, Color_Red, 0, Any_NONE);
|
||||
</pre><p>Note that we're passing <code>150</code> for the <code>mana</code> field, which happens to be the default value: this means the field will not actually be written to the buffer, since we'll get that value anyway when we query it. This is a nice space savings, since it is very common for fields to be at their default. It means we also don't need to be scared to add fields only used in a minority of cases, since they won't bloat up the buffer sizes if they're not actually used.</p>
|
||||
<p>We do something similarly for the union field <code>test</code> by specifying a <code>0</code> offset and the <code>NONE</code> enum value (part of every union) to indicate we don't actually want to write this field. You can use <code>0</code> also as a default for other non-scalar types, such as strings, vectors and tables.</p>
|
||||
<p>Tables (like <code>Monster</code>) give you full flexibility on what fields you write (unlike <code>Vec3</code>, which always has all fields set because it is a <code>struct</code>). If you want even more control over this (i.e. skip fields even when they are not default), instead of the convenient <code>CreateMonster</code> call we can also build the object field-by-field manually: </p><pre class="fragment">MonsterBuilder mb(fbb);
|
||||
mb.add_pos(&vec);
|
||||
mb.add_hp(80);
|
||||
mb.add_name(name);
|
||||
mb.add_inventory(inventory);
|
||||
auto mloc = mb.Finish();
|
||||
</pre><p>We start with a temporary helper class <code>MonsterBuilder</code> (which is defined in our generated code also), then call the various <code>add_</code> methods to set fields, and <code>Finish</code> to complete the object. This is pretty much the same code as you find inside <code>CreateMonster</code>, except we're leaving out a few fields. Fields may also be added in any order, though orderings with fields of the same size adjacent to each other most efficient in size, due to alignment. You should not nest these Builder classes (serialize your data in pre-order).</p>
|
||||
<p>Regardless of whether you used <code>CreateMonster</code> or <code>MonsterBuilder</code>, you now have an offset to the root of your data, and you can finish the buffer using: </p><pre class="fragment">FinishMonsterBuffer(fbb, mloc);
|
||||
</pre><p>The buffer is now ready to be stored somewhere, sent over the network, be compressed, or whatever you'd like to do with it. You can access the start of the buffer with <code>fbb.GetBufferPointer()</code>, and it's size from <code>fbb.GetSize()</code>.</p>
|
||||
<p><code>samples/sample_binary.cpp</code> is a complete code sample similar to the code above, that also includes the reading code below.</p>
|
||||
<h3>Reading in C++</h3>
|
||||
<p>If you've received a buffer from somewhere (disk, network, etc.) you can directly start traversing it using: </p><pre class="fragment">auto monster = GetMonster(buffer_pointer);
|
||||
</pre><p><code>monster</code> is of type <code>Monster *</code>, and points to somewhere inside your buffer. If you look in your generated header, you'll see it has convenient accessors for all fields, e.g. </p><pre class="fragment">assert(monster->hp() == 80);
|
||||
assert(monster->mana() == 150); // default
|
||||
assert(strcmp(monster->name()->c_str(), "MyMonster") == 0);
|
||||
</pre><p>These should all be true. Note that we never stored a <code>mana</code> value, so it will return the default.</p>
|
||||
<p>To access sub-objects, in this case the <code>Vec3</code>: </p><pre class="fragment">auto pos = monster->pos();
|
||||
assert(pos);
|
||||
assert(pos->z() == 3);
|
||||
</pre><p>If we had not set the <code>pos</code> field during serialization, it would be <code>NULL</code>.</p>
|
||||
<p>Similarly, we can access elements of the inventory array: </p><pre class="fragment">auto inv = monster->inventory();
|
||||
assert(inv);
|
||||
assert(inv->Get(9) == 9);
|
||||
</pre><h3>Direct memory access</h3>
|
||||
<p>As you can see from the above examples, all elements in a buffer are accessed through generated accessors. This is because everything is stored in little endian format on all platforms (the accessor performs a swap operation on big endian machines), and also because the layout of things is generally not known to the user.</p>
|
||||
<p>For structs, layout is deterministic and guaranteed to be the same accross platforms (scalars are aligned to their own size, and structs themselves to their largest member), and you are allowed to access this memory directly by using <code>sizeof()</code> and <code>memcpy</code> on the pointer to a struct, or even an array of structs.</p>
|
||||
<p>To compute offsets to sub-elements of a struct, make sure they are a structs themselves, as then you can use the pointers to figure out the offset without having to hardcode it. This is handy for use of arrays of structs with calls like <code>glVertexAttribPointer</code> in OpenGL or similar APIs.</p>
|
||||
<p>It is important to note is that structs are still little endian on all machines, so only use tricks like this if you can guarantee you're not shipping on a big endian machine (an <code>assert(FLATBUFFERS_LITTLEENDIAN)</code> would be wise).</p>
|
||||
<h3>Access of untrusted buffers</h3>
|
||||
<p>The generated accessor functions access fields over offsets, which is very quick. These offsets are not verified at run-time, so a malformed buffer could cause a program to crash by accessing random memory.</p>
|
||||
<p>When you're processing large amounts of data from a source you know (e.g. your own generated data on disk), this is acceptable, but when reading data from the network that can potentially have been modified by an attacker, this is undesirable.</p>
|
||||
<p>For this reason, you can optionally use a buffer verifier before you access the data. This verifier will check all offsets, all sizes of fields, and null termination of strings to ensure that when a buffer is accessed, all reads will end up inside the buffer.</p>
|
||||
<p>Each root type will have a verification function generated for it, e.g. for <code>Monster</code>, you can call:</p>
|
||||
<p>bool ok = VerifyMonsterBuffer(Verifier(buf, len));</p>
|
||||
<p>if <code>ok</code> is true, the buffer is safe to read.</p>
|
||||
<p>Besides untrusted data, this function may be useful to call in debug mode, as extra insurance against data being corrupted somewhere along the way.</p>
|
||||
<p>While verifying a buffer isn't "free", it is typically faster than a full traversal (since any scalar data is not actually touched), and since it may cause the buffer to be brought into cache before reading, the actual overhead may be even lower than expected.</p>
|
||||
<h2>Text & schema parsing</h2>
|
||||
<p>Using binary buffers with the generated header provides a super low overhead use of FlatBuffer data. There are, however, times when you want to use text formats, for example because it interacts better with source control, or you want to give your users easy access to data.</p>
|
||||
<p>Another reason might be that you already have a lot of data in JSON format, or a tool that generates JSON, and if you can write a schema for it, this will provide you an easy way to use that data directly.</p>
|
||||
<p>(see the schema documentation for some specifics on the JSON format accepted).</p>
|
||||
<p>There are two ways to use text formats:</p>
|
||||
<h3>Using the compiler as a conversion tool</h3>
|
||||
<p>This is the preferred path, as it doesn't require you to add any new code to your program, and is maximally efficient since you can ship with binary data. The disadvantage is that it is an extra step for your users/developers to perform, though you might be able to automate it. </p><pre class="fragment">flatc -b myschema.fbs mydata.json
|
||||
</pre><p>This will generate the binary file <code>mydata_wire.bin</code> which can be loaded as before.</p>
|
||||
<h3>Making your program capable of loading text directly</h3>
|
||||
<p>This gives you maximum flexibility. You could even opt to support both, i.e. check for both files, and regenerate the binary from text when required, otherwise just load the binary.</p>
|
||||
<p>This option is currently only available for C++, or Java through JNI.</p>
|
||||
<p>As mentioned in the section "Building" above, this technique requires you to link a few more files into your program, and you'll want to include <code>flatbuffers/idl.h</code>.</p>
|
||||
<p>Load text (either a schema or json) into an in-memory buffer (there is a convenient <code>LoadFile()</code> utility function in <code>flatbuffers/util.h</code> if you wish). Construct a parser: </p><pre class="fragment">flatbuffers::Parser parser;
|
||||
</pre><p>Now you can parse any number of text files in sequence: </p><pre class="fragment">parser.Parse(text_file.c_str());
|
||||
</pre><p>This works similarly to how the command-line compiler works: a sequence of files parsed by the same <code>Parser</code> object allow later files to reference definitions in earlier files. Typically this means you first load a schema file (which populates <code>Parser</code> with definitions), followed by one or more JSON files.</p>
|
||||
<p>If there were any parsing errors, <code>Parse</code> will return <code>false</code>, and <code>Parser::err</code> contains a human readable error string with a line number etc, which you should present to the creator of that file.</p>
|
||||
<p>After each JSON file, the <code>Parser::fbb</code> member variable is the <code>FlatBufferBuilder</code> that contains the binary buffer version of that file, that you can access as described above.</p>
|
||||
<p><code>samples/sample_text.cpp</code> is a code sample showing the above operations.</p>
|
||||
<h3>Threading</h3>
|
||||
<p>None of the code is thread-safe, by design. That said, since currently a FlatBuffer is read-only and entirely <code>const</code>, reading by multiple threads is possible. </p>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,106 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Use in Go</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__go_usage.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Use in Go </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>There's experimental support for reading FlatBuffers in Go. Generate code for Go with the <code>-g</code> option to <code>flatc</code>.</p>
|
||||
<p>See <code>go_test.go</code> for an example. You import the generated code, read a FlatBuffer binary file into a <code>[]byte</code>, which you pass to the <code>GetRootAsMonster</code> function: </p><pre class="fragment">import (
|
||||
example "MyGame/Example"
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
|
||||
io/ioutil
|
||||
)
|
||||
|
||||
buf, err := ioutil.ReadFile("monster.dat")
|
||||
// handle err
|
||||
monster := example.GetRootAsMonster(buf, 0)
|
||||
</pre><p>Now you can access values like this: </p><pre class="fragment">hp := monster.Hp()
|
||||
pos := monster.Pos(nil)
|
||||
</pre><p>Note that whenever you access a new object like in the <code>Pos</code> example above, a new temporary accessor object gets created. If your code is very performance sensitive (you iterate through a lot of objects), you can replace nil with a pointer to a <code>Vec3</code> object you've already created. This allows you to reuse it across many calls and reduce the amount of object allocation (and thus garbage collection) your program does.</p>
|
||||
<p>To access vectors you pass an extra index to the vector field accessor. Then a second method with the same name suffixed by <code>Length</code> let's you know the number of elements you can access: </p><pre class="fragment">for i := 0; i < monster.InventoryLength(); i++ {
|
||||
monster.Inventory(i) // do something here
|
||||
}
|
||||
</pre><p>You can also construct these buffers in Go using the functions found in the generated code, and the FlatBufferBuilder class: </p><pre class="fragment">builder := flatbuffers.NewBuilder(0)
|
||||
</pre><p>Create strings: </p><pre class="fragment">str := builder.CreateString("MyMonster")
|
||||
</pre><p>Create a table with a struct contained therein: </p><pre class="fragment">example.MonsterStart(builder)
|
||||
example.MonsterAddPos(builder, example.CreateVec3(builder, 1.0, 2.0, 3.0, 3.0, 4, 5, 6))
|
||||
example.MonsterAddHp(builder, 80)
|
||||
example.MonsterAddName(builder, str)
|
||||
example.MonsterAddInventory(builder, inv)
|
||||
example.MonsterAddTest_Type(builder, 1)
|
||||
example.MonsterAddTest(builder, mon2)
|
||||
example.MonsterAddTest4(builder, test4s)
|
||||
mon := example.MonsterEnd(builder)
|
||||
</pre><p>Unlike C++, Go does not support table creation functions like 'createMonster()'. This is to create the buffer without using temporary object allocation (since the <code>Vec3</code> is an inline component of <code>Monster</code>, it has to be created right where it is added, whereas the name and the inventory are not inline). Structs do have convenient methods that allow you to construct them in one call. These also have arguments for nested structs, e.g. if a struct has a field <code>a</code> and a nested struct field <code>b</code> (which has fields <code>c</code> and <code>d</code>), then the arguments will be <code>a</code>, <code>c</code> and <code>d</code>.</p>
|
||||
<p>Vectors also use this start/end pattern to allow vectors of both scalar types and structs: </p><pre class="fragment">example.MonsterStartInventoryVector(builder, 5)
|
||||
for i := 4; i >= 0; i-- {
|
||||
builder.PrependByte(byte(i))
|
||||
}
|
||||
inv := builder.EndVector(5)
|
||||
</pre><p>The generated method 'StartInventoryVector' is provided as a convenience function which calls 'StartVector' with the correct element size of the vector type which in this case is 'ubyte' or 1 byte per vector element. You pass the number of elements you want to write. You write the elements backwards since the buffer is being constructed back to front.</p>
|
||||
<p>There are <code>Prepend</code> functions for all the scalar types. You use <code>PrependUOffset</code> for any previously constructed objects (such as other tables, strings, vectors). For structs, you use the appropriate <code>create</code> function in-line, as shown above in the <code>Monster</code> example.</p>
|
||||
<h2>Text Parsing</h2>
|
||||
<p>There currently is no support for parsing text (Schema's and JSON) directly from Go, though you could use the C++ parser through cgo. Please see the C++ documentation for more on text parsing. </p>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,81 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Formal Grammar of the schema language</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__grammar.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Formal Grammar of the schema language </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>schema = namespace_decl | type_decl | enum_decl | root_decl | object</p>
|
||||
<p>namespace_decl = <code>namespace</code> ident ( <code>.</code> ident )* <code>;</code></p>
|
||||
<p>type_decl = ( <code>table</code> | <code>struct</code> ) ident metadata <code>{</code> field_decl+ <code>}</code></p>
|
||||
<p>enum_decl = ( <code>enum</code> | <code>union</code> ) ident [ <code>:</code> type ] metadata <code>{</code> commasep( enumval_decl ) <code>}</code></p>
|
||||
<p>root_decl = <code>root_type</code> ident <code>;</code></p>
|
||||
<p>field_decl = type <code>:</code> ident [ <code>=</code> scalar ] metadata <code>;</code></p>
|
||||
<p>type = <code>bool</code> | <code>byte</code> | <code>ubyte</code> | <code>short</code> | <code>ushort</code> | <code>int</code> | <code>uint</code> | <code>float</code> | <code>long</code> | <code>ulong</code> | <code>double</code> | <code>string</code> | <code>[</code> type <code>]</code> | ident</p>
|
||||
<p>enumval_decl = ident [ <code>=</code> integer_constant ]</p>
|
||||
<p>metadata = [ <code>(</code> commasep( ident [ <code>:</code> scalar ] ) <code>)</code> ]</p>
|
||||
<p>scalar = integer_constant | float_constant | <code>true</code> | <code>false</code></p>
|
||||
<p>object = { commasep( ident <code>:</code> value ) }</p>
|
||||
<p>value = scalar | object | string_constant | <code>[</code> commasep( value ) <code>]</code></p>
|
||||
<p>commasep(x) = [ x ( <code>,</code> x )* ] </p>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,169 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: FlatBuffer Internals</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__internals.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">FlatBuffer Internals </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>This section is entirely optional for the use of FlatBuffers. In normal usage, you should never need the information contained herein. If you're interested however, it should give you more of an appreciation of why FlatBuffers is both efficient and convenient.</p>
|
||||
<h3>Format components</h3>
|
||||
<p>A FlatBuffer is a binary file and in-memory format consisting mostly of scalars of various sizes, all aligned to their own size. Each scalar is also always represented in little-endian format, as this corresponds to all commonly used CPUs today. FlatBuffers will also work on big-endian machines, but will be slightly slower because of additional byte-swap intrinsics.</p>
|
||||
<p>On purpose, the format leaves a lot of details about where exactly things live in memory undefined, e.g. fields in a table can have any order, and objects to some extend can be stored in many orders. This is because the format doesn't need this information to be efficient, and it leaves room for optimization and extension (for example, fields can be packed in a way that is most compact). Instead, the format is defined in terms of offsets and adjacency only. This may mean two different implementations may produce different binaries given the same input values, and this is perfectly valid.</p>
|
||||
<h3>Format identification</h3>
|
||||
<p>The format also doesn't contain information for format identification and versioning, which is also by design. FlatBuffers is a statically typed system, meaning the user of a buffer needs to know what kind of buffer it is. FlatBuffers can of course be wrapped inside other containers where needed, or you can use its union feature to dynamically identify multiple possible sub-objects stored. Additionally, it can be used together with the schema parser if full reflective capabilities are desired.</p>
|
||||
<p>Versioning is something that is intrinsically part of the format (the optionality / extensibility of fields), so the format itself does not need a version number (it's a meta-format, in a sense). We're hoping that this format can accommodate all data needed. If format breaking changes are ever necessary, it would become a new kind of format rather than just a variation.</p>
|
||||
<h3>Offsets</h3>
|
||||
<p>The most important and generic offset type (see <code>flatbuffers.h</code>) is <code>uoffset_t</code>, which is currently always a <code>uint32_t</code>, and is used to refer to all tables/unions/strings/vectors (these are never stored in-line). 32bit is intentional, since we want to keep the format binary compatible between 32 and 64bit systems, and a 64bit offset would bloat the size for almost all uses. A version of this format with 64bit (or 16bit) offsets is easy to set when needed. Unsigned means they can only point in one direction, which typically is forward (towards a higher memory location). Any backwards offsets will be explicitly marked as such.</p>
|
||||
<p>The format starts with an <code>uoffset_t</code> to the root object in the buffer.</p>
|
||||
<p>We have two kinds of objects, structs and tables.</p>
|
||||
<h3>Structs</h3>
|
||||
<p>These are the simplest, and as mentioned, intended for simple data that benefits from being extra efficient and doesn't need versioning / extensibility. They are always stored inline in their parent (a struct, table, or vector) for maximum compactness. Structs define a consistent memory layout where all components are aligned to their size, and structs aligned to their largest scalar member. This is done independent of the alignment rules of the underlying compiler to guarantee a cross platform compatible layout. This layout is then enforced in the generated code.</p>
|
||||
<h3>Tables</h3>
|
||||
<p>These start with an <code>soffset_t</code> to a vtable (signed version of <code>uoffset_t</code>, since vtables may be stored anywhere), followed by all the fields as aligned scalars (or offsets). Unlike structs, not all fields need to be present. There is no set order and layout.</p>
|
||||
<p>To be able to access fields regardless of these uncertainties, we go through a vtable of offsets. Vtables are shared between any objects that happen to have the same vtable values.</p>
|
||||
<p>The elements of a vtable are all of type <code>voffset_t</code>, which is a <code>uint16_t</code>. The first element is the number of elements of the vtable, including this one. The second one is the size of the object, in bytes (including the vtable offset). This size is used for streaming, to know how many bytes to read to be able to access all fields of the object. The remaining elements are the N offsets, where N is the amount of fields declared in the schema when the code that constructed this buffer was compiled (thus, the size of the table is N + 2).</p>
|
||||
<p>All accessor functions in the generated code for tables contain the offset into this table as a constant. This offset is checked against the first field (the number of elements), to protect against newer code reading older data. If this offset is out of range, or the vtable entry is 0, that means the field is not present in this object, and the default value is return. Otherwise, the entry is used as offset to the field to be read.</p>
|
||||
<h3>Strings and Vectors</h3>
|
||||
<p>Strings are simply a vector of bytes, and are always null-terminated. Vectors are stored as contiguous aligned scalar elements prefixed by a 32bit element count (not including any null termination).</p>
|
||||
<h3>Construction</h3>
|
||||
<p>The current implementation constructs these buffers backwards (starting at the highest memory address of the buffer), since that significantly reduces the amount of bookkeeping and simplifies the construction API.</p>
|
||||
<h3>Code example</h3>
|
||||
<p>Here's an example of the code that gets generated for the <code>samples/monster.fbs</code>. What follows is the entire file, broken up by comments: </p><pre class="fragment">// automatically generated, do not modify
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
namespace MyGame {
|
||||
namespace Sample {
|
||||
</pre><p>Nested namespace support. </p><pre class="fragment">enum {
|
||||
Color_Red = 0,
|
||||
Color_Green = 1,
|
||||
Color_Blue = 2,
|
||||
};
|
||||
|
||||
inline const char **EnumNamesColor() {
|
||||
static const char *names[] = { "Red", "Green", "Blue", nullptr };
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameColor(int e) { return EnumNamesColor()[e]; }
|
||||
</pre><p>Enums and convenient reverse lookup. </p><pre class="fragment">enum {
|
||||
Any_NONE = 0,
|
||||
Any_Monster = 1,
|
||||
};
|
||||
|
||||
inline const char **EnumNamesAny() {
|
||||
static const char *names[] = { "NONE", "Monster", nullptr };
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameAny(int e) { return EnumNamesAny()[e]; }
|
||||
</pre><p>Unions share a lot with enums. </p><pre class="fragment">struct Vec3;
|
||||
struct Monster;
|
||||
</pre><p>Predeclare all datatypes since there may be circular references. </p><pre class="fragment">MANUALLY_ALIGNED_STRUCT(4) Vec3 {
|
||||
private:
|
||||
float x_;
|
||||
float y_;
|
||||
float z_;
|
||||
|
||||
public:
|
||||
Vec3(float x, float y, float z)
|
||||
: x_(flatbuffers::EndianScalar(x)), y_(flatbuffers::EndianScalar(y)), z_(flatbuffers::EndianScalar(z)) {}
|
||||
|
||||
float x() const { return flatbuffers::EndianScalar(x_); }
|
||||
float y() const { return flatbuffers::EndianScalar(y_); }
|
||||
float z() const { return flatbuffers::EndianScalar(z_); }
|
||||
};
|
||||
STRUCT_END(Vec3, 12);
|
||||
</pre><p>These ugly macros do a couple of things: they turn off any padding the compiler might normally do, since we add padding manually (though none in this example), and they enforce alignment chosen by FlatBuffers. This ensures the layout of this struct will look the same regardless of compiler and platform. Note that the fields are private: this is because these store little endian scalars regardless of platform (since this is part of the serialized data). <code>EndianScalar</code> then converts back and forth, which is a no-op on all current mobile and desktop platforms, and a single machine instruction on the few remaining big endian platforms. </p><pre class="fragment">struct Monster : private flatbuffers::Table {
|
||||
const Vec3 *pos() const { return GetStruct<const Vec3 *>(4); }
|
||||
int16_t mana() const { return GetField<int16_t>(6, 150); }
|
||||
int16_t hp() const { return GetField<int16_t>(8, 100); }
|
||||
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(10); }
|
||||
const flatbuffers::Vector<uint8_t> *inventory() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(14); }
|
||||
int8_t color() const { return GetField<int8_t>(16, 2); }
|
||||
};
|
||||
</pre><p>Tables are a bit more complicated. A table accessor struct is used to point at the serialized data for a table, which always starts with an offset to its vtable. It derives from <code>Table</code>, which contains the <code>GetField</code> helper functions. GetField takes a vtable offset, and a default value. It will look in the vtable at that offset. If the offset is out of bounds (data from an older version) or the vtable entry is 0, the field is not present and the default is returned. Otherwise, it uses the entry as an offset into the table to locate the field. </p><pre class="fragment">struct MonsterBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_pos(const Vec3 *pos) { fbb_.AddStruct(4, pos); }
|
||||
void add_mana(int16_t mana) { fbb_.AddElement<int16_t>(6, mana, 150); }
|
||||
void add_hp(int16_t hp) { fbb_.AddElement<int16_t>(8, hp, 100); }
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(10, name); }
|
||||
void add_inventory(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory) { fbb_.AddOffset(14, inventory); }
|
||||
void add_color(int8_t color) { fbb_.AddElement<int8_t>(16, color, 2); }
|
||||
MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
flatbuffers::Offset<Monster> Finish() { return flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 7)); }
|
||||
};
|
||||
</pre><p><code>MonsterBuilder</code> is the base helper struct to construct a table using a <code>FlatBufferBuilder</code>. You can add the fields in any order, and the <code>Finish</code> call will ensure the correct vtable gets generated. </p><pre class="fragment">inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const Vec3 *pos, int16_t mana, int16_t hp, flatbuffers::Offset<flatbuffers::String> name, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory, int8_t color) {
|
||||
MonsterBuilder builder_(_fbb);
|
||||
builder_.add_inventory(inventory);
|
||||
builder_.add_name(name);
|
||||
builder_.add_pos(pos);
|
||||
builder_.add_hp(hp);
|
||||
builder_.add_mana(mana);
|
||||
builder_.add_color(color);
|
||||
return builder_.Finish();
|
||||
}
|
||||
</pre><p><code>CreateMonster</code> is a convenience function that calls all functions in <code>MonsterBuilder</code> above for you. Note that if you pass values which are defaults as arguments, it will not actually construct that field, so you can probably use this function instead of the builder class in almost all cases. </p><pre class="fragment">inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot<Monster>(buf); }
|
||||
</pre><p>This function is only generated for the root table type, to be able to start traversing a FlatBuffer from a raw buffer pointer. </p><pre class="fragment">}; // namespace MyGame
|
||||
}; // namespace Sample</pre> </div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,100 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Use in Java</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__java_usage.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Use in Java </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>FlatBuffers supports reading and writing binary FlatBuffers in Java. Generate code for Java with the <code>-j</code> option to <code>flatc</code>.</p>
|
||||
<p>See <code>javaTest.java</code> for an example. Essentially, you read a FlatBuffer binary file into a <code>byte[]</code>, which you then turn into a <code>ByteBuffer</code>, which you pass to the <code>getRootAsMyRootType</code> function: </p><pre class="fragment">ByteBuffer bb = ByteBuffer.wrap(data);
|
||||
Monster monster = Monster.getRootAsMonster(bb);
|
||||
</pre><p>Now you can access values much like C++: </p><pre class="fragment">short hp = monster.hp();
|
||||
Vec3 pos = monster.pos();
|
||||
</pre><p>Note that whenever you access a new object like in the <code>pos</code> example above, a new temporary accessor object gets created. If your code is very performance sensitive (you iterate through a lot of objects), there's a second <code>pos()</code> method to which you can pass a <code>Vec3</code> object you've already created. This allows you to reuse it across many calls and reduce the amount of object allocation (and thus garbage collection) your program does.</p>
|
||||
<p>Java does not support unsigned scalars. This means that any unsigned types you use in your schema will actually be represented as a signed value. This means all bits are still present, but may represent a negative value when used. For example, to read a <code>byte b</code> as an unsigned number, you can do: <code>(short)(b & 0xFF)</code></p>
|
||||
<p>Sadly the string accessors currently always create a new string when accessed, since FlatBuffer's UTF-8 strings can't be read in-place by Java.</p>
|
||||
<p>Vector access is also a bit different from C++: you pass an extra index to the vector field accessor. Then a second method with the same name suffixed by <code>Length</code> let's you know the number of elements you can access: </p><pre class="fragment">for (int i = 0; i < monster.inventoryLength(); i++)
|
||||
monster.inventory(i); // do something here
|
||||
</pre><p>You can also construct these buffers in Java using the static methods found in the generated code, and the FlatBufferBuilder class: </p><pre class="fragment">FlatBufferBuilder fbb = new FlatBufferBuilder();
|
||||
</pre><p>Create strings: </p><pre class="fragment">int str = fbb.createString("MyMonster");
|
||||
</pre><p>Create a table with a struct contained therein: </p><pre class="fragment">Monster.startMonster(fbb);
|
||||
Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0, (byte)4, (short)5, (byte)6));
|
||||
Monster.addHp(fbb, (short)80);
|
||||
Monster.addName(fbb, str);
|
||||
Monster.addInventory(fbb, inv);
|
||||
Monster.addTest_type(fbb, (byte)1);
|
||||
Monster.addTest(fbb, mon2);
|
||||
Monster.addTest4(fbb, test4s);
|
||||
int mon = Monster.endMonster(fbb);
|
||||
</pre><p>As you can see, the Java code for tables does not use a convenient <code>createMonster</code> call like the C++ code. This is to create the buffer without using temporary object allocation.</p>
|
||||
<p>It's important to understand that fields that are structs are inline (like <code>Vec3</code> above), and MUST thus be created between the start and end calls of a table. Everything else (other tables, strings, vectors) MUST be created before the start of the table they are referenced in.</p>
|
||||
<p>Structs do have convenient methods that even have arguments for nested structs.</p>
|
||||
<p>As you can see, references to other objects (e.g. the string above) are simple ints, and thus do not have the type-safety of the Offset type in C++. Extra case must thus be taken that you set the right offset on the right field.</p>
|
||||
<p>Vectors also use this start/end pattern to allow vectors of both scalar types and structs: </p><pre class="fragment">Monster.startInventoryVector(fbb, 5);
|
||||
for (byte i = 4; i >=0; i--) fbb.addByte(i);
|
||||
int inv = fbb.endVector();
|
||||
</pre><p>You can use the generated method <code>startInventoryVector</code> to conveniently call <code>startVector</code> with the right element size. You pass the number of elements you want to write. You write the elements backwards since the buffer is being constructed back to front.</p>
|
||||
<p>There are <code>add</code> functions for all the scalar types. You use <code>addOffset</code> for any previously constructed objects (such as other tables, strings, vectors). For structs, you use the appropriate <code>create</code> function in-line, as shown above in the <code>Monster</code> example.</p>
|
||||
<h2>Text Parsing</h2>
|
||||
<p>There currently is no support for parsing text (Schema's and JSON) directly from Java, though you could use the C++ parser through JNI. Please see the C++ documentation for more on text parsing. </p>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,160 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Writing a schema</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__schemas.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Writing a schema </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>The syntax of the schema language (aka IDL, Interface Definition Language) should look quite familiar to users of any of the C family of languages, and also to users of other IDLs. Let's look at an example first: </p><pre class="fragment">// example IDL file
|
||||
|
||||
namespace MyGame;
|
||||
|
||||
enum Color : byte { Red = 1, Green, Blue }
|
||||
|
||||
union Any { Monster, Weapon, Pickup }
|
||||
|
||||
struct Vec3 {
|
||||
x:float;
|
||||
y:float;
|
||||
z:float;
|
||||
}
|
||||
|
||||
table Monster {
|
||||
pos:Vec3;
|
||||
mana:short = 150;
|
||||
hp:short = 100;
|
||||
name:string;
|
||||
friendly:bool = false (deprecated, priority: 1);
|
||||
inventory:[ubyte];
|
||||
color:Color = Blue;
|
||||
test:Any;
|
||||
}
|
||||
|
||||
root_type Monster;
|
||||
</pre><p>(Weapon & Pickup not defined as part of this example).</p>
|
||||
<h3>Tables</h3>
|
||||
<p>Tables are the main way of defining objects in FlatBuffers, and consist of a name (here <code>Monster</code>) and a list of fields. Each field has a name, a type, and optionally a default value (if omitted, it defaults to 0 / NULL).</p>
|
||||
<p>Each field is optional: It does not have to appear in the wire representation, and you can choose to omit fields for each individual object. As a result, you have the flexibility to add fields without fear of bloating your data. This design is also FlatBuffer's mechanism for forward and backwards compatibility. Note that:</p>
|
||||
<ul>
|
||||
<li>You can add new fields in the schema ONLY at the end of a table definition. Older data will still read correctly, and give you the default value when read. Older code will simply ignore the new field. If you want to have flexibility to use any order for fields in your schema, you can manually assign ids (much like Protocol Buffers), see the <code>id</code> attribute below.</li>
|
||||
<li>You cannot delete fields you don't use anymore from the schema, but you can simply stop writing them into your data for almost the same effect. Additionally you can mark them as <code>deprecated</code> as in the example above, which will prevent the generation of accessors in the generated C++, as a way to enforce the field not being used any more. (careful: this may break code!).</li>
|
||||
<li>You may change field names and table names, if you're ok with your code breaking until you've renamed them there too.</li>
|
||||
</ul>
|
||||
<h3>Structs</h3>
|
||||
<p>Similar to a table, only now none of the fields are optional (so no defaults either), and fields may not be added or be deprecated. Structs may only contain scalars or other structs. Use this for simple objects where you are very sure no changes will ever be made (as quite clear in the example <code>Vec3</code>). Structs use less memory than tables and are even faster to access (they are always stored in-line in their parent object, and use no virtual table).</p>
|
||||
<h3>Types</h3>
|
||||
<p>Builtin scalar types are:</p>
|
||||
<ul>
|
||||
<li>8 bit: <code>byte ubyte bool</code></li>
|
||||
<li>16 bit: <code>short ushort</code></li>
|
||||
<li>32 bit: <code>int uint float</code></li>
|
||||
<li>64 bit: <code>long ulong double</code></li>
|
||||
<li>Vector of any other type (denoted with <code>[type]</code>). Nesting vectors is not supported, instead you can wrap the inner vector in a table.</li>
|
||||
<li><code>string</code>, which may only hold UTF-8 or 7-bit ASCII. For other text encodings or general binary data use vectors (<code>[byte]</code> or <code>[ubyte]</code>) instead.</li>
|
||||
<li>References to other tables or structs, enums or unions (see below).</li>
|
||||
</ul>
|
||||
<p>You can't change types of fields once they're used, with the exception of same-size data where a <code>reinterpret_cast</code> would give you a desirable result, e.g. you could change a <code>uint</code> to an <code>int</code> if no values in current data use the high bit yet.</p>
|
||||
<h3>(Default) Values</h3>
|
||||
<p>Values are a sequence of digits, optionally followed by a <code>.</code> and more digits for float constants, and optionally prefixed by a <code>-</code>. Non-scalar defaults are currently not supported (always NULL).</p>
|
||||
<p>You generally do not want to change default values after they're initially defined. Fields that have the default value are not actually stored in the serialized data but are generated in code, so when you change the default, you'd now get a different value than from code generated from an older version of the schema. There are situations however where this may be desirable, especially if you can ensure a simultaneous rebuild of all code.</p>
|
||||
<h3>Enums</h3>
|
||||
<p>Define a sequence of named constants, each with a given value, or increasing by one from the previous one. The default first value is <code>0</code>. As you can see in the enum declaration, you specify the underlying integral type of the enum with <code>:</code> (in this case <code>byte</code>), which then determines the type of any fields declared with this enum type.</p>
|
||||
<h3>Unions</h3>
|
||||
<p>Unions share a lot of properties with enums, but instead of new names for constants, you use names of tables. You can then declare a union field which can hold a reference to any of those types, and additionally a hidden field with the suffix <code>_type</code> is generated that holds the corresponding enum value, allowing you to know which type to cast to at runtime.</p>
|
||||
<h3>Namespaces</h3>
|
||||
<p>These will generate the corresponding namespace in C++ for all helper code, and packages in Java. You can use <code>.</code> to specify nested namespaces / packages.</p>
|
||||
<h3>Root type</h3>
|
||||
<p>This declares what you consider to be the root table (or struct) of the serialized data. This is particular important for parsing JSON data, which doesn't include object type information.</p>
|
||||
<h3>File identification and extension</h3>
|
||||
<p>Typically, a FlatBuffer binary buffer is not self-describing, i.e. it needs you to know its schema to parse it correctly. But if you want to use a FlatBuffer as a file format, it would be convenient to be able to have a "magic number" in there, like most file formats have, to be able to do a sanity check to see if you're reading the kind of file you're expecting.</p>
|
||||
<p>Now, you can always prefix a FlatBuffer with your own file header, but FlatBuffers has a built-in way to add an identifier to a FlatBuffer that takes up minimal space, and keeps the buffer compatible with buffers that don't have such an identifier.</p>
|
||||
<p>You can specify in a schema, similar to <code>root_type</code>, that you intend for this type of FlatBuffer to be used as a file format: </p><pre class="fragment">file_identifier "MYFI";
|
||||
</pre><p>Identifiers must always be exactly 4 characters long. These 4 characters will end up as bytes at offsets 4-7 (inclusive) in the buffer.</p>
|
||||
<p>For any schema that has such an identifier, <code>flatc</code> will automatically add the identifier to any binaries it generates (with <code>-b</code>), and generated calls like <code>FinishMonsterBuffer</code> also add the identifier. If you have specified an identifier and wish to generate a buffer without one, you can always still do so by calling <code>FlatBufferBuilder::Finish</code> explicitly.</p>
|
||||
<p>After loading a buffer, you can use a call like <code>MonsterBufferHasIdentifier</code> to check if the identifier is present.</p>
|
||||
<p>Additionally, by default <code>flatc</code> will output binary files as <code>.bin</code>. This declaration in the schema will change that to whatever you want: </p><pre class="fragment">file_extension "ext";
|
||||
</pre><h3>Comments & documentation</h3>
|
||||
<p>May be written as in most C-based languages. Additionally, a triple comment (<code>///</code>) on a line by itself signals that a comment is documentation for whatever is declared on the line after it (table/struct/field/enum/union/element), and the comment is output in the corresponding C++ code. Multiple such lines per item are allowed.</p>
|
||||
<h3>Attributes</h3>
|
||||
<p>Attributes may be attached to a declaration, behind a field, or after the name of a table/struct/enum/union. These may either have a value or not. Some attributes like <code>deprecated</code> are understood by the compiler, others are simply ignored (like <code>priority</code>), but are available to query if you parse the schema at runtime. This is useful if you write your own code generators/editors etc., and you wish to add additional information specific to your tool (such as a help text).</p>
|
||||
<p>Current understood attributes:</p>
|
||||
<ul>
|
||||
<li><code>id: n</code> (on a table field): manually set the field identifier to <code>n</code>. If you use this attribute, you must use it on ALL fields of this table, and the numbers must be a contiguous range from 0 onwards. Additionally, since a union type effectively adds two fields, its id must be that of the second field (the first field is the type field and not explicitly declared in the schema). For example, if the last field before the union field had id 6, the union field should have id 8, and the unions type field will implicitly be 7. IDs allow the fields to be placed in any order in the schema. When a new field is added to the schema is must use the next available ID.</li>
|
||||
<li><code>deprecated</code> (on a field): do not generate accessors for this field anymore, code should stop using this data.</li>
|
||||
<li><code>original_order</code> (on a table): since elements in a table do not need to be stored in any particular order, they are often optimized for space by sorting them to size. This attribute stops that from happening.</li>
|
||||
<li><code>force_align: size</code> (on a struct): force the alignment of this struct to be something higher than what it is naturally aligned to. Causes these structs to be aligned to that amount inside a buffer, IF that buffer is allocated with that alignment (which is not necessarily the case for buffers accessed directly inside a <code>FlatBufferBuilder</code>).</li>
|
||||
<li><code>bit_flags</code> (on an enum): the values of this field indicate bits, meaning that any value N specified in the schema will end up representing 1<<N, or if you don't specify values at all, you'll get the sequence 1, 2, 4, 8, ...</li>
|
||||
</ul>
|
||||
<h2>JSON Parsing</h2>
|
||||
<p>The same parser that parses the schema declarations above is also able to parse JSON objects that conform to this schema. So, unlike other JSON parsers, this parser is strongly typed, and parses directly into a FlatBuffer (see the compiler documentation on how to do this from the command line, or the C++ documentation on how to do this at runtime).</p>
|
||||
<p>Besides needing a schema, there are a few other changes to how it parses JSON:</p>
|
||||
<ul>
|
||||
<li>It accepts field names with and without quotes, like many JSON parsers already do. It outputs them without quotes as well, though can be made to output them using the <code>strict_json</code> flag.</li>
|
||||
<li>If a field has an enum type, the parser will recognize symbolic enum values (with or without quotes) instead of numbers, e.g. <code>field: EnumVal</code>. If a field is of integral type, you can still use symbolic names, but values need to be prefixed with their type and need to be quoted, e.g. <code>field: "Enum.EnumVal"</code>. For enums representing flags, you may place multiple inside a string separated by spaces to OR them, e.g. <code>field: "EnumVal1 EnumVal2"</code> or <code>field: "Enum.EnumVal1 Enum.EnumVal2"</code>.</li>
|
||||
</ul>
|
||||
<h2>Gotchas</h2>
|
||||
<h3>Schemas and version control</h3>
|
||||
<p>FlatBuffers relies on new field declarations being added at the end, and earlier declarations to not be removed, but be marked deprecated when needed. We think this is an improvement over the manual number assignment that happens in Protocol Buffers (and which is still an option using the <code>id</code> attribute mentioned above).</p>
|
||||
<p>One place where this is possibly problematic however is source control. If user A adds a field, generates new binary data with this new schema, then tries to commit both to source control after user B already committed a new field also, and just auto-merges the schema, the binary files are now invalid compared to the new schema.</p>
|
||||
<p>The solution of course is that you should not be generating binary data before your schema changes have been committed, ensuring consistency with the rest of the world. If this is not practical for you, use explicit field ids, which should always generate a merge conflict if two people try to allocate the same id. </p>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,101 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: FlatBuffers white paper</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('md__white_paper.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">FlatBuffers white paper </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>This document tries to shed some light on to the "why" of FlatBuffers, a new serialization library.</p>
|
||||
<h2>Motivation</h2>
|
||||
<p>Back in the good old days, performance was all about instructions and cycles. Nowadays, processing units have run so far ahead of the memory subsystem, that making an efficient application should start and finish with thinking about memory. How much you use of it. How you lay it out and access it. How you allocate it. When you copy it.</p>
|
||||
<p>Serialization is a pervasive activity in a lot programs, and a common source of memory inefficiency, with lots of temporary data structures needed to parse and represent data, and inefficient allocation patterns and locality.</p>
|
||||
<p>If it would be possible to do serialization with no temporary objects, no additional allocation, no copying, and good locality, this could be of great value. The reason serialization systems usually don't manage this is because it goes counter to forwards/backwards compatability, and platform specifics like endianness and alignment.</p>
|
||||
<p>FlatBuffers is what you get if you try anyway.</p>
|
||||
<p>In particular, FlatBuffers focus is on mobile hardware (where memory size and memory bandwidth is even more constrained than on desktop hardware), and applications that have the highest performance needs: games.</p>
|
||||
<h2>FlatBuffers</h2>
|
||||
<p><em>This is a summary of FlatBuffers functionality, with some rationale. A more detailed description can be found in the FlatBuffers documentation.</em></p>
|
||||
<h3>Summary</h3>
|
||||
<p>A FlatBuffer is a binary buffer containing nested objects (structs, tables, vectors,..) organized using offsets so that the data can be traversed in-place just like any pointer-based data structure. Unlike most in-memory data structures however, it uses strict rules of alignment and endianness (always little) to ensure these buffers are cross platform. Additionally, for objects that are tables, FlatBuffers provides forwards/backwards compatibility and general optionality of fields, to support most forms of format evolution.</p>
|
||||
<p>You define your object types in a schema, which can then be compiled to C++ or Java for low to zero overhead reading & writing. Optionally, JSON data can be dynamically parsed into buffers.</p>
|
||||
<h3>Tables</h3>
|
||||
<p>Tables are the cornerstone of FlatBuffers, since format evolution is essential for most applications of serialization. Typically, dealing with format changes is something that can be done transparently during the parsing process of most serialization solutions out there. But a FlatBuffer isn't parsed before it is accessed.</p>
|
||||
<p>Tables get around this by using an extra indirection to access fields, through a <em>vtable</em>. Each table comes with a vtable (which may be shared between multiple tables with the same layout), and contains information where fields for this particular kind of instance of vtable are stored. The vtable may also indicate that the field is not present (because this FlatBuffer was written with an older version of the software, of simply because the information was not necessary for this instance, or deemed deprecated), in which case a default value is returned.</p>
|
||||
<p>Tables have a low overhead in memory (since vtables are small and shared) and in access cost (an extra indirection), but provide great flexibility. Tables may even cost less memory than the equivalent struct, since fields do not need to be stored when they are equal to their default.</p>
|
||||
<p>FlatBuffers additionally offers "naked" structs, which do not offer forwards/backwards compatibility, but can be even smaller (useful for very small objects that are unlikely to change, like e.g. a coordinate pair or a RGBA color).</p>
|
||||
<h3>Schemas</h3>
|
||||
<p>While schemas reduce some generality (you can't just read any data without having its schema), they have a lot of upsides:</p>
|
||||
<ul>
|
||||
<li>Most information about the format can be factored into the generated code, reducing memory needed to store data, and time to access it.</li>
|
||||
<li>The strong typing of the data definitions means less error checking/handling at runtime (less can go wrong).</li>
|
||||
<li>A schema enables us to access a buffer without parsing.</li>
|
||||
</ul>
|
||||
<p>FlatBuffer schemas are fairly similar to those of the incumbent, Protocol Buffers, and generally should be readable to those familiar with the C family of languages. We chose to improve upon the features offered by .proto files in the following ways:</p>
|
||||
<ul>
|
||||
<li>Deprecation of fields instead of manual field id assignment. Extending an object in a .proto means hunting for a free slot among the numbers (preferring lower numbers since they have a more compact representation). Besides being inconvenient, it also makes removing fields problematic: you either have to keep them, not making it obvious that this field shouldn't be read/written anymore, and still generating accessors. Or you remove it, but now you risk that there's still old data around that uses that field by the time someone reuses that field id, with nasty consequences.</li>
|
||||
<li>Differentiating between tables and structs (see above). Effectively all table fields are <code>optional</code>, and all struct fields are <code>required</code>.</li>
|
||||
<li>Having a native vector type instead of <code>repeated</code>. This gives you a length without having to collect all items, and in the case of scalars provides for a more compact representation, and one that guarantees adjacency.</li>
|
||||
<li>Having a native <code>union</code> type instead of using a series of <code>optional</code> fields, all of which must be checked individually.</li>
|
||||
<li>Being able to define defaults for all scalars, instead of having to deal with their optionality at each access.</li>
|
||||
<li>A parser that can deal with both schemas and data definitions (JSON compatible) uniformly. </li>
|
||||
</ul>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 153 B |
|
Before Width: | Height: | Size: 95 B |
|
Before Width: | Height: | Size: 98 B |
@@ -1,143 +0,0 @@
|
||||
#nav-tree .children_ul {
|
||||
margin:0;
|
||||
padding:4px;
|
||||
}
|
||||
|
||||
#nav-tree ul {
|
||||
list-style:none outside none;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree li {
|
||||
white-space:nowrap;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree .plus {
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
#nav-tree .selected {
|
||||
background-image: url('tab_a.png');
|
||||
background-repeat:repeat-x;
|
||||
color: #fff;
|
||||
text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0);
|
||||
}
|
||||
|
||||
#nav-tree img {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
border:0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#nav-tree a {
|
||||
text-decoration:none;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
outline:none;
|
||||
}
|
||||
|
||||
#nav-tree .label {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
font: 12px 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif;
|
||||
}
|
||||
|
||||
#nav-tree .label a {
|
||||
padding:2px;
|
||||
}
|
||||
|
||||
#nav-tree .selected a {
|
||||
text-decoration:none;
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
#nav-tree .children_ul {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree .item {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree {
|
||||
padding: 0px 0px;
|
||||
background-color: #FAFAFF;
|
||||
font-size:14px;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#doc-content {
|
||||
overflow:auto;
|
||||
display:block;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
-webkit-overflow-scrolling : touch; /* iOS 5+ */
|
||||
}
|
||||
|
||||
#side-nav {
|
||||
padding:0 6px 0 0;
|
||||
margin: 0px;
|
||||
display:block;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.ui-resizable .ui-resizable-handle {
|
||||
display:block;
|
||||
}
|
||||
|
||||
.ui-resizable-e {
|
||||
background:url("ftv2splitbar.png") repeat scroll right center transparent;
|
||||
cursor:e-resize;
|
||||
height:100%;
|
||||
right:0;
|
||||
top:0;
|
||||
width:6px;
|
||||
}
|
||||
|
||||
.ui-resizable-handle {
|
||||
display:none;
|
||||
font-size:0.1px;
|
||||
position:absolute;
|
||||
z-index:1;
|
||||
}
|
||||
|
||||
#nav-tree-contents {
|
||||
margin: 6px 0px 0px 0px;
|
||||
}
|
||||
|
||||
#nav-tree {
|
||||
background-image:url('nav_h.png');
|
||||
background-repeat:repeat-x;
|
||||
background-color: #F9FAFC;
|
||||
-webkit-overflow-scrolling : touch; /* iOS 5+ */
|
||||
}
|
||||
|
||||
#nav-sync {
|
||||
position:absolute;
|
||||
top:5px;
|
||||
right:24px;
|
||||
z-index:0;
|
||||
}
|
||||
|
||||
#nav-sync img {
|
||||
opacity:0.3;
|
||||
}
|
||||
|
||||
#nav-sync img:hover {
|
||||
opacity:0.9;
|
||||
}
|
||||
|
||||
@media print
|
||||
{
|
||||
#nav-tree { display: none; }
|
||||
div.ui-resizable-handle { display: none; position: relative; }
|
||||
}
|
||||
|
||||
@@ -1,550 +0,0 @@
|
||||
var NAVTREE =
|
||||
[
|
||||
[ "FlatBuffers", "index.html", [
|
||||
[ "Building", "md__building.html", null ],
|
||||
[ "Using the schema compiler", "md__compiler.html", null ],
|
||||
[ "Writing a schema", "md__schemas.html", null ],
|
||||
[ "Use in C++", "md__cpp_usage.html", null ],
|
||||
[ "Use in Go", "md__go_usage.html", null ],
|
||||
[ "Use in Java", "md__java_usage.html", null ],
|
||||
[ "Benchmarks", "md__benchmarks.html", null ],
|
||||
[ "FlatBuffers white paper", "md__white_paper.html", null ],
|
||||
[ "FlatBuffer Internals", "md__internals.html", null ],
|
||||
[ "Formal Grammar of the schema language", "md__grammar.html", null ]
|
||||
] ]
|
||||
];
|
||||
|
||||
var NAVTREEINDEX =
|
||||
[
|
||||
"index.html"
|
||||
];
|
||||
|
||||
var SYNCONMSG = 'click to disable panel synchronisation';
|
||||
var SYNCOFFMSG = 'click to enable panel synchronisation';
|
||||
var navTreeSubIndices = new Array();
|
||||
|
||||
function getData(varName)
|
||||
{
|
||||
var i = varName.lastIndexOf('/');
|
||||
var n = i>=0 ? varName.substring(i+1) : varName;
|
||||
return eval(n.replace(/\-/g,'_'));
|
||||
}
|
||||
|
||||
function stripPath(uri)
|
||||
{
|
||||
return uri.substring(uri.lastIndexOf('/')+1);
|
||||
}
|
||||
|
||||
function stripPath2(uri)
|
||||
{
|
||||
var i = uri.lastIndexOf('/');
|
||||
var s = uri.substring(i+1);
|
||||
var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/);
|
||||
return m ? uri.substring(i-6) : s;
|
||||
}
|
||||
|
||||
function hashValue()
|
||||
{
|
||||
return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,'');
|
||||
}
|
||||
|
||||
function hashUrl()
|
||||
{
|
||||
return '#'+hashValue();
|
||||
}
|
||||
|
||||
function pathName()
|
||||
{
|
||||
return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, '');
|
||||
}
|
||||
|
||||
function localStorageSupported()
|
||||
{
|
||||
try {
|
||||
return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem;
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function storeLink(link)
|
||||
{
|
||||
if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) {
|
||||
window.localStorage.setItem('navpath',link);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteLink()
|
||||
{
|
||||
if (localStorageSupported()) {
|
||||
window.localStorage.setItem('navpath','');
|
||||
}
|
||||
}
|
||||
|
||||
function cachedLink()
|
||||
{
|
||||
if (localStorageSupported()) {
|
||||
return window.localStorage.getItem('navpath');
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getScript(scriptName,func,show)
|
||||
{
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
var script = document.createElement('script');
|
||||
script.id = scriptName;
|
||||
script.type = 'text/javascript';
|
||||
script.onload = func;
|
||||
script.src = scriptName+'.js';
|
||||
if ($.browser.msie && $.browser.version<=8) {
|
||||
// script.onload does not work with older versions of IE
|
||||
script.onreadystatechange = function() {
|
||||
if (script.readyState=='complete' || script.readyState=='loaded') {
|
||||
func(); if (show) showRoot();
|
||||
}
|
||||
}
|
||||
}
|
||||
head.appendChild(script);
|
||||
}
|
||||
|
||||
function createIndent(o,domNode,node,level)
|
||||
{
|
||||
var level=-1;
|
||||
var n = node;
|
||||
while (n.parentNode) { level++; n=n.parentNode; }
|
||||
if (node.childrenData) {
|
||||
var imgNode = document.createElement("img");
|
||||
imgNode.style.paddingLeft=(16*level).toString()+'px';
|
||||
imgNode.width = 16;
|
||||
imgNode.height = 22;
|
||||
imgNode.border = 0;
|
||||
node.plus_img = imgNode;
|
||||
node.expandToggle = document.createElement("a");
|
||||
node.expandToggle.href = "javascript:void(0)";
|
||||
node.expandToggle.onclick = function() {
|
||||
if (node.expanded) {
|
||||
$(node.getChildrenUL()).slideUp("fast");
|
||||
node.plus_img.src = node.relpath+"ftv2pnode.png";
|
||||
node.expanded = false;
|
||||
} else {
|
||||
expandNode(o, node, false, false);
|
||||
}
|
||||
}
|
||||
node.expandToggle.appendChild(imgNode);
|
||||
domNode.appendChild(node.expandToggle);
|
||||
imgNode.src = node.relpath+"ftv2pnode.png";
|
||||
} else {
|
||||
var span = document.createElement("span");
|
||||
span.style.display = 'inline-block';
|
||||
span.style.width = 16*(level+1)+'px';
|
||||
span.style.height = '22px';
|
||||
span.innerHTML = ' ';
|
||||
domNode.appendChild(span);
|
||||
}
|
||||
}
|
||||
|
||||
var animationInProgress = false;
|
||||
|
||||
function gotoAnchor(anchor,aname,updateLocation)
|
||||
{
|
||||
var pos, docContent = $('#doc-content');
|
||||
var ancParent = $(anchor.parent());
|
||||
if (ancParent.hasClass('memItemLeft') ||
|
||||
ancParent.hasClass('fieldname') ||
|
||||
ancParent.hasClass('fieldtype') ||
|
||||
ancParent.is(':header'))
|
||||
{
|
||||
pos = ancParent.position().top;
|
||||
} else if (anchor.position()) {
|
||||
pos = anchor.position().top;
|
||||
}
|
||||
if (pos) {
|
||||
var dist = Math.abs(Math.min(
|
||||
pos-docContent.offset().top,
|
||||
docContent[0].scrollHeight-
|
||||
docContent.height()-docContent.scrollTop()));
|
||||
animationInProgress=true;
|
||||
docContent.animate({
|
||||
scrollTop: pos + docContent.scrollTop() - docContent.offset().top
|
||||
},Math.max(50,Math.min(500,dist)),function(){
|
||||
if (updateLocation) window.location.href=aname;
|
||||
animationInProgress=false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function newNode(o, po, text, link, childrenData, lastNode)
|
||||
{
|
||||
var node = new Object();
|
||||
node.children = Array();
|
||||
node.childrenData = childrenData;
|
||||
node.depth = po.depth + 1;
|
||||
node.relpath = po.relpath;
|
||||
node.isLast = lastNode;
|
||||
|
||||
node.li = document.createElement("li");
|
||||
po.getChildrenUL().appendChild(node.li);
|
||||
node.parentNode = po;
|
||||
|
||||
node.itemDiv = document.createElement("div");
|
||||
node.itemDiv.className = "item";
|
||||
|
||||
node.labelSpan = document.createElement("span");
|
||||
node.labelSpan.className = "label";
|
||||
|
||||
createIndent(o,node.itemDiv,node,0);
|
||||
node.itemDiv.appendChild(node.labelSpan);
|
||||
node.li.appendChild(node.itemDiv);
|
||||
|
||||
var a = document.createElement("a");
|
||||
node.labelSpan.appendChild(a);
|
||||
node.label = document.createTextNode(text);
|
||||
node.expanded = false;
|
||||
a.appendChild(node.label);
|
||||
if (link) {
|
||||
var url;
|
||||
if (link.substring(0,1)=='^') {
|
||||
url = link.substring(1);
|
||||
link = url;
|
||||
} else {
|
||||
url = node.relpath+link;
|
||||
}
|
||||
a.className = stripPath(link.replace('#',':'));
|
||||
if (link.indexOf('#')!=-1) {
|
||||
var aname = '#'+link.split('#')[1];
|
||||
var srcPage = stripPath(pathName());
|
||||
var targetPage = stripPath(link.split('#')[0]);
|
||||
a.href = srcPage!=targetPage ? url : "javascript:void(0)";
|
||||
a.onclick = function(){
|
||||
storeLink(link);
|
||||
if (!$(a).parent().parent().hasClass('selected'))
|
||||
{
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
$(a).parent().parent().addClass('selected');
|
||||
$(a).parent().parent().attr('id','selected');
|
||||
}
|
||||
var anchor = $(aname);
|
||||
gotoAnchor(anchor,aname,true);
|
||||
};
|
||||
} else {
|
||||
a.href = url;
|
||||
a.onclick = function() { storeLink(link); }
|
||||
}
|
||||
} else {
|
||||
if (childrenData != null)
|
||||
{
|
||||
a.className = "nolink";
|
||||
a.href = "javascript:void(0)";
|
||||
a.onclick = node.expandToggle.onclick;
|
||||
}
|
||||
}
|
||||
|
||||
node.childrenUL = null;
|
||||
node.getChildrenUL = function() {
|
||||
if (!node.childrenUL) {
|
||||
node.childrenUL = document.createElement("ul");
|
||||
node.childrenUL.className = "children_ul";
|
||||
node.childrenUL.style.display = "none";
|
||||
node.li.appendChild(node.childrenUL);
|
||||
}
|
||||
return node.childrenUL;
|
||||
};
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function showRoot()
|
||||
{
|
||||
var headerHeight = $("#top").height();
|
||||
var footerHeight = $("#nav-path").height();
|
||||
var windowHeight = $(window).height() - headerHeight - footerHeight;
|
||||
(function (){ // retry until we can scroll to the selected item
|
||||
try {
|
||||
var navtree=$('#nav-tree');
|
||||
navtree.scrollTo('#selected',0,{offset:-windowHeight/2});
|
||||
} catch (err) {
|
||||
setTimeout(arguments.callee, 0);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
function expandNode(o, node, imm, showRoot)
|
||||
{
|
||||
if (node.childrenData && !node.expanded) {
|
||||
if (typeof(node.childrenData)==='string') {
|
||||
var varName = node.childrenData;
|
||||
getScript(node.relpath+varName,function(){
|
||||
node.childrenData = getData(varName);
|
||||
expandNode(o, node, imm, showRoot);
|
||||
}, showRoot);
|
||||
} else {
|
||||
if (!node.childrenVisited) {
|
||||
getNode(o, node);
|
||||
} if (imm || ($.browser.msie && $.browser.version>8)) {
|
||||
// somehow slideDown jumps to the start of tree for IE9 :-(
|
||||
$(node.getChildrenUL()).show();
|
||||
} else {
|
||||
$(node.getChildrenUL()).slideDown("fast");
|
||||
}
|
||||
if (node.isLast) {
|
||||
node.plus_img.src = node.relpath+"ftv2mlastnode.png";
|
||||
} else {
|
||||
node.plus_img.src = node.relpath+"ftv2mnode.png";
|
||||
}
|
||||
node.expanded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function glowEffect(n,duration)
|
||||
{
|
||||
n.addClass('glow').delay(duration).queue(function(next){
|
||||
$(this).removeClass('glow');next();
|
||||
});
|
||||
}
|
||||
|
||||
function highlightAnchor()
|
||||
{
|
||||
var aname = hashUrl();
|
||||
var anchor = $(aname);
|
||||
if (anchor.parent().attr('class')=='memItemLeft'){
|
||||
var rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
|
||||
glowEffect(rows.children(),300); // member without details
|
||||
} else if (anchor.parent().attr('class')=='fieldname'){
|
||||
glowEffect(anchor.parent().parent(),1000); // enum value
|
||||
} else if (anchor.parent().attr('class')=='fieldtype'){
|
||||
glowEffect(anchor.parent().parent(),1000); // struct field
|
||||
} else if (anchor.parent().is(":header")) {
|
||||
glowEffect(anchor.parent(),1000); // section header
|
||||
} else {
|
||||
glowEffect(anchor.next(),1000); // normal member
|
||||
}
|
||||
gotoAnchor(anchor,aname,false);
|
||||
}
|
||||
|
||||
function selectAndHighlight(hash,n)
|
||||
{
|
||||
var a;
|
||||
if (hash) {
|
||||
var link=stripPath(pathName())+':'+hash.substring(1);
|
||||
a=$('.item a[class$="'+link+'"]');
|
||||
}
|
||||
if (a && a.length) {
|
||||
a.parent().parent().addClass('selected');
|
||||
a.parent().parent().attr('id','selected');
|
||||
highlightAnchor();
|
||||
} else if (n) {
|
||||
$(n.itemDiv).addClass('selected');
|
||||
$(n.itemDiv).attr('id','selected');
|
||||
}
|
||||
if ($('#nav-tree-contents .item:first').hasClass('selected')) {
|
||||
$('#nav-sync').css('top','30px');
|
||||
} else {
|
||||
$('#nav-sync').css('top','5px');
|
||||
}
|
||||
showRoot();
|
||||
}
|
||||
|
||||
function showNode(o, node, index, hash)
|
||||
{
|
||||
if (node && node.childrenData) {
|
||||
if (typeof(node.childrenData)==='string') {
|
||||
var varName = node.childrenData;
|
||||
getScript(node.relpath+varName,function(){
|
||||
node.childrenData = getData(varName);
|
||||
showNode(o,node,index,hash);
|
||||
},true);
|
||||
} else {
|
||||
if (!node.childrenVisited) {
|
||||
getNode(o, node);
|
||||
}
|
||||
$(node.getChildrenUL()).css({'display':'block'});
|
||||
if (node.isLast) {
|
||||
node.plus_img.src = node.relpath+"ftv2mlastnode.png";
|
||||
} else {
|
||||
node.plus_img.src = node.relpath+"ftv2mnode.png";
|
||||
}
|
||||
node.expanded = true;
|
||||
var n = node.children[o.breadcrumbs[index]];
|
||||
if (index+1<o.breadcrumbs.length) {
|
||||
showNode(o,n,index+1,hash);
|
||||
} else {
|
||||
if (typeof(n.childrenData)==='string') {
|
||||
var varName = n.childrenData;
|
||||
getScript(n.relpath+varName,function(){
|
||||
n.childrenData = getData(varName);
|
||||
node.expanded=false;
|
||||
showNode(o,node,index,hash); // retry with child node expanded
|
||||
},true);
|
||||
} else {
|
||||
var rootBase = stripPath(o.toroot.replace(/\..+$/, ''));
|
||||
if (rootBase=="index" || rootBase=="pages" || rootBase=="search") {
|
||||
expandNode(o, n, true, true);
|
||||
}
|
||||
selectAndHighlight(hash,n);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectAndHighlight(hash);
|
||||
}
|
||||
}
|
||||
|
||||
function removeToInsertLater(element) {
|
||||
var parentNode = element.parentNode;
|
||||
var nextSibling = element.nextSibling;
|
||||
parentNode.removeChild(element);
|
||||
return function() {
|
||||
if (nextSibling) {
|
||||
parentNode.insertBefore(element, nextSibling);
|
||||
} else {
|
||||
parentNode.appendChild(element);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getNode(o, po)
|
||||
{
|
||||
var insertFunction = removeToInsertLater(po.li);
|
||||
po.childrenVisited = true;
|
||||
var l = po.childrenData.length-1;
|
||||
for (var i in po.childrenData) {
|
||||
var nodeData = po.childrenData[i];
|
||||
po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
|
||||
i==l);
|
||||
}
|
||||
insertFunction();
|
||||
}
|
||||
|
||||
function gotoNode(o,subIndex,root,hash,relpath)
|
||||
{
|
||||
var nti = navTreeSubIndices[subIndex][root+hash];
|
||||
o.breadcrumbs = $.extend(true, [], nti ? nti : navTreeSubIndices[subIndex][root]);
|
||||
if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
|
||||
navTo(o,NAVTREE[0][1],"",relpath);
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
}
|
||||
if (o.breadcrumbs) {
|
||||
o.breadcrumbs.unshift(0); // add 0 for root node
|
||||
showNode(o, o.node, 0, hash);
|
||||
}
|
||||
}
|
||||
|
||||
function navTo(o,root,hash,relpath)
|
||||
{
|
||||
var link = cachedLink();
|
||||
if (link) {
|
||||
var parts = link.split('#');
|
||||
root = parts[0];
|
||||
if (parts.length>1) hash = '#'+parts[1].replace(/[^\w\-]/g,'');
|
||||
else hash='';
|
||||
}
|
||||
if (hash.match(/^#l\d+$/)) {
|
||||
var anchor=$('a[name='+hash.substring(1)+']');
|
||||
glowEffect(anchor.parent(),1000); // line number
|
||||
hash=''; // strip line number anchors
|
||||
}
|
||||
var url=root+hash;
|
||||
var i=-1;
|
||||
while (NAVTREEINDEX[i+1]<=url) i++;
|
||||
if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
|
||||
if (navTreeSubIndices[i]) {
|
||||
gotoNode(o,i,root,hash,relpath)
|
||||
} else {
|
||||
getScript(relpath+'navtreeindex'+i,function(){
|
||||
navTreeSubIndices[i] = eval('NAVTREEINDEX'+i);
|
||||
if (navTreeSubIndices[i]) {
|
||||
gotoNode(o,i,root,hash,relpath);
|
||||
}
|
||||
},true);
|
||||
}
|
||||
}
|
||||
|
||||
function showSyncOff(n,relpath)
|
||||
{
|
||||
n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
|
||||
}
|
||||
|
||||
function showSyncOn(n,relpath)
|
||||
{
|
||||
n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
|
||||
}
|
||||
|
||||
function toggleSyncButton(relpath)
|
||||
{
|
||||
var navSync = $('#nav-sync');
|
||||
if (navSync.hasClass('sync')) {
|
||||
navSync.removeClass('sync');
|
||||
showSyncOff(navSync,relpath);
|
||||
storeLink(stripPath2(pathName())+hashUrl());
|
||||
} else {
|
||||
navSync.addClass('sync');
|
||||
showSyncOn(navSync,relpath);
|
||||
deleteLink();
|
||||
}
|
||||
}
|
||||
|
||||
function initNavTree(toroot,relpath)
|
||||
{
|
||||
var o = new Object();
|
||||
o.toroot = toroot;
|
||||
o.node = new Object();
|
||||
o.node.li = document.getElementById("nav-tree-contents");
|
||||
o.node.childrenData = NAVTREE;
|
||||
o.node.children = new Array();
|
||||
o.node.childrenUL = document.createElement("ul");
|
||||
o.node.getChildrenUL = function() { return o.node.childrenUL; };
|
||||
o.node.li.appendChild(o.node.childrenUL);
|
||||
o.node.depth = 0;
|
||||
o.node.relpath = relpath;
|
||||
o.node.expanded = false;
|
||||
o.node.isLast = true;
|
||||
o.node.plus_img = document.createElement("img");
|
||||
o.node.plus_img.src = relpath+"ftv2pnode.png";
|
||||
o.node.plus_img.width = 16;
|
||||
o.node.plus_img.height = 22;
|
||||
|
||||
if (localStorageSupported()) {
|
||||
var navSync = $('#nav-sync');
|
||||
if (cachedLink()) {
|
||||
showSyncOff(navSync,relpath);
|
||||
navSync.removeClass('sync');
|
||||
} else {
|
||||
showSyncOn(navSync,relpath);
|
||||
}
|
||||
navSync.click(function(){ toggleSyncButton(relpath); });
|
||||
}
|
||||
|
||||
$(window).load(function(){
|
||||
navTo(o,toroot,hashUrl(),relpath);
|
||||
showRoot();
|
||||
});
|
||||
|
||||
$(window).bind('hashchange', function(){
|
||||
if (window.location.hash && window.location.hash.length>1){
|
||||
var a;
|
||||
if ($(location).attr('hash')){
|
||||
var clslink=stripPath(pathName())+':'+hashValue();
|
||||
a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
|
||||
}
|
||||
if (a==null || !$(a).parent().parent().hasClass('selected')){
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
}
|
||||
var link=stripPath2(pathName());
|
||||
navTo(o,link,hashUrl(),relpath);
|
||||
} else if (!animationInProgress) {
|
||||
$('#doc-content').scrollTop(0);
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
navTo(o,toroot,hashUrl(),relpath);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
var NAVTREEINDEX0 =
|
||||
{
|
||||
"index.html":[],
|
||||
"md__benchmarks.html":[6],
|
||||
"md__building.html":[0],
|
||||
"md__compiler.html":[1],
|
||||
"md__cpp_usage.html":[3],
|
||||
"md__go_usage.html":[4],
|
||||
"md__grammar.html":[9],
|
||||
"md__internals.html":[8],
|
||||
"md__java_usage.html":[5],
|
||||
"md__schemas.html":[2],
|
||||
"md__white_paper.html":[7],
|
||||
"pages.html":[]
|
||||
};
|
||||
|
Before Width: | Height: | Size: 123 B |
@@ -1,82 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.7"/>
|
||||
<title>FlatBuffers: Related Pages</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">FlatBuffers
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.7 -->
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('pages.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Related Pages</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock">Here is a list of all related documentation pages:</div><div class="directory">
|
||||
<table class="directory">
|
||||
<tr id="row_0_" class="even"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__building.html" target="_self">Building</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_1_"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__compiler.html" target="_self">Using the schema compiler</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_2_" class="even"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__schemas.html" target="_self">Writing a schema</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_3_"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__cpp_usage.html" target="_self">Use in C++</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_4_" class="even"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__go_usage.html" target="_self">Use in Go</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_5_"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__java_usage.html" target="_self">Use in Java</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_6_" class="even"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__benchmarks.html" target="_self">Benchmarks</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_7_"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__white_paper.html" target="_self">FlatBuffers white paper</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_8_" class="even"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__internals.html" target="_self">FlatBuffer Internals</a></td><td class="desc"></td></tr>
|
||||
<tr id="row_9_"><td class="entry"><span style="width:16px;display:inline-block;"> </span><a class="el" href="md__grammar.html" target="_self">Formal Grammar of the schema language</a></td><td class="desc"></td></tr>
|
||||
</table>
|
||||
</div><!-- directory -->
|
||||
</div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-49880327-7', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,97 +0,0 @@
|
||||
var cookie_namespace = 'doxygen';
|
||||
var sidenav,navtree,content,header;
|
||||
|
||||
function readCookie(cookie)
|
||||
{
|
||||
var myCookie = cookie_namespace+"_"+cookie+"=";
|
||||
if (document.cookie)
|
||||
{
|
||||
var index = document.cookie.indexOf(myCookie);
|
||||
if (index != -1)
|
||||
{
|
||||
var valStart = index + myCookie.length;
|
||||
var valEnd = document.cookie.indexOf(";", valStart);
|
||||
if (valEnd == -1)
|
||||
{
|
||||
valEnd = document.cookie.length;
|
||||
}
|
||||
var val = document.cookie.substring(valStart, valEnd);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function writeCookie(cookie, val, expiration)
|
||||
{
|
||||
if (val==undefined) return;
|
||||
if (expiration == null)
|
||||
{
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
|
||||
expiration = date.toGMTString();
|
||||
}
|
||||
document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/";
|
||||
}
|
||||
|
||||
function resizeWidth()
|
||||
{
|
||||
var windowWidth = $(window).width() + "px";
|
||||
var sidenavWidth = $(sidenav).outerWidth();
|
||||
content.css({marginLeft:parseInt(sidenavWidth)+"px"});
|
||||
writeCookie('width',sidenavWidth, null);
|
||||
}
|
||||
|
||||
function restoreWidth(navWidth)
|
||||
{
|
||||
var windowWidth = $(window).width() + "px";
|
||||
content.css({marginLeft:parseInt(navWidth)+6+"px"});
|
||||
sidenav.css({width:navWidth + "px"});
|
||||
}
|
||||
|
||||
function resizeHeight()
|
||||
{
|
||||
var headerHeight = header.outerHeight();
|
||||
var footerHeight = footer.outerHeight();
|
||||
var windowHeight = $(window).height() - headerHeight - footerHeight;
|
||||
content.css({height:windowHeight + "px"});
|
||||
navtree.css({height:windowHeight + "px"});
|
||||
sidenav.css({height:windowHeight + "px",top: headerHeight+"px"});
|
||||
}
|
||||
|
||||
function initResizable()
|
||||
{
|
||||
header = $("#top");
|
||||
sidenav = $("#side-nav");
|
||||
content = $("#doc-content");
|
||||
navtree = $("#nav-tree");
|
||||
footer = $("#nav-path");
|
||||
$(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } });
|
||||
$(window).resize(function() { resizeHeight(); });
|
||||
var width = readCookie('width');
|
||||
if (width) { restoreWidth(width); } else { resizeWidth(); }
|
||||
resizeHeight();
|
||||
var url = location.href;
|
||||
var i=url.indexOf("#");
|
||||
if (i>=0) window.location.hash=url.substr(i);
|
||||
var _preventDefault = function(evt) { evt.preventDefault(); };
|
||||
$("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
|
||||
$(document).bind('touchmove',function(e){
|
||||
var device = navigator.userAgent.toLowerCase();
|
||||
var ios = device.match(/(iphone|ipod|ipad)/);
|
||||
if (ios) {
|
||||
try {
|
||||
var target = e.target;
|
||||
while (target) {
|
||||
if ($(target).css('-webkit-overflow-scrolling')=='touch') return;
|
||||
target = target.parentNode;
|
||||
}
|
||||
e.preventDefault();
|
||||
} catch(err) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 853 B |
|
Before Width: | Height: | Size: 845 B |
|
Before Width: | Height: | Size: 142 B |
|
Before Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 177 B |
|
Before Width: | Height: | Size: 184 B |
@@ -1,60 +0,0 @@
|
||||
.tabs, .tabs2, .tabs3 {
|
||||
background-image: url('tab_b.png');
|
||||
width: 100%;
|
||||
z-index: 101;
|
||||
font-size: 13px;
|
||||
font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif;
|
||||
}
|
||||
|
||||
.tabs2 {
|
||||
font-size: 10px;
|
||||
}
|
||||
.tabs3 {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.tablist {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: table;
|
||||
}
|
||||
|
||||
.tablist li {
|
||||
float: left;
|
||||
display: table-cell;
|
||||
background-image: url('tab_b.png');
|
||||
line-height: 36px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.tablist a {
|
||||
display: block;
|
||||
padding: 0 20px;
|
||||
font-weight: bold;
|
||||
background-image:url('tab_s.png');
|
||||
background-repeat:no-repeat;
|
||||
background-position:right;
|
||||
color: #283A5D;
|
||||
text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9);
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.tabs3 .tablist a {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.tablist a:hover {
|
||||
background-image: url('tab_h.png');
|
||||
background-repeat:repeat-x;
|
||||
color: #fff;
|
||||
text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.tablist li.current a {
|
||||
background-image: url('tab_a.png');
|
||||
background-repeat:repeat-x;
|
||||
color: #fff;
|
||||
text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0);
|
||||
}
|
||||
BIN
docs/images/fpl_logo_small.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
docs/images/ftv2mnode.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
docs/images/ftv2pnode.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
@@ -1,10 +1,17 @@
|
||||
# Benchmarks
|
||||
Benchmarks {#flatbuffers_benchmarks}
|
||||
==========
|
||||
|
||||
Comparing against other serialization solutions, running on Windows 7
|
||||
64bit. We use the LITE runtime for Protocol Buffers (less code / lower
|
||||
overhead), Rapid JSON (one of the fastest C++ JSON parsers around),
|
||||
and pugixml, also one of the fastest XML parsers.
|
||||
|
||||
We also compare against code that doesn't use a serialization library
|
||||
at all (the column "Raw structs"), which is what you get if you write
|
||||
hardcoded code that just writes structs. This is the fastest possible,
|
||||
but of course is not cross platform nor has any kind of forwards /
|
||||
backwards compatibility.
|
||||
|
||||
We compare against Flatbuffers with the binary wire format (as
|
||||
intended), and also with JSON as the wire format with the optional JSON
|
||||
parser (which, using a schema, parses JSON into a binary buffer that can
|
||||
@@ -14,17 +21,17 @@ The benchmark object is a set of about 10 objects containing an array, 4
|
||||
strings, and a large variety of int/float scalar values of all sizes,
|
||||
meant to be representative of game data, e.g. a scene format.
|
||||
|
||||
| | FlatBuffers (binary) | Protocol Buffers LITE | Rapid JSON | FlatBuffers (JSON) | pugixml |
|
||||
|--------------------------------------------------------|-----------------------|-----------------------|-----------------------|-----------------------| ----------------------|
|
||||
| Decode + Traverse + Dealloc (1 million times, seconds) | 0.08 | 302 | 583 | 105 | 196 |
|
||||
| Decode / Traverse / Dealloc (breakdown) | 0 / 0.08 / 0 | 220 / 0.15 / 81 | 294 / 0.9 / 287 | 70 / 0.08 / 35 | 41 / 3.9 / 150 |
|
||||
| Encode (1 million times, seconds) | 3.2 | 185 | 650 | 169 | 273 |
|
||||
| Wire format size (normal / zlib, bytes) | 344 / 220 | 228 / 174 | 1475 / 322 | 1029 / 298 | 1137 / 341 |
|
||||
| Memory needed to store decoded wire (bytes / blocks) | 0 / 0 | 760 / 20 | 65689 / 4 | 328 / 1 | 34194 / 3 |
|
||||
| Transient memory allocated during decode (KB) | 0 | 1 | 131 | 4 | 34 |
|
||||
| Generated source code size (KB) | 4 | 61 | 0 | 4 | 0 |
|
||||
| Field access in handwritten traversal code | typed accessors | typed accessors | manual error checking | typed accessors | manual error checking |
|
||||
| Library source code (KB) | 15 | some subset of 3800 | 87 | 43 | 327 |
|
||||
| | FlatBuffers (binary) | Protocol Buffers LITE | Rapid JSON | FlatBuffers (JSON) | pugixml | Raw structs |
|
||||
|--------------------------------------------------------|-----------------------|-----------------------|-----------------------|------------------------| ----------------------| ----------------------|
|
||||
| Decode + Traverse + Dealloc (1 million times, seconds) | 0.08 | 302 | 583 | 105 | 196 | 0.02 |
|
||||
| Decode / Traverse / Dealloc (breakdown) | 0 / 0.08 / 0 | 220 / 0.15 / 81 | 294 / 0.9 / 287 | 70 / 0.08 / 35 | 41 / 3.9 / 150 | 0 / 0.02 / 0 |
|
||||
| Encode (1 million times, seconds) | 3.2 | 185 | 650 | 169 | 273 | 0.15 |
|
||||
| Wire format size (normal / zlib, bytes) | 344 / 220 | 228 / 174 | 1475 / 322 | 1029 / 298 | 1137 / 341 | 312 / 187 |
|
||||
| Memory needed to store decoded wire (bytes / blocks) | 0 / 0 | 760 / 20 | 65689 / 4 | 328 / 1 | 34194 / 3 | 0 / 0 |
|
||||
| Transient memory allocated during decode (KB) | 0 | 1 | 131 | 4 | 34 | 0 |
|
||||
| Generated source code size (KB) | 4 | 61 | 0 | 4 | 0 | 0 |
|
||||
| Field access in handwritten traversal code | typed accessors | typed accessors | manual error checking | typed accessors | manual error checking | typed but no safety |
|
||||
| Library source code (KB) | 15 | some subset of 3800 | 87 | 43 | 327 | 0 |
|
||||
|
||||
### Some other serialization systems we compared against but did not benchmark (yet), in rough order of applicability:
|
||||
|
||||
@@ -33,7 +40,7 @@ meant to be representative of game data, e.g. a scene format.
|
||||
optional fields to allow deprecating fields or serializing with missing
|
||||
fields for which defaults exist).
|
||||
It currently also isn't fully cross-platform portable (lack of VS support).
|
||||
- msgpack: has very minimal forwards/backwards compatability support when used
|
||||
- msgpack: has very minimal forwards/backwards compatibility support when used
|
||||
with the typed C++ interface. Also lacks VS2010 support.
|
||||
- Thrift: very similar to Protocol Buffers, but appears to be less efficient,
|
||||
and have more dependencies.
|
||||
@@ -46,3 +53,11 @@ meant to be representative of game data, e.g. a scene format.
|
||||
fields manually), is very much tied to the rest of the engine, and works
|
||||
without a schema to generate code (tied to your C++ class definition).
|
||||
|
||||
### Code for benchmarks
|
||||
|
||||
Code for these benchmarks sits in `benchmarks/` in git branch `benchmarks`.
|
||||
It sits in its own branch because it has submodule dependencies that the main
|
||||
project doesn't need, and the code standards do not meet those of the main
|
||||
project. Please read `benchmarks/cpp/README.txt` before working with the code.
|
||||
|
||||
<br>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
# Building
|
||||
Building {#flatbuffers_guide_building}
|
||||
========
|
||||
|
||||
## Building with Visual Studio or Xcode projects
|
||||
|
||||
There are project files for Visual Studio and Xcode that should allow you
|
||||
to build the compiler `flatc`, the samples and the tests out of the box.
|
||||
|
||||
## Building with CMake
|
||||
|
||||
Alternatively, the distribution comes with a `cmake` file that should allow
|
||||
you to build project/make files for any platform. For details on `cmake`, see
|
||||
<http://www.cmake.org>. In brief, depending on your platform, use one of
|
||||
@@ -18,28 +23,45 @@ Note that to use clang instead of gcc, you may need to set up your environment
|
||||
variables, e.g.
|
||||
`CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -G "Unix Makefiles"`.
|
||||
|
||||
Optionally, run the `flattests` executable to ensure everything is working
|
||||
correctly on your system. If this fails, please contact us!
|
||||
Optionally, run the `flattests` executable from the root `flatbuffers/`
|
||||
directory to ensure everything is working correctly on your system. If this
|
||||
fails, please contact us!
|
||||
|
||||
Note that you MUST be in the root of the FlatBuffers distribution when you
|
||||
run 'flattests' (and the samples), or it will fail to load its files.
|
||||
Building should also produce two sample executables, `flatsamplebinary` and
|
||||
`flatsampletext`, see the corresponding `.cpp` files in the
|
||||
`flatbuffers/samples` directory.
|
||||
|
||||
Building should also produce two sample executables, `sample_binary` and
|
||||
`sample_text`, see the corresponding `.cpp` file in the samples directory.
|
||||
*Note that you MUST be in the root of the FlatBuffers distribution when you
|
||||
run 'flattests' or `flatsampletext`, or it will fail to load its files.*
|
||||
|
||||
There is an `android` directory that contains all you need to build the test
|
||||
executable on android (use the included `build_apk.sh` script, or use
|
||||
## Building for Android
|
||||
|
||||
There is a `flatbuffers/android` directory that contains all you need to build
|
||||
the test executable on android (use the included `build_apk.sh` script, or use
|
||||
`ndk_build` / `adb` etc. as usual). Upon running, it will output to the log
|
||||
if tests succeeded or not.
|
||||
|
||||
There is usually no runtime to compile, as the code consists of a single
|
||||
header, `include/flatbuffers/flatbuffers.h`. You should add the
|
||||
You may also run an android sample from inside the `flatbuffers/samples`, by
|
||||
running the `android_sample.sh` script. Optionally, you may go to the
|
||||
`flatbuffers/samples/android` folder and build the sample with the
|
||||
`build_apk.sh` script or `ndk_build` / `adb` etc.
|
||||
|
||||
## Using FlatBuffers in your own projects.
|
||||
|
||||
For C++, there is usually no runtime to compile, as the code consists of a
|
||||
single header, `include/flatbuffers/flatbuffers.h`. You should add the
|
||||
`include` folder to your include paths. If you wish to be
|
||||
able to load schemas and/or parse text into binary buffers at runtime,
|
||||
you additionally need the other headers in `include/flatbuffers`. You must
|
||||
also compile/link `src/idl_parser.cpp` (and `src/idl_gen_text.cpp` if you
|
||||
also want to be able convert binary to text).
|
||||
|
||||
To see how to include FlatBuffers in any of our supported languages, please
|
||||
view the [Tutorial](@ref flatbuffers_guide_tutorial) and select your appropriate
|
||||
language using the radio buttons.
|
||||
|
||||
#### For Google Play apps
|
||||
|
||||
For applications on Google Play that integrate this library, usage is tracked.
|
||||
This tracking is done automatically using the embedded version string
|
||||
(flatbuffer_version_string), and helps us continue to optimize it.
|
||||
|
||||
1
docs/source/CONTRIBUTING.md
Symbolic link
@@ -0,0 +1 @@
|
||||
../../CONTRIBUTING
|
||||
@@ -1,36 +1,105 @@
|
||||
# Using the schema compiler
|
||||
Using the schema compiler {#flatbuffers_guide_using_schema_compiler}
|
||||
=========================
|
||||
|
||||
Usage:
|
||||
|
||||
flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -S ] FILES...
|
||||
flatc [ GENERATOR OPTIONS ] [ -o PATH ] [ -I PATH ] [ -S ] FILES...
|
||||
[ -- FILES...]
|
||||
|
||||
The files are read and parsed in order, and can contain either schemas
|
||||
or data (see below). Later files can make use of definitions in earlier
|
||||
files.
|
||||
or data (see below). Data files are processed according to the definitions of
|
||||
the most recent schema specified.
|
||||
|
||||
`--` indicates that the following files are binary files in
|
||||
FlatBuffer format conforming to the schema(s) indicated before it.
|
||||
Incompatible binary files currently will give unpredictable results (!)
|
||||
FlatBuffer format conforming to the schema indicated before it.
|
||||
|
||||
Depending on the flags passed, additional files may
|
||||
be generated for each file processed:
|
||||
|
||||
- `-c` : Generate a C++ header for all definitions in this file (as
|
||||
`filename_generated.h`). Skipped for data.
|
||||
For any schema input files, one or more generators can be specified:
|
||||
|
||||
- `-j` : Generate Java classes. Skipped for data.
|
||||
- `--cpp`, `-c` : Generate a C++ header for all definitions in this file (as
|
||||
`filename_generated.h`).
|
||||
|
||||
- `-b` : If data is contained in this file, generate a
|
||||
`filename.bin` containing the binary flatbuffer.
|
||||
- `--java`, `-j` : Generate Java code.
|
||||
|
||||
- `-t` : If data is contained in this file, generate a
|
||||
- `--csharp`, `-n` : Generate C# code.
|
||||
|
||||
- `--go`, `-g` : Generate Go code.
|
||||
|
||||
- `--python`, `-p`: Generate Python code.
|
||||
|
||||
- `--javascript`, `-s`: Generate JavaScript code.
|
||||
|
||||
- `--php`: Generate PHP code.
|
||||
|
||||
For any data input files:
|
||||
|
||||
- `--binary`, `-b` : If data is contained in this file, generate a
|
||||
`filename.bin` containing the binary flatbuffer (or a different extension
|
||||
if one is specified in the schema).
|
||||
|
||||
- `--json`, `-t` : If data is contained in this file, generate a
|
||||
`filename.json` representing the data in the flatbuffer.
|
||||
|
||||
Additional options:
|
||||
|
||||
- `-o PATH` : Output all generated files to PATH (either absolute, or
|
||||
relative to the current directory). If omitted, PATH will be the
|
||||
current directory. PATH should end in your systems path separator,
|
||||
e.g. `/` or `\`.
|
||||
|
||||
- `-S` : Generate strict JSON (field names are enclosed in quotes).
|
||||
By default, no quotes are generated.
|
||||
- `-I PATH` : when encountering `include` statements, attempt to load the
|
||||
files from this path. Paths will be tried in the order given, and if all
|
||||
fail (or none are specified) it will try to load relative to the path of
|
||||
the schema file being parsed.
|
||||
|
||||
- `-M` : Print make rules for generated files.
|
||||
|
||||
- `--strict-json` : Require & generate strict JSON (field names are enclosed
|
||||
in quotes, no trailing commas in tables/vectors). By default, no quotes are
|
||||
required/generated, and trailing commas are allowed.
|
||||
|
||||
- `--defaults-json` : Output fields whose value is equal to the default value
|
||||
when writing JSON text.
|
||||
|
||||
- `--no-prefix` : Don't prefix enum values in generated C++ by their enum
|
||||
type.
|
||||
|
||||
- `--scoped-enums` : Use C++11 style scoped and strongly typed enums in
|
||||
generated C++. This also implies `--no-prefix`.
|
||||
|
||||
- `--gen-includes` : (deprecated), this is the default behavior.
|
||||
If the original behavior is required (no include
|
||||
statements) use `--no-includes.`
|
||||
|
||||
- `--no-includes` : Don't generate include statements for included schemas the
|
||||
generated file depends on (C++).
|
||||
|
||||
- `--gen-mutable` : Generate additional non-const accessors for mutating
|
||||
FlatBuffers in-place.
|
||||
|
||||
- `--gen-onefile` : Generate single output file (useful for C#)
|
||||
|
||||
- `--gen-all`: Generate not just code for the current schema files, but
|
||||
for all files it includes as well. If the language uses a single file for
|
||||
output (by default the case for C++ and JS), all code will end up in
|
||||
this one file.
|
||||
|
||||
- `--raw-binary` : Allow binaries without a file_indentifier to be read.
|
||||
This may crash flatc given a mismatched schema.
|
||||
|
||||
- `--proto`: Expect input files to be .proto files (protocol buffers).
|
||||
Output the corresponding .fbs file.
|
||||
Currently supports: `package`, `message`, `enum`, nested declarations,
|
||||
`import` (use `-I` for paths), `extend`, `oneof`, `group`.
|
||||
Does not support, but will skip without error: `option`, `service`,
|
||||
`extensions`, and most everything else.
|
||||
|
||||
- `--schema`: Serialize schemas instead of JSON (use with -b). This will
|
||||
output a binary version of the specified schema that itself corresponds
|
||||
to the reflection/reflection.fbs schema. Loading this binary file is the
|
||||
basis for reflection functionality.
|
||||
|
||||
NOTE: short-form options for generators are deprecated, use the long form
|
||||
whenever possible.
|
||||
|
||||
@@ -1,137 +1,140 @@
|
||||
# Use in C++
|
||||
Use in C++ {#flatbuffers_guide_use_cpp}
|
||||
==========
|
||||
|
||||
Assuming you have written a schema using the above language in say
|
||||
`mygame.fbs` (FlatBuffer Schema, though the extension doesn't matter),
|
||||
you've generated a C++ header called `mygame_generated.h` using the
|
||||
## Before you get started
|
||||
|
||||
Before diving into the FlatBuffers usage in C++, it should be noted that
|
||||
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide
|
||||
to general FlatBuffers usage in all of the supported languages (including C++).
|
||||
This page is designed to cover the nuances of FlatBuffers usage, specific to
|
||||
C++.
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
This page assumes you have written a FlatBuffers schema and compiled it
|
||||
with the Schema Compiler. If you have not, please see
|
||||
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler)
|
||||
and [Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||
|
||||
Assuming you wrote a schema, say `mygame.fbs` (though the extension doesn't
|
||||
matter), you've generated a C++ header called `mygame_generated.h` using the
|
||||
compiler (e.g. `flatc -c mygame.fbs`), you can now start using this in
|
||||
your program by including the header. As noted, this header relies on
|
||||
`flatbuffers/flatbuffers.h`, which should be in your include path.
|
||||
|
||||
### Writing in C++
|
||||
## FlatBuffers C++ library code location
|
||||
|
||||
To start creating a buffer, create an instance of `FlatBufferBuilder`
|
||||
which will contain the buffer as it grows:
|
||||
The code for the FlatBuffers C++ library can be found at
|
||||
`flatbuffers/include/flatbuffers`. You can browse the library code on the
|
||||
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/
|
||||
include/flatbuffers).
|
||||
|
||||
FlatBufferBuilder fbb;
|
||||
## Testing the FlatBuffers C++ library
|
||||
|
||||
Before we serialize a Monster, we need to first serialize any objects
|
||||
that are contained there-in, i.e. we serialize the data tree using
|
||||
depth first, pre-order traversal. This is generally easy to do on
|
||||
any tree structures. For example:
|
||||
The code to test the C++ library can be found at `flatbuffers/tests`.
|
||||
The test code itself is located in
|
||||
[test.cpp](https://github.com/google/flatbuffers/blob/master/tests/test.cpp).
|
||||
|
||||
auto name = fbb.CreateString("MyMonster");
|
||||
This test file is built alongside `flatc`. To review how to build the project,
|
||||
please read the [Building](@ref flatbuffers_guide_building) documenation.
|
||||
|
||||
unsigned char inv[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
auto inventory = fbb.CreateVector(inv, 10);
|
||||
To run the tests, execute `flattests` from the root `flatbuffers/` directory.
|
||||
For example, on [Linux](https://en.wikipedia.org/wiki/Linux), you would simply
|
||||
run: `./flattests`.
|
||||
|
||||
`CreateString` and `CreateVector` serialize these two built-in
|
||||
datatypes, and return offsets into the serialized data indicating where
|
||||
they are stored, such that `Monster` below can refer to them.
|
||||
## Using the FlatBuffers C++ library
|
||||
|
||||
`CreateString` can also take an `std::string`, or a `const char *` with
|
||||
an explicit length, and is suitable for holding UTF-8 and binary
|
||||
data if needed.
|
||||
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||
example of how to use FlatBuffers in C++.*
|
||||
|
||||
`CreateVector` can also take an `std::vector`. The
|
||||
offset it returns is typed, i.e. can only be used to set fields of the
|
||||
correct type below. To create a vector of struct objects (which will
|
||||
be stored as contiguous memory in the buffer, use `CreateVectorOfStructs`
|
||||
instead.
|
||||
FlatBuffers supports both reading and writing FlatBuffers in C++.
|
||||
|
||||
Vec3 vec(1, 2, 3);
|
||||
To use FlatBuffers in your code, first generate the C++ classes from your
|
||||
schema with the `--cpp` option to `flatc`. Then you can include both FlatBuffers
|
||||
and the generated code to read or write FlatBuffers.
|
||||
|
||||
`Vec3` is the first example of code from our generated
|
||||
header. Structs (unlike tables) translate to simple structs in C++, so
|
||||
we can construct them in a familiar way.
|
||||
For example, here is how you would read a FlatBuffer binary file in C++:
|
||||
First, include the library and generated code. Then read the file into
|
||||
a `char *` array, which you pass to `GetMonster()`.
|
||||
|
||||
We have now serialized the non-scalar components of of the monster
|
||||
example, so we could create the monster something like this:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "monster_test_generate.h"
|
||||
#include <cstdio> // For printing and file access.
|
||||
|
||||
auto mloc = CreateMonster(fbb, &vec, 150, 80, name, inventory, Color_Red, 0, Any_NONE);
|
||||
FILE* file = fopen("monsterdata_test.mon", "rb");
|
||||
fseek(file, 0L, SEEK_END);
|
||||
int length = ftell(file);
|
||||
fseek(file, 0L, SEEK_SET);
|
||||
char *data = new char[length];
|
||||
fread(data, sizeof(char), length, file);
|
||||
fclose(file);
|
||||
|
||||
Note that we're passing `150` for the `mana` field, which happens to be the
|
||||
default value: this means the field will not actually be written to the buffer,
|
||||
since we'll get that value anyway when we query it. This is a nice space
|
||||
savings, since it is very common for fields to be at their default. It means
|
||||
we also don't need to be scared to add fields only used in a minority of cases,
|
||||
since they won't bloat up the buffer sizes if they're not actually used.
|
||||
auto monster = GetMonster(data);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
We do something similarly for the union field `test` by specifying a `0` offset
|
||||
and the `NONE` enum value (part of every union) to indicate we don't actually
|
||||
want to write this field. You can use `0` also as a default for other
|
||||
non-scalar types, such as strings, vectors and tables.
|
||||
`monster` is of type `Monster *`, and points to somewhere *inside* your
|
||||
buffer (root object pointers are not the same as `buffer_pointer` !).
|
||||
If you look in your generated header, you'll see it has
|
||||
convenient accessors for all fields, e.g. `hp()`, `mana()`, etc:
|
||||
|
||||
Tables (like `Monster`) give you full flexibility on what fields you write
|
||||
(unlike `Vec3`, which always has all fields set because it is a `struct`).
|
||||
If you want even more control over this (i.e. skip fields even when they are
|
||||
not default), instead of the convenient `CreateMonster` call we can also
|
||||
build the object field-by-field manually:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
printf("%d\n", monster->hp()); // `80`
|
||||
printf("%d\n", monster->mana()); // default value of `150`
|
||||
printf("%s\n", monster->name()->c_str()); // "MyMonster"
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
MonsterBuilder mb(fbb);
|
||||
mb.add_pos(&vec);
|
||||
mb.add_hp(80);
|
||||
mb.add_name(name);
|
||||
mb.add_inventory(inventory);
|
||||
auto mloc = mb.Finish();
|
||||
*Note: That we never stored a `mana` value, so it will return the default.*
|
||||
|
||||
We start with a temporary helper class `MonsterBuilder` (which is
|
||||
defined in our generated code also), then call the various `add_`
|
||||
methods to set fields, and `Finish` to complete the object. This is
|
||||
pretty much the same code as you find inside `CreateMonster`, except
|
||||
we're leaving out a few fields. Fields may also be added in any order,
|
||||
though orderings with fields of the same size adjacent
|
||||
to each other most efficient in size, due to alignment. You should
|
||||
not nest these Builder classes (serialize your
|
||||
data in pre-order).
|
||||
## Reflection (& Resizing)
|
||||
|
||||
Regardless of whether you used `CreateMonster` or `MonsterBuilder`, you
|
||||
now have an offset to the root of your data, and you can finish the
|
||||
buffer using:
|
||||
There is experimental support for reflection in FlatBuffers, allowing you to
|
||||
read and write data even if you don't know the exact format of a buffer, and
|
||||
even allows you to change sizes of strings and vectors in-place.
|
||||
|
||||
FinishMonsterBuffer(fbb, mloc);
|
||||
The way this works is very elegant; there is actually a FlatBuffer schema that
|
||||
describes schemas (!) which you can find in `reflection/reflection.fbs`.
|
||||
The compiler, `flatc`, can write out any schemas it has just parsed as a binary
|
||||
FlatBuffer, corresponding to this meta-schema.
|
||||
|
||||
The buffer is now ready to be stored somewhere, sent over the network,
|
||||
be compressed, or whatever you'd like to do with it. You can access the
|
||||
start of the buffer with `fbb.GetBufferPointer()`, and it's size from
|
||||
`fbb.GetSize()`.
|
||||
Loading in one of these binary schemas at runtime allows you traverse any
|
||||
FlatBuffer data that corresponds to it without knowing the exact format. You
|
||||
can query what fields are present, and then read/write them after.
|
||||
|
||||
`samples/sample_binary.cpp` is a complete code sample similar to
|
||||
the code above, that also includes the reading code below.
|
||||
For convenient field manipulation, you can include the header
|
||||
`flatbuffers/reflection.h` which includes both the generated code from the meta
|
||||
schema, as well as a lot of helper functions.
|
||||
|
||||
### Reading in C++
|
||||
And example of usage, for the time being, can be found in
|
||||
`test.cpp/ReflectionTest()`.
|
||||
|
||||
If you've received a buffer from somewhere (disk, network, etc.) you can
|
||||
directly start traversing it using:
|
||||
## Storing maps / dictionaries in a FlatBuffer
|
||||
|
||||
auto monster = GetMonster(buffer_pointer);
|
||||
FlatBuffers doesn't support maps natively, but there is support to
|
||||
emulate their behavior with vectors and binary search, which means you
|
||||
can have fast lookups directly from a FlatBuffer without having to unpack
|
||||
your data into a `std::map` or similar.
|
||||
|
||||
`monster` is of type `Monster *`, and points to somewhere inside your
|
||||
buffer. If you look in your generated header, you'll see it has
|
||||
convenient accessors for all fields, e.g.
|
||||
To use it:
|
||||
- Designate one of the fields in a table as they "key" field. You do this
|
||||
by setting the `key` attribute on this field, e.g.
|
||||
`name:string (key)`.
|
||||
You may only have one key field, and it must be of string or scalar type.
|
||||
- Write out tables of this type as usual, collect their offsets in an
|
||||
array or vector.
|
||||
- Instead of `CreateVector`, call `CreateVectorOfSortedTables`,
|
||||
which will first sort all offsets such that the tables they refer to
|
||||
are sorted by the key field, then serialize it.
|
||||
- Now when you're accessing the FlatBuffer, you can use `Vector::LookupByKey`
|
||||
instead of just `Vector::Get` to access elements of the vector, e.g.:
|
||||
`myvector->LookupByKey("Fred")`, which returns a pointer to the
|
||||
corresponding table type, or `nullptr` if not found.
|
||||
`LookupByKey` performs a binary search, so should have a similar speed to
|
||||
`std::map`, though may be faster because of better caching. `LookupByKey`
|
||||
only works if the vector has been sorted, it will likely not find elements
|
||||
if it hasn't been sorted.
|
||||
|
||||
assert(monster->hp() == 80);
|
||||
assert(monster->mana() == 150); // default
|
||||
assert(strcmp(monster->name()->c_str(), "MyMonster") == 0);
|
||||
|
||||
These should all be true. Note that we never stored a `mana` value, so
|
||||
it will return the default.
|
||||
|
||||
To access sub-objects, in this case the `Vec3`:
|
||||
|
||||
auto pos = monster->pos();
|
||||
assert(pos);
|
||||
assert(pos->z() == 3);
|
||||
|
||||
If we had not set the `pos` field during serialization, it would be
|
||||
`NULL`.
|
||||
|
||||
Similarly, we can access elements of the inventory array:
|
||||
|
||||
auto inv = monster->inventory();
|
||||
assert(inv);
|
||||
assert(inv->Get(9) == 9);
|
||||
|
||||
### Direct memory access
|
||||
## Direct memory access
|
||||
|
||||
As you can see from the above examples, all elements in a buffer are
|
||||
accessed through generated accessors. This is because everything is
|
||||
@@ -156,7 +159,7 @@ machines, so only use tricks like this if you can guarantee you're not
|
||||
shipping on a big endian machine (an `assert(FLATBUFFERS_LITTLEENDIAN)`
|
||||
would be wise).
|
||||
|
||||
### Access of untrusted buffers
|
||||
## Access of untrusted buffers
|
||||
|
||||
The generated accessor functions access fields over offsets, which is
|
||||
very quick. These offsets are not verified at run-time, so a malformed
|
||||
@@ -175,7 +178,9 @@ is accessed, all reads will end up inside the buffer.
|
||||
Each root type will have a verification function generated for it,
|
||||
e.g. for `Monster`, you can call:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
bool ok = VerifyMonsterBuffer(Verifier(buf, len));
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if `ok` is true, the buffer is safe to read.
|
||||
|
||||
@@ -188,6 +193,13 @@ a full traversal (since any scalar data is not actually touched),
|
||||
and since it may cause the buffer to be brought into cache before
|
||||
reading, the actual overhead may be even lower than expected.
|
||||
|
||||
In specialized cases where a denial of service attack is possible,
|
||||
the verifier has two additional constructor arguments that allow
|
||||
you to limit the nesting depth and total amount of tables the
|
||||
verifier may encounter before declaring the buffer malformed. The default is
|
||||
`Verifier(buf, len, 64 /* max depth */, 1000000, /* max tables */)` which
|
||||
should be sufficient for most uses.
|
||||
|
||||
## Text & schema parsing
|
||||
|
||||
Using binary buffers with the generated header provides a super low
|
||||
@@ -204,7 +216,7 @@ accepted).
|
||||
|
||||
There are two ways to use text formats:
|
||||
|
||||
### Using the compiler as a conversion tool
|
||||
#### Using the compiler as a conversion tool
|
||||
|
||||
This is the preferred path, as it doesn't require you to add any new
|
||||
code to your program, and is maximally efficient since you can ship with
|
||||
@@ -216,7 +228,7 @@ users/developers to perform, though you might be able to automate it.
|
||||
This will generate the binary file `mydata_wire.bin` which can be loaded
|
||||
as before.
|
||||
|
||||
### Making your program capable of loading text directly
|
||||
#### Making your program capable of loading text directly
|
||||
|
||||
This gives you maximum flexibility. You could even opt to support both,
|
||||
i.e. check for both files, and regenerate the binary from text when
|
||||
@@ -232,11 +244,15 @@ Load text (either a schema or json) into an in-memory buffer (there is a
|
||||
convenient `LoadFile()` utility function in `flatbuffers/util.h` if you
|
||||
wish). Construct a parser:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
flatbuffers::Parser parser;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Now you can parse any number of text files in sequence:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
parser.Parse(text_file.c_str());
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This works similarly to how the command-line compiler works: a sequence
|
||||
of files parsed by the same `Parser` object allow later files to
|
||||
@@ -244,6 +260,10 @@ reference definitions in earlier files. Typically this means you first
|
||||
load a schema file (which populates `Parser` with definitions), followed
|
||||
by one or more JSON files.
|
||||
|
||||
As optional argument to `Parse`, you may specify a null-terminated list of
|
||||
include paths. If not specified, any include statements try to resolve from
|
||||
the current directory.
|
||||
|
||||
If there were any parsing errors, `Parse` will return `false`, and
|
||||
`Parser::err` contains a human readable error string with a line number
|
||||
etc, which you should present to the creator of that file.
|
||||
@@ -254,9 +274,18 @@ file, that you can access as described above.
|
||||
|
||||
`samples/sample_text.cpp` is a code sample showing the above operations.
|
||||
|
||||
### Threading
|
||||
## Threading
|
||||
|
||||
None of the code is thread-safe, by design. That said, since currently a
|
||||
FlatBuffer is read-only and entirely `const`, reading by multiple threads
|
||||
is possible.
|
||||
Reading a FlatBuffer does not touch any memory outside the original buffer,
|
||||
and is entirely read-only (all const), so is safe to access from multiple
|
||||
threads even without synchronisation primitives.
|
||||
|
||||
Creating a FlatBuffer is not thread safe. All state related to building
|
||||
a FlatBuffer is contained in a FlatBufferBuilder instance, and no memory
|
||||
outside of it is touched. To make this thread safe, either do not
|
||||
share instances of FlatBufferBuilder between threads (recommended), or
|
||||
manually wrap it in synchronisation primites. There's no automatic way to
|
||||
accomplish this, by design, as we feel multithreaded construction
|
||||
of a single buffer will be rare, and synchronisation overhead would be costly.
|
||||
|
||||
<br>
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
# FlatBuffers
|
||||
FlatBuffers {#flatbuffers_index}
|
||||
===========
|
||||
|
||||
FlatBuffers is an efficient cross platform serialization library for C++,
|
||||
with support for Java and Go. It was created at Google specifically for game
|
||||
# Overview {#flatbuffers_overview}
|
||||
|
||||
[FlatBuffers](@ref flatbuffers_overview) is an efficient cross platform
|
||||
serialization library for C++, C#, Go, Java, JavaScript, PHP, and Python
|
||||
(C and Ruby in progress). It was originally created at Google for game
|
||||
development and other performance-critical applications.
|
||||
|
||||
It is available as open source under the Apache license, v2 (see LICENSE.txt).
|
||||
It is available as Open Source on [GitHub](http://github.com/google/flatbuffers)
|
||||
under the Apache license, v2 (see LICENSE.txt).
|
||||
|
||||
## Why use FlatBuffers?
|
||||
|
||||
@@ -15,8 +20,8 @@ It is available as open source under the Apache license, v2 (see LICENSE.txt).
|
||||
structure evolution (forwards/backwards compatibility).
|
||||
|
||||
- **Memory efficiency and speed** - The only memory needed to access
|
||||
your data is that of the buffer. It requires 0 additional allocations.
|
||||
FlatBuffers is also very
|
||||
your data is that of the buffer. It requires 0 additional allocations
|
||||
(in C++, other languages may vary). FlatBuffers is also very
|
||||
suitable for use with mmap (or streaming), requiring only part of the
|
||||
buffer to be in memory. Access is close to the speed of raw
|
||||
struct access with only one extra indirection (a kind of vtable) to
|
||||
@@ -24,7 +29,7 @@ It is available as open source under the Apache license, v2 (see LICENSE.txt).
|
||||
projects where spending time and space (many memory allocations) to
|
||||
be able to access or construct serialized data is undesirable, such
|
||||
as in games or any other performance sensitive applications. See the
|
||||
[benchmarks](md__benchmarks.html) for details.
|
||||
[benchmarks](@ref flatbuffers_benchmarks) for details.
|
||||
|
||||
- **Flexible** - Optional fields means not only do you get great
|
||||
forwards and backwards compatibility (increasingly important for
|
||||
@@ -46,10 +51,11 @@ It is available as open source under the Apache license, v2 (see LICENSE.txt).
|
||||
needed (faster and more memory efficient than other JSON
|
||||
parsers).
|
||||
|
||||
Java and Go code supports object-reuse.
|
||||
Java and Go code supports object-reuse. C# has efficient struct based
|
||||
accessors.
|
||||
|
||||
- **Cross platform C++11/Java/Go code with no dependencies** - will work with
|
||||
any recent gcc/clang and VS2010. Comes with build files for the tests &
|
||||
- **Cross platform code with no dependencies** - C++ code will work
|
||||
with any recent gcc/clang and VS2010. Comes with build files for the tests &
|
||||
samples (Android .mk files, and cmake for all other platforms).
|
||||
|
||||
### Why not use Protocol Buffers, or .. ?
|
||||
@@ -73,7 +79,18 @@ In this context, it is only a better choice for systems that have very
|
||||
little to no information ahead of time about what data needs to be stored.
|
||||
|
||||
Read more about the "why" of FlatBuffers in the
|
||||
[white paper](md__white_paper.html).
|
||||
[white paper](@ref flatbuffers_white_paper).
|
||||
|
||||
### Who uses FlatBuffers?
|
||||
- [Cocos2d-x](http://www.cocos2d-x.org/), the #1 open source mobile game
|
||||
engine, uses it to serialize all their
|
||||
[game data](http://www.cocos2d-x.org/reference/native-cpp/V3.5/d7/d2d/namespaceflatbuffers.html).
|
||||
- [Facebook](http://facebook.com/) uses it for client-server communication in
|
||||
their Android app. They have a nice
|
||||
[article](https://code.facebook.com/posts/872547912839369/improving-facebook-s-performance-on-android-with-flatbuffers/)
|
||||
explaining how it speeds up loading their posts.
|
||||
- [Fun Propulsion Labs](https://developers.google.com/games/#Tools)
|
||||
at Google uses it extensively in all their libraries and games.
|
||||
|
||||
## Usage in brief
|
||||
|
||||
@@ -87,10 +104,10 @@ sections provide a more in-depth usage guide.
|
||||
Fields are optional and have defaults, so they don't need to be
|
||||
present for every object instance.
|
||||
|
||||
- Use `flatc` (the FlatBuffer compiler) to generate a C++ header (or Java/Go
|
||||
classes) with helper classes to access and construct serialized data. This
|
||||
header (say `mydata_generated.h`) only depends on `flatbuffers.h`, which
|
||||
defines the core functionality.
|
||||
- Use `flatc` (the FlatBuffer compiler) to generate a C++ header (or
|
||||
Java/C#/Go/Python.. classes) with helper classes to access and construct
|
||||
serialized data. This header (say `mydata_generated.h`) only depends on
|
||||
`flatbuffers.h`, which defines the core functionality.
|
||||
|
||||
- Use the `FlatBufferBuilder` class to construct a flat binary buffer.
|
||||
The generated functions allow you to add objects to this
|
||||
@@ -104,25 +121,41 @@ sections provide a more in-depth usage guide.
|
||||
|
||||
## In-depth documentation
|
||||
|
||||
- How to [build the compiler](md__building.html) and samples on various
|
||||
platforms.
|
||||
- How to [use the compiler](md__compiler.html).
|
||||
- How to [write a schema](md__schemas.html).
|
||||
- How to [use the generated C++ code](md__cpp_usage.html) in your own
|
||||
programs.
|
||||
- How to [use the generated Java code](md__java_usage.html) in your own
|
||||
programs.
|
||||
- How to [use the generated Go code](md__go_usage.html) in your own
|
||||
programs.
|
||||
- Some [benchmarks](md__benchmarks.html) showing the advantage of using
|
||||
- How to [build the compiler](@ref flatbuffers_guide_building) and samples on
|
||||
various platforms.
|
||||
- How to [use the compiler](@ref flatbuffers_guide_using_schema_compiler).
|
||||
- How to [write a schema](@ref flatbuffers_guide_writing_schema).
|
||||
- How to [use the generated C++ code](@ref flatbuffers_guide_use_cpp) in your
|
||||
own programs.
|
||||
- How to [use the generated Java/C# code](@ref flatbuffers_guide_use_java_c-sharp)
|
||||
in your own programs.
|
||||
- How to [use the generated Go code](@ref flatbuffers_guide_use_go) in your
|
||||
own programs.
|
||||
- [Support matrix](@ref flatbuffers_support) for platforms/languages/features.
|
||||
- Some [benchmarks](@ref flatbuffers_benchmarks) showing the advantage of
|
||||
using FlatBuffers.
|
||||
- A [white paper](@ref flatbuffers_white_paper) explaining the "why" of
|
||||
FlatBuffers.
|
||||
- A [white paper](md__white_paper.html) explaining the "why" of FlatBuffers.
|
||||
- A description of the [internals](md__internals.html) of FlatBuffers.
|
||||
- A formal [grammar](md__grammar.html) of the schema language.
|
||||
- A description of the [internals](@ref flatbuffers_internals) of FlatBuffers.
|
||||
- A formal [grammar](@ref flatbuffers_grammar) of the schema language.
|
||||
|
||||
## Online resources
|
||||
|
||||
- [github repository](http://github.com/google/flatbuffers)
|
||||
- [landing page](http://google.github.io/flatbuffers)
|
||||
- [GitHub repository](http://github.com/google/flatbuffers)
|
||||
- [Landing page](http://google.github.io/flatbuffers)
|
||||
- [FlatBuffers Google Group](http://group.google.com/group/flatbuffers)
|
||||
- [FlatBuffers Issues Tracker](http://github.com/google/flatbuffers/issues)
|
||||
- Independent implementations & tools:
|
||||
- [FlatCC](https://github.com/dvidelabs/flatcc) Alternative FlatBuffers
|
||||
parser, code generator and runtime all in C.
|
||||
- Videos:
|
||||
- Colt's [DevByte](https://www.youtube.com/watch?v=iQTxMkSJ1dQ).
|
||||
- GDC 2015 [Lightning Talk](https://www.youtube.com/watch?v=olmL1fUnQAQ).
|
||||
- FlatBuffers for [Go](https://www.youtube.com/watch?v=-BPVId_lA5w).
|
||||
- Evolution of FlatBuffers
|
||||
[visualization](https://www.youtube.com/watch?v=a0QE0xS8rKM).
|
||||
- Useful documentation created by others:
|
||||
- [FlatBuffers in Go](https://rwinslow.com/tags/flatbuffers/)
|
||||
- [FlatBuffers in Android](http://frogermcs.github.io/flatbuffers-in-android-introdution/)
|
||||
- [Parsing JSON to FlatBuffers in Java](http://frogermcs.github.io/json-parsing-with-flatbuffers-in-android/)
|
||||
- [FlatBuffers in Unity](http://exiin.com/blog/flatbuffers-for-unity-sample-code/)
|
||||
|
||||
26
docs/source/GoApi.md
Normal file
@@ -0,0 +1,26 @@
|
||||
Go API
|
||||
======
|
||||
|
||||
\addtogroup flatbuffers_go_api
|
||||
|
||||
<!-- Note: The `GoApi_generate.txt` code snippet was generated using `godoc` and
|
||||
customized for use with this markdown file. To regenerate the file, use the
|
||||
`godoc` tool (http://godoc.org) with the files in the `flatbuffers/go`
|
||||
folder.
|
||||
|
||||
You may need to ensure that copies of the files exist in the `src/`
|
||||
subfolder at the path set by the `$GOROOT` environment variable. You can
|
||||
either move the files to `$GOROOT/src/flatbuffers` manually, if `$GOROOT`
|
||||
is already set, otherwise you will need to manually set the `$GOROOT`
|
||||
variable to a path and create `src/flatbuffers` subfolders at that path.
|
||||
Then copy the flatbuffers files into `$GOROOT/src/flatbuffers`. (Some
|
||||
versions of `godoc` include a `-path` flag. This could be used instead, if
|
||||
available).
|
||||
|
||||
Once the files exist at the `$GOROOT/src/flatbuffers` location, you can
|
||||
regenerate this doc using the following command:
|
||||
`godoc flatbuffers > GoApi_generated.txt`.
|
||||
|
||||
After the documentation is generated, you will have to manually remove any
|
||||
non-user facing documentation from this file. -->
|
||||
\snippet GoApi_generated.txt Go API
|
||||
125
docs/source/GoApi_generated.txt
Normal file
@@ -0,0 +1,125 @@
|
||||
// This file was generated using `godoc` and customized for use with the
|
||||
// API Reference documentation. To recreate this file, use the `godoc` tool
|
||||
// (http://godoc.org) with the files in the `flatbuffers/go` folder.
|
||||
//
|
||||
// Note: You may need to ensure that copies of the files exist in the
|
||||
// `src/` subfolder at the path set by the `$GOROOT` environment variable.
|
||||
// You can either move the files to `$GOROOT/src/flatbuffers` manually, if
|
||||
// `$GOROOT` is already set, otherwise you will need to manually set the
|
||||
// `$GOROOT` variable to a path and create `src/flatbuffers` subfolders at that
|
||||
// path. Then copy these files into `$GOROOT/src/flatbuffers`. (Some versions of
|
||||
// `godoc` include a `-path` flag. This could be used instead, if available).
|
||||
//
|
||||
// Once the files exist at the `$GOROOT/src/flatbuffers` location, you can
|
||||
// regenerate this doc using the following command:
|
||||
// `godoc flatbuffers > GoApi_generated.txt`.
|
||||
//
|
||||
// After the documentation is generated, you will have to manually remove any
|
||||
// non-user facing documentation from this file.
|
||||
|
||||
/// [Go API]
|
||||
PACKAGE DOCUMENTATION
|
||||
|
||||
package flatbuffers
|
||||
Package flatbuffers provides facilities to read and write flatbuffers
|
||||
objects.
|
||||
|
||||
TYPES
|
||||
|
||||
type Builder struct {
|
||||
// `Bytes` gives raw access to the buffer. Most users will want to use
|
||||
// FinishedBytes() instead.
|
||||
Bytes []byte
|
||||
}
|
||||
Builder is a state machine for creating FlatBuffer objects. Use a
|
||||
Builder to construct object(s) starting from leaf nodes.
|
||||
|
||||
A Builder constructs byte buffers in a last-first manner for simplicity
|
||||
and performance.
|
||||
|
||||
FUNCTIONS
|
||||
|
||||
func NewBuilder(initialSize int) *Builder
|
||||
NewBuilder initializes a Builder of size `initial_size`. The internal
|
||||
buffer is grown as needed.
|
||||
|
||||
func (b *Builder) CreateByteString(s []byte) UOffsetT
|
||||
CreateByteString writes a byte slice as a string (null-terminated).
|
||||
|
||||
func (b *Builder) CreateByteVector(v []byte) UOffsetT
|
||||
CreateByteVector writes a ubyte vector
|
||||
|
||||
func (b *Builder) CreateString(s string) UOffsetT
|
||||
CreateString writes a null-terminated string as a vector.
|
||||
|
||||
func (b *Builder) EndVector(vectorNumElems int) UOffsetT
|
||||
EndVector writes data necessary to finish vector construction.
|
||||
|
||||
func (b *Builder) Finish(rootTable UOffsetT)
|
||||
Finish finalizes a buffer, pointing to the given `rootTable`.
|
||||
|
||||
func (b *Builder) FinishedBytes() []byte
|
||||
FinishedBytes returns a pointer to the written data in the byte buffer.
|
||||
Panics if the builder is not in a finished state (which is caused by
|
||||
calling `Finish()`).
|
||||
|
||||
func (b *Builder) Head() UOffsetT
|
||||
Head gives the start of useful data in the underlying byte buffer. Note:
|
||||
unlike other functions, this value is interpreted as from the left.
|
||||
|
||||
func (b *Builder) PrependBool(x bool)
|
||||
PrependBool prepends a bool to the Builder buffer. Aligns and checks for
|
||||
space.
|
||||
|
||||
func (b *Builder) PrependByte(x byte)
|
||||
PrependByte prepends a byte to the Builder buffer. Aligns and checks for
|
||||
space.
|
||||
|
||||
func (b *Builder) PrependFloat32(x float32)
|
||||
PrependFloat32 prepends a float32 to the Builder buffer. Aligns and
|
||||
checks for space.
|
||||
|
||||
func (b *Builder) PrependFloat64(x float64)
|
||||
PrependFloat64 prepends a float64 to the Builder buffer. Aligns and
|
||||
checks for space.
|
||||
|
||||
func (b *Builder) PrependInt16(x int16)
|
||||
PrependInt16 prepends a int16 to the Builder buffer. Aligns and checks
|
||||
for space.
|
||||
|
||||
func (b *Builder) PrependInt32(x int32)
|
||||
PrependInt32 prepends a int32 to the Builder buffer. Aligns and checks
|
||||
for space.
|
||||
|
||||
func (b *Builder) PrependInt64(x int64)
|
||||
PrependInt64 prepends a int64 to the Builder buffer. Aligns and checks
|
||||
for space.
|
||||
|
||||
func (b *Builder) PrependInt8(x int8)
|
||||
PrependInt8 prepends a int8 to the Builder buffer. Aligns and checks for
|
||||
space.
|
||||
|
||||
func (b *Builder) PrependUOffsetT(off UOffsetT)
|
||||
PrependUOffsetT prepends an UOffsetT, relative to where it will be
|
||||
written.
|
||||
|
||||
func (b *Builder) PrependUint16(x uint16)
|
||||
PrependUint16 prepends a uint16 to the Builder buffer. Aligns and checks
|
||||
for space.
|
||||
|
||||
func (b *Builder) PrependUint32(x uint32)
|
||||
PrependUint32 prepends a uint32 to the Builder buffer. Aligns and checks
|
||||
for space.
|
||||
|
||||
func (b *Builder) PrependUint64(x uint64)
|
||||
PrependUint64 prepends a uint64 to the Builder buffer. Aligns and checks
|
||||
for space.
|
||||
|
||||
func (b *Builder) PrependUint8(x uint8)
|
||||
PrependUint8 prepends a uint8 to the Builder buffer. Aligns and checks
|
||||
for space.
|
||||
|
||||
func (b *Builder) Reset()
|
||||
Reset truncates the underlying Builder buffer, facilitating alloc-free
|
||||
reuse of a Builder. It also resets bookkeeping data.
|
||||
/// [Go API]
|
||||
125
docs/source/GoUsage.md
Executable file → Normal file
@@ -1,12 +1,53 @@
|
||||
# Use in Go
|
||||
Use in Go {#flatbuffers_guide_use_go}
|
||||
=========
|
||||
|
||||
There's experimental support for reading FlatBuffers in Go. Generate code
|
||||
for Go with the `-g` option to `flatc`.
|
||||
## Before you get started
|
||||
|
||||
See `go_test.go` for an example. You import the generated code, read a
|
||||
FlatBuffer binary file into a `[]byte`, which you pass to the
|
||||
`GetRootAsMonster` function:
|
||||
Before diving into the FlatBuffers usage in Go, it should be noted that
|
||||
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide
|
||||
to general FlatBuffers usage in all of the supported languages (including Go).
|
||||
This page is designed to cover the nuances of FlatBuffers usage, specific to
|
||||
Go.
|
||||
|
||||
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||
documentation to build `flatc` and should be familiar with
|
||||
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||
|
||||
## FlatBuffers Go library code location
|
||||
|
||||
The code for the FlatBuffers Go library can be found at
|
||||
`flatbuffers/go`. You can browse the library code on the [FlatBuffers
|
||||
GitHub page](https://github.com/google/flatbuffers/tree/master/go).
|
||||
|
||||
## Testing the FlatBuffers Go library
|
||||
|
||||
The code to test the Go library can be found at `flatbuffers/tests`.
|
||||
The test code itself is located in [go_test.go](https://github.com/google/
|
||||
flatbuffers/blob/master/tests/go_test.go).
|
||||
|
||||
To run the tests, use the [GoTest.sh](https://github.com/google/flatbuffers/
|
||||
blob/master/tests/GoTest.sh) shell script.
|
||||
|
||||
*Note: The shell script requires [Go](https://golang.org/doc/install) to
|
||||
be installed.*
|
||||
|
||||
## Using the FlatBuffers Go library
|
||||
|
||||
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||
example of how to use FlatBuffers in Go.*
|
||||
|
||||
FlatBuffers supports reading and writing binary FlatBuffers in Go.
|
||||
|
||||
To use FlatBuffers in your own code, first generate Go classes from your
|
||||
schema with the `--go` option to `flatc`. Then you can include both FlatBuffers
|
||||
and the generated code to read or write a FlatBuffer.
|
||||
|
||||
For example, here is how you would read a FlatBuffer binary file in Go: First,
|
||||
include the library and generated code. Then read a FlatBuffer binary file into
|
||||
a `[]byte`, which you pass to the `GetRootAsMonster` function:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go}
|
||||
import (
|
||||
example "MyGame/Example"
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
@@ -17,81 +58,19 @@ FlatBuffer binary file into a `[]byte`, which you pass to the
|
||||
buf, err := ioutil.ReadFile("monster.dat")
|
||||
// handle err
|
||||
monster := example.GetRootAsMonster(buf, 0)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Now you can access values like this:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go}
|
||||
hp := monster.Hp()
|
||||
pos := monster.Pos(nil)
|
||||
|
||||
Note that whenever you access a new object like in the `Pos` example above,
|
||||
a new temporary accessor object gets created. If your code is very performance
|
||||
sensitive (you iterate through a lot of objects), you can replace nil with a
|
||||
pointer to a `Vec3` object you've already created. This allows
|
||||
you to reuse it across many calls and reduce the amount of object allocation
|
||||
(and thus garbage collection) your program does.
|
||||
|
||||
To access vectors you pass an extra index to the
|
||||
vector field accessor. Then a second method with the same name suffixed
|
||||
by `Length` let's you know the number of elements you can access:
|
||||
|
||||
for i := 0; i < monster.InventoryLength(); i++ {
|
||||
monster.Inventory(i) // do something here
|
||||
}
|
||||
|
||||
You can also construct these buffers in Go using the functions found in the
|
||||
generated code, and the FlatBufferBuilder class:
|
||||
|
||||
builder := flatbuffers.NewBuilder(0)
|
||||
|
||||
Create strings:
|
||||
|
||||
str := builder.CreateString("MyMonster")
|
||||
|
||||
Create a table with a struct contained therein:
|
||||
|
||||
example.MonsterStart(builder)
|
||||
example.MonsterAddPos(builder, example.CreateVec3(builder, 1.0, 2.0, 3.0, 3.0, 4, 5, 6))
|
||||
example.MonsterAddHp(builder, 80)
|
||||
example.MonsterAddName(builder, str)
|
||||
example.MonsterAddInventory(builder, inv)
|
||||
example.MonsterAddTest_Type(builder, 1)
|
||||
example.MonsterAddTest(builder, mon2)
|
||||
example.MonsterAddTest4(builder, test4s)
|
||||
mon := example.MonsterEnd(builder)
|
||||
|
||||
Unlike C++, Go does not support table creation functions like 'createMonster()'.
|
||||
This is to create the buffer without
|
||||
using temporary object allocation (since the `Vec3` is an inline component of
|
||||
`Monster`, it has to be created right where it is added, whereas the name and
|
||||
the inventory are not inline).
|
||||
Structs do have convenient methods that allow you to construct them in one call.
|
||||
These also have arguments for nested structs, e.g. if a struct has a field `a`
|
||||
and a nested struct field `b` (which has fields `c` and `d`), then the arguments
|
||||
will be `a`, `c` and `d`.
|
||||
|
||||
Vectors also use this start/end pattern to allow vectors of both scalar types
|
||||
and structs:
|
||||
|
||||
example.MonsterStartInventoryVector(builder, 5)
|
||||
for i := 4; i >= 0; i-- {
|
||||
builder.PrependByte(byte(i))
|
||||
}
|
||||
inv := builder.EndVector(5)
|
||||
|
||||
The generated method 'StartInventoryVector' is provided as a convenience
|
||||
function which calls 'StartVector' with the correct element size of the vector
|
||||
type which in this case is 'ubyte' or 1 byte per vector element.
|
||||
You pass the number of elements you want to write.
|
||||
You write the elements backwards since the buffer
|
||||
is being constructed back to front.
|
||||
|
||||
There are `Prepend` functions for all the scalar types. You use
|
||||
`PrependUOffset` for any previously constructed objects (such as other tables,
|
||||
strings, vectors). For structs, you use the appropriate `create` function
|
||||
in-line, as shown above in the `Monster` example.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
## Text Parsing
|
||||
|
||||
There currently is no support for parsing text (Schema's and JSON) directly
|
||||
from Go, though you could use the C++ parser through cgo. Please see the
|
||||
C++ documentation for more on text parsing.
|
||||
|
||||
<br>
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
# Formal Grammar of the schema language
|
||||
Grammar of the schema language {#flatbuffers_grammar}
|
||||
==============================
|
||||
|
||||
schema = namespace\_decl | type\_decl | enum\_decl | root\_decl | object
|
||||
schema = include*
|
||||
( namespace\_decl | type\_decl | enum\_decl | root\_decl |
|
||||
file_extension_decl | file_identifier_decl |
|
||||
attribute\_decl | object )*
|
||||
|
||||
include = `include` string\_constant `;`
|
||||
|
||||
namespace\_decl = `namespace` ident ( `.` ident )* `;`
|
||||
|
||||
attribute\_decl = `attribute` string\_constant `;`
|
||||
|
||||
type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
|
||||
|
||||
enum\_decl = ( `enum` | `union` ) ident [ `:` type ] metadata `{` commasep(
|
||||
@@ -11,7 +19,7 @@ enumval\_decl ) `}`
|
||||
|
||||
root\_decl = `root_type` ident `;`
|
||||
|
||||
field\_decl = type `:` ident [ `=` scalar ] metadata `;`
|
||||
field\_decl = ident `:` type [ `=` scalar ] metadata `;`
|
||||
|
||||
type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
|
||||
`float` | `long` | `ulong` | `double`
|
||||
@@ -19,12 +27,22 @@ type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
|
||||
|
||||
enumval\_decl = ident [ `=` integer\_constant ]
|
||||
|
||||
metadata = [ `(` commasep( ident [ `:` scalar ] ) `)` ]
|
||||
metadata = [ `(` commasep( ident [ `:` single\_value ] ) `)` ]
|
||||
|
||||
scalar = integer\_constant | float\_constant | `true` | `false`
|
||||
scalar = integer\_constant | float\_constant
|
||||
|
||||
object = { commasep( ident `:` value ) }
|
||||
|
||||
value = scalar | object | string\_constant | `[` commasep( value ) `]`
|
||||
single\_value = scalar | string\_constant
|
||||
|
||||
value = single\_value | object | `[` commasep( value ) `]`
|
||||
|
||||
commasep(x) = [ x ( `,` x )\* ]
|
||||
|
||||
file_extension_decl = `file_extension` string\_constant `;`
|
||||
|
||||
file_identifier_decl = `file_identifier` string\_constant `;`
|
||||
|
||||
integer\_constant = -?[0-9]+ | `true` | `false`
|
||||
|
||||
float\_constant = -?[0-9]+.[0-9]+((e|E)(+|-)?[0-9]+)?
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# FlatBuffer Internals
|
||||
FlatBuffer Internals {#flatbuffers_internals}
|
||||
====================
|
||||
|
||||
This section is entirely optional for the use of FlatBuffers. In normal
|
||||
usage, you should never need the information contained herein. If you're
|
||||
@@ -16,7 +17,7 @@ byte-swap intrinsics.
|
||||
|
||||
On purpose, the format leaves a lot of details about where exactly
|
||||
things live in memory undefined, e.g. fields in a table can have any
|
||||
order, and objects to some extend can be stored in many orders. This is
|
||||
order, and objects to some extent can be stored in many orders. This is
|
||||
because the format doesn't need this information to be efficient, and it
|
||||
leaves room for optimization and extension (for example, fields can be
|
||||
packed in a way that is most compact). Instead, the format is defined in
|
||||
@@ -73,8 +74,13 @@ code.
|
||||
|
||||
### Tables
|
||||
|
||||
These start with an `soffset_t` to a vtable (signed version of
|
||||
`uoffset_t`, since vtables may be stored anywhere), followed by all the
|
||||
Unlike structs, these are not stored in inline in their parent, but are
|
||||
referred to by offset.
|
||||
|
||||
They start with an `soffset_t` to a vtable. This is a signed version of
|
||||
`uoffset_t`, since vtables may be stored anywhere relative to the object.
|
||||
This offset is substracted (not added) from the object start to arrive at
|
||||
the vtable start. This offset is followed by all the
|
||||
fields as aligned scalars (or offsets). Unlike structs, not all fields
|
||||
need to be present. There is no set order and layout.
|
||||
|
||||
@@ -83,10 +89,10 @@ through a vtable of offsets. Vtables are shared between any objects that
|
||||
happen to have the same vtable values.
|
||||
|
||||
The elements of a vtable are all of type `voffset_t`, which is
|
||||
a `uint16_t`. The first element is the number of elements of the vtable,
|
||||
including this one. The second one is the size of the object, in bytes
|
||||
(including the vtable offset). This size is used for streaming, to know
|
||||
how many bytes to read to be able to access all fields of the object.
|
||||
a `uint16_t`. The first element is the size of the vtable in bytes,
|
||||
including the size element. The second one is the size of the object, in bytes
|
||||
(including the vtable offset). This size could be used for streaming, to know
|
||||
how many bytes to read to be able to access all *inline* fields of the object.
|
||||
The remaining elements are the N offsets, where N is the amount of fields
|
||||
declared in the schema when the code that constructed this buffer was
|
||||
compiled (thus, the size of the table is N + 2).
|
||||
@@ -104,7 +110,8 @@ field to be read.
|
||||
Strings are simply a vector of bytes, and are always
|
||||
null-terminated. Vectors are stored as contiguous aligned scalar
|
||||
elements prefixed by a 32bit element count (not including any
|
||||
null termination).
|
||||
null termination). Neither is stored inline in their parent, but are referred to
|
||||
by offset.
|
||||
|
||||
### Construction
|
||||
|
||||
@@ -159,7 +166,8 @@ Unions share a lot with enums.
|
||||
struct Vec3;
|
||||
struct Monster;
|
||||
|
||||
Predeclare all datatypes since there may be circular references.
|
||||
Predeclare all data types since circular references between types are allowed
|
||||
(circular references between object are not, though).
|
||||
|
||||
MANUALLY_ALIGNED_STRUCT(4) Vec3 {
|
||||
private:
|
||||
@@ -221,7 +229,12 @@ Otherwise, it uses the entry as an offset into the table to locate the field.
|
||||
`FlatBufferBuilder`. You can add the fields in any order, and the `Finish`
|
||||
call will ensure the correct vtable gets generated.
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const Vec3 *pos, int16_t mana, int16_t hp, flatbuffers::Offset<flatbuffers::String> name, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory, int8_t color) {
|
||||
inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const Vec3 *pos, int16_t mana,
|
||||
int16_t hp,
|
||||
flatbuffers::Offset<flatbuffers::String> name,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory,
|
||||
int8_t color) {
|
||||
MonsterBuilder builder_(_fbb);
|
||||
builder_.add_inventory(inventory);
|
||||
builder_.add_name(name);
|
||||
@@ -246,4 +259,37 @@ start traversing a FlatBuffer from a raw buffer pointer.
|
||||
}; // namespace MyGame
|
||||
}; // namespace Sample
|
||||
|
||||
### Encoding example.
|
||||
|
||||
Below is a sample encoding for the following JSON corresponding to the above
|
||||
schema:
|
||||
|
||||
{ pos: { x: 1, y: 2, z: 3 }, name: "fred", hp: 50 }
|
||||
|
||||
Resulting in this binary buffer:
|
||||
|
||||
// Start of the buffer:
|
||||
uint32_t 20 // Offset to the root table.
|
||||
|
||||
// Start of the vtable. Not shared in this example, but could be:
|
||||
uint16_t 16 // Size of table, starting from here.
|
||||
uint16_t 22 // Size of object inline data.
|
||||
uint16_t 4, 0, 20, 16, 0, 0 // Offsets to fields from start of (root) table, 0 for not present.
|
||||
|
||||
// Start of the root table:
|
||||
int32_t 16 // Offset to vtable used (default negative direction)
|
||||
float 1, 2, 3 // the Vec3 struct, inline.
|
||||
uint32_t 8 // Offset to the name string.
|
||||
int16_t 50 // hp field.
|
||||
int16_t 0 // Padding for alignment.
|
||||
|
||||
// Start of name string:
|
||||
uint32_t 4 // Length of string.
|
||||
int8_t 'f', 'r', 'e', 'd', 0, 0, 0, 0 // Text + 0 termination + padding.
|
||||
|
||||
Note that this not the only possible encoding, since the writer has some
|
||||
flexibility in which of the children of root object to write first (though in
|
||||
this case there's only one string), and what order to write the fields in.
|
||||
Different orders may also cause different alignments to happen.
|
||||
|
||||
<br>
|
||||
|
||||
141
docs/source/JavaCsharpUsage.md
Executable file
@@ -0,0 +1,141 @@
|
||||
Use in Java/C# {#flatbuffers_guide_use_java_c-sharp}
|
||||
==============
|
||||
|
||||
## Before you get started
|
||||
|
||||
Before diving into the FlatBuffers usage in Java or C#, it should be noted that
|
||||
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to
|
||||
general FlatBuffers usage in all of the supported languages (including both Java
|
||||
and C#). This page is designed to cover the nuances of FlatBuffers usage,
|
||||
specific to Java and C#.
|
||||
|
||||
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||
documentation to build `flatc` and should be familiar with
|
||||
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||
|
||||
## FlatBuffers Java and C-sharp code location
|
||||
|
||||
#### Java
|
||||
|
||||
The code for the FlatBuffers Java library can be found at
|
||||
`flatbuffers/java/com/google/flatbuffers`. You can browse the library on the
|
||||
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/
|
||||
java/com/google/flatbuffers).
|
||||
|
||||
#### C-sharp
|
||||
|
||||
The code for the FlatBuffers C# library can be found at
|
||||
`flatbuffers/net/FlatBuffers`. You can browse the library on the
|
||||
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/net/
|
||||
FlatBuffers).
|
||||
|
||||
## Testing the FlatBuffers Java and C-sharp libraries
|
||||
|
||||
The code to test the libraries can be found at `flatbuffers/tests`.
|
||||
|
||||
#### Java
|
||||
|
||||
The test code for Java is located in [JavaTest.java](https://github.com/google
|
||||
/flatbuffers/blob/master/tests/JavaTest.java).
|
||||
|
||||
To run the tests, use either [JavaTest.sh](https://github.com/google/
|
||||
flatbuffers/blob/master/tests/JavaTest.sh) or [JavaTest.bat](https://github.com/
|
||||
google/flatbuffers/blob/master/tests/JavaTest.bat), depending on your operating
|
||||
system.
|
||||
|
||||
*Note: These scripts require that [Java](https://www.oracle.com/java/index.html)
|
||||
is installed.*
|
||||
|
||||
#### C-sharp
|
||||
|
||||
The test code for C# is located in the [FlatBuffers.Test](https://github.com/
|
||||
google/flatbuffers/tree/master/tests/FlatBuffers.Test) subfolder. To run the
|
||||
tests, open `FlatBuffers.Test.csproj` in [Visual Studio](
|
||||
https://www.visualstudio.com), and compile/run the project.
|
||||
|
||||
Optionally, you can run this using [Mono](http://www.mono-project.com/) instead.
|
||||
Once you have installed `Mono`, you can run the tests from the command line
|
||||
by running the following commands from inside the `FlatBuffers.Test` folder:
|
||||
|
||||
~~~{.sh}
|
||||
mcs *.cs ../MyGame/Example/*.cs ../../net/FlatBuffers/*.cs
|
||||
mono Assert.exe
|
||||
~~~
|
||||
|
||||
## Using the FlatBuffers Java (and C#) library
|
||||
|
||||
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||
example of how to use FlatBuffers in Java or C#.*
|
||||
|
||||
FlatBuffers supports reading and writing binary FlatBuffers in Java and C#.
|
||||
|
||||
To use FlatBuffers in your own code, first generate Java classes from your
|
||||
schema with the `--java` option to `flatc`. (Or for C# with `--csharp`).
|
||||
Then you can include both FlatBuffers and the generated code to read
|
||||
or write a FlatBuffer.
|
||||
|
||||
For example, here is how you would read a FlatBuffer binary file in Java:
|
||||
First, import the library and generated code. Then, you read a FlatBuffer binary
|
||||
file into a `byte[]`. You then turn the `byte[]` into a `ByteBuffer`, which you
|
||||
pass to the `getRootAsMyRootType` function:
|
||||
|
||||
*Note: The code here is written from the perspective of Java. Code for both
|
||||
languages is both generated and used in nearly the exact same way, with only
|
||||
minor differences. These differences are
|
||||
[explained in a section below](#differences_in_c-sharp).*
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.java}
|
||||
import MyGame.Example.*;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
|
||||
// This snippet ignores exceptions for brevity.
|
||||
File file = new File("monsterdata_test.mon");
|
||||
RandomAccessFile f = new RandomAccessFile(file, "r");
|
||||
byte[] data = new byte[(int)f.length()];
|
||||
f.readFully(data);
|
||||
f.close();
|
||||
|
||||
ByteBuffer bb = ByteBuffer.wrap(data);
|
||||
Monster monster = Monster.getRootAsMonster(bb);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Now you can access the data from the `Monster monster`:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.java}
|
||||
short hp = monster.hp();
|
||||
Vec3 pos = monster.pos();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
<a name="differences_in_c-sharp">
|
||||
#### Differences in C-sharp
|
||||
</a>
|
||||
|
||||
C# code works almost identically to Java, with only a few minor differences.
|
||||
You can see an example of C# code in
|
||||
`tests/FlatBuffers.Test/FlatBuffersExampleTests.cs` or
|
||||
`samples/SampleBinary.cs`.
|
||||
|
||||
First of all, naming follows standard C# style with `PascalCasing` identifiers,
|
||||
e.g. `GetRootAsMyRootType`. Also, values (except vectors and unions) are
|
||||
available as properties instead of parameterless accessor methods as in Java.
|
||||
The performance-enhancing methods to which you can pass an already created
|
||||
object are prefixed with `Get`, e.g.:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
|
||||
// property
|
||||
var pos = monster.Pos;
|
||||
|
||||
// method filling a preconstructed object
|
||||
var preconstructedPos = new Vec3();
|
||||
monster.GetPos(preconstructedPos);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
## Text parsing
|
||||
|
||||
There currently is no support for parsing text (Schema's and JSON) directly
|
||||
from Java or C#, though you could use the C++ parser through native call
|
||||
interfaces available to each language. Please see the
|
||||
C++ documentation for more on text parsing.
|
||||
|
||||
<br>
|
||||
105
docs/source/JavaScriptUsage.md
Executable file
@@ -0,0 +1,105 @@
|
||||
Use in JavaScript {#flatbuffers_guide_use_javascript}
|
||||
=================
|
||||
|
||||
## Before you get started
|
||||
|
||||
Before diving into the FlatBuffers usage in JavaScript, it should be noted that
|
||||
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to
|
||||
general FlatBuffers usage in all of the supported languages
|
||||
(including JavaScript). This page is specifically designed to cover the nuances
|
||||
of FlatBuffers usage in JavaScript.
|
||||
|
||||
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||
documentation to build `flatc` and should be familiar with
|
||||
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||
|
||||
## FlatBuffers JavaScript library code location
|
||||
|
||||
The code for the FlatBuffers JavaScript library can be found at
|
||||
`flatbuffers/js`. You can browse the library code on the [FlatBuffers
|
||||
GitHub page](https://github.com/google/flatbuffers/tree/master/js).
|
||||
|
||||
## Testing the FlatBuffers JavaScript library
|
||||
|
||||
The code to test the JavaScript library can be found at `flatbuffers/tests`.
|
||||
The test code itself is located in [JavaScriptTest.js](https://github.com/
|
||||
google/flatbuffers/blob/master/tests/JavaScriptTest.js).
|
||||
|
||||
To run the tests, use the [JavaScriptTest.sh](https://github.com/google/
|
||||
flatbuffers/blob/master/tests/JavaScriptTest.sh) shell script.
|
||||
|
||||
*Note: The JavaScript test file requires [Node.js](https://nodejs.org/en/).*
|
||||
|
||||
## Using the FlatBuffers JavaScript libary
|
||||
|
||||
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||
example of how to use FlatBuffers in JavaScript.*
|
||||
|
||||
FlatBuffers supports both reading and writing FlatBuffers in JavaScript.
|
||||
|
||||
To use FlatBuffers in your own code, first generate JavaScript classes from your
|
||||
schema with the `--js` option to `flatc`. Then you can include both FlatBuffers
|
||||
and the generated code to read or write a FlatBuffer.
|
||||
|
||||
For example, here is how you would read a FlatBuffer binary file in Javascript:
|
||||
First, include the library and generated code. Then read the file into an
|
||||
`Uint8Array`. Make a `flatbuffers.ByteBuffer` out of the `Uint8Array`, and pass
|
||||
the ByteBuffer to the `getRootAsMonster` function.
|
||||
|
||||
*Note: Both JavaScript module loaders (e.g. Node.js) and browser-based
|
||||
HTML/JavaScript code segments are shown below in the following snippet:*
|
||||
|
||||
~~~{.js}
|
||||
// Note: These require functions are specific to JavaScript module loaders
|
||||
// (namely, Node.js). See below for a browser-based example.
|
||||
var fs = require('fs');
|
||||
|
||||
var flatbuffers = require('../flatbuffers').flatbuffers;
|
||||
var MyGame = require('./monster_generated').MyGame;
|
||||
|
||||
var data = new Uint8Array(fs.readFileSync('monster.dat'));
|
||||
var buf = new flatbuffers.ByteBuffer(data);
|
||||
|
||||
var monster = MyGame.Example.Monster.getRootAsMonster(buf);
|
||||
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
// Note: This code is specific to browser-based HTML/JavaScript. See above
|
||||
// for the code using JavaScript module loaders (e.g. Node.js).
|
||||
<script src="../js/flatbuffers.js"></script>
|
||||
<script src="monster_generated.js"></script>
|
||||
<script>
|
||||
function readFile() {
|
||||
var reader = new FileReader(); // This example uses the HTML5 FileReader.
|
||||
var file = document.getElementById(
|
||||
'file_input').files[0]; // "monster.dat" from the HTML <input> field.
|
||||
|
||||
reader.onload = function() { // Executes after the file is read.
|
||||
var data = new Uint8Array(reader.result);
|
||||
|
||||
var buf = new flatbuffers.ByteBuffer(data);
|
||||
|
||||
var monster = MyGame.Example.Monster.getRootAsMonster(buf);
|
||||
}
|
||||
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
</script>
|
||||
|
||||
// Open the HTML file in a browser and select "monster.dat" from with the
|
||||
// <input> field.
|
||||
<input type="file" id="file_input" onchange="readFile();">
|
||||
~~~
|
||||
|
||||
Now you can access values like this:
|
||||
|
||||
~~~{.js}
|
||||
var hp = monster.hp();
|
||||
var pos = monster.pos();
|
||||
~~~
|
||||
|
||||
## Text parsing FlatBuffers in JavaScript
|
||||
|
||||
There currently is no support for parsing text (Schema's and JSON) directly
|
||||
from JavaScript.
|
||||
@@ -1,98 +0,0 @@
|
||||
# Use in Java
|
||||
|
||||
FlatBuffers supports reading and writing binary FlatBuffers in Java. Generate code
|
||||
for Java with the `-j` option to `flatc`.
|
||||
|
||||
See `javaTest.java` for an example. Essentially, you read a FlatBuffer binary
|
||||
file into a `byte[]`, which you then turn into a `ByteBuffer`, which you pass to
|
||||
the `getRootAsMyRootType` function:
|
||||
|
||||
ByteBuffer bb = ByteBuffer.wrap(data);
|
||||
Monster monster = Monster.getRootAsMonster(bb);
|
||||
|
||||
Now you can access values much like C++:
|
||||
|
||||
short hp = monster.hp();
|
||||
Vec3 pos = monster.pos();
|
||||
|
||||
Note that whenever you access a new object like in the `pos` example above,
|
||||
a new temporary accessor object gets created. If your code is very performance
|
||||
sensitive (you iterate through a lot of objects), there's a second `pos()`
|
||||
method to which you can pass a `Vec3` object you've already created. This allows
|
||||
you to reuse it across many calls and reduce the amount of object allocation (and
|
||||
thus garbage collection) your program does.
|
||||
|
||||
Java does not support unsigned scalars. This means that any unsigned types you
|
||||
use in your schema will actually be represented as a signed value. This means
|
||||
all bits are still present, but may represent a negative value when used.
|
||||
For example, to read a `byte b` as an unsigned number, you can do:
|
||||
`(short)(b & 0xFF)`
|
||||
|
||||
Sadly the string accessors currently always create a new string when accessed,
|
||||
since FlatBuffer's UTF-8 strings can't be read in-place by Java.
|
||||
|
||||
Vector access is also a bit different from C++: you pass an extra index
|
||||
to the vector field accessor. Then a second method with the same name
|
||||
suffixed by `Length` let's you know the number of elements you can access:
|
||||
|
||||
for (int i = 0; i < monster.inventoryLength(); i++)
|
||||
monster.inventory(i); // do something here
|
||||
|
||||
You can also construct these buffers in Java using the static methods found
|
||||
in the generated code, and the FlatBufferBuilder class:
|
||||
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder();
|
||||
|
||||
Create strings:
|
||||
|
||||
int str = fbb.createString("MyMonster");
|
||||
|
||||
Create a table with a struct contained therein:
|
||||
|
||||
Monster.startMonster(fbb);
|
||||
Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0, (byte)4, (short)5, (byte)6));
|
||||
Monster.addHp(fbb, (short)80);
|
||||
Monster.addName(fbb, str);
|
||||
Monster.addInventory(fbb, inv);
|
||||
Monster.addTest_type(fbb, (byte)1);
|
||||
Monster.addTest(fbb, mon2);
|
||||
Monster.addTest4(fbb, test4s);
|
||||
int mon = Monster.endMonster(fbb);
|
||||
|
||||
As you can see, the Java code for tables does not use a convenient
|
||||
`createMonster` call like the C++ code. This is to create the buffer without
|
||||
using temporary object allocation.
|
||||
|
||||
It's important to understand that fields that are structs are inline (like
|
||||
`Vec3` above), and MUST thus be created between the start and end calls of
|
||||
a table. Everything else (other tables, strings, vectors) MUST be created
|
||||
before the start of the table they are referenced in.
|
||||
|
||||
Structs do have convenient methods that even have arguments for nested structs.
|
||||
|
||||
As you can see, references to other objects (e.g. the string above) are simple
|
||||
ints, and thus do not have the type-safety of the Offset type in C++. Extra
|
||||
case must thus be taken that you set the right offset on the right field.
|
||||
|
||||
Vectors also use this start/end pattern to allow vectors of both scalar types
|
||||
and structs:
|
||||
|
||||
Monster.startInventoryVector(fbb, 5);
|
||||
for (byte i = 4; i >=0; i--) fbb.addByte(i);
|
||||
int inv = fbb.endVector();
|
||||
|
||||
You can use the generated method `startInventoryVector` to conveniently call
|
||||
`startVector` with the right element size. You pass the number of
|
||||
elements you want to write. You write the elements backwards since the buffer
|
||||
is being constructed back to front.
|
||||
|
||||
There are `add` functions for all the scalar types. You use `addOffset` for
|
||||
any previously constructed objects (such as other tables, strings, vectors).
|
||||
For structs, you use the appropriate `create` function in-line, as shown
|
||||
above in the `Monster` example.
|
||||
|
||||
## Text Parsing
|
||||
|
||||
There currently is no support for parsing text (Schema's and JSON) directly
|
||||
from Java, though you could use the C++ parser through JNI. Please see the
|
||||
C++ documentation for more on text parsing.
|
||||
89
docs/source/PHPUsage.md
Normal file
@@ -0,0 +1,89 @@
|
||||
Use in PHP {#flatbuffers_guide_use_php}
|
||||
==========
|
||||
|
||||
## Before you get started
|
||||
|
||||
Before diving into the FlatBuffers usage in PHP, it should be noted that
|
||||
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to
|
||||
general FlatBuffers usage in all of the supported languages
|
||||
(including PHP). This page is specifically designed to cover the nuances of
|
||||
FlatBuffers usage in PHP.
|
||||
|
||||
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||
documentation to build `flatc` and should be familiar with
|
||||
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||
|
||||
## FlatBuffers PHP library code location
|
||||
|
||||
The code for FlatBuffers PHP library can be found at `flatbuffers/php`. You
|
||||
can browse the library code on the [FlatBuffers
|
||||
GitHub page](https://github.com/google/flatbuffers/tree/master/php).
|
||||
|
||||
## Testing the FlatBuffers JavaScript library
|
||||
|
||||
The code to test the PHP library can be found at `flatbuffers/tests`.
|
||||
The test code itself is located in [phpTest.php](https://github.com/google/
|
||||
flatbuffers/blob/master/tests/phpTest.php).
|
||||
|
||||
You can run the test with `php phpTest.php` from the command line.
|
||||
|
||||
*Note: The PHP test file requires
|
||||
[PHP](http://php.net/manual/en/install.php) to be installed.*
|
||||
|
||||
## Using theFlatBuffers PHP library
|
||||
|
||||
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||
example of how to use FlatBuffers in PHP.*
|
||||
|
||||
FlatBuffers supports both reading and writing FlatBuffers in PHP.
|
||||
|
||||
To use FlatBuffers in your own code, first generate PHP classes from your schema
|
||||
with the `--php` option to `flatc`. Then you can include both FlatBuffers and
|
||||
the generated code to read or write a FlatBuffer.
|
||||
|
||||
For example, here is how you would read a FlatBuffer binary file in PHP:
|
||||
First, include the library and generated code (using the PSR `autoload`
|
||||
function). Then you can read a FlatBuffer binary file, which you
|
||||
pass the contents of to the `GetRootAsMonster` function:
|
||||
|
||||
~~~{.php}
|
||||
// It is recommended that your use PSR autoload when using FlatBuffers in PHP.
|
||||
// Here is an example:
|
||||
function __autoload($class_name) {
|
||||
// The last segment of the class name matches the file name.
|
||||
$class = substr($class_name, strrpos($class_name, "\\") + 1);
|
||||
$root_dir = join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)))); // `flatbuffers` root.
|
||||
|
||||
// Contains the `*.php` files for the FlatBuffers library and the `flatc` generated files.
|
||||
$paths = array(join(DIRECTORY_SEPARATOR, array($root_dir, "php")),
|
||||
join(DIRECTORY_SEPARATOR, array($root_dir, "tests", "MyGame", "Example")));
|
||||
foreach ($paths as $path) {
|
||||
$file = join(DIRECTORY_SEPARATOR, array($path, $class . ".php"));
|
||||
if (file_exists($file)) {
|
||||
require($file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Read the contents of the FlatBuffer binary file.
|
||||
$filename = "monster.dat";
|
||||
$handle = fopen($filename, "rb");
|
||||
$contents = $fread($handle, filesize($filename));
|
||||
fclose($handle);
|
||||
|
||||
// Pass the contents to `GetRootAsMonster`.
|
||||
$monster = \MyGame\Example\Monster::GetRootAsMonster($contents);
|
||||
~~~
|
||||
|
||||
Now you can access values like this:
|
||||
|
||||
~~~{.php}
|
||||
$hp = $monster->GetHp();
|
||||
$pos = $monster->GetPos();
|
||||
~~~
|
||||
|
||||
## Text Parsing
|
||||
|
||||
There currently is no support for parsing text (Schema's and JSON) directly
|
||||
from PHP.
|
||||
73
docs/source/PythonUsage.md
Executable file
@@ -0,0 +1,73 @@
|
||||
Use in Python {#flatbuffers_guide_use_python}
|
||||
=============
|
||||
|
||||
## Before you get started
|
||||
|
||||
Before diving into the FlatBuffers usage in Python, it should be noted that the
|
||||
[Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to general
|
||||
FlatBuffers usage in all of the supported languages (including Python). This
|
||||
page is designed to cover the nuances of FlatBuffers usage, specific to
|
||||
Python.
|
||||
|
||||
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||
documentation to build `flatc` and should be familiar with
|
||||
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||
|
||||
## FlatBuffers Python library code location
|
||||
|
||||
The code for the FlatBuffers Python library can be found at
|
||||
`flatbuffers/python/flatbuffers`. You can browse the library code on the
|
||||
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/
|
||||
python).
|
||||
|
||||
## Testing the FlatBuffers Python library
|
||||
|
||||
The code to test the Python library can be found at `flatbuffers/tests`.
|
||||
The test code itself is located in [py_test.py](https://github.com/google/
|
||||
flatbuffers/blob/master/tests/py_test.py).
|
||||
|
||||
To run the tests, use the [PythonTest.sh](https://github.com/google/flatbuffers/
|
||||
blob/master/tests/PythonTest.sh) shell script.
|
||||
|
||||
*Note: This script requires [python](https://www.python.org/) to be
|
||||
installed.*
|
||||
|
||||
## Using the FlatBuffers Python library
|
||||
|
||||
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||
example of how to use FlatBuffers in Python.*
|
||||
|
||||
There is support for both reading and writing FlatBuffers in Python.
|
||||
|
||||
To use FlatBuffers in your own code, first generate Python classes from your
|
||||
schema with the `--python` option to `flatc`. Then you can include both
|
||||
FlatBuffers and the generated code to read or write a FlatBuffer.
|
||||
|
||||
For example, here is how you would read a FlatBuffer binary file in Python:
|
||||
First, import the library and the generated code. Then read a FlatBuffer binary
|
||||
file into a `bytearray`, which you pass to the `GetRootAsMonster` function:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py}
|
||||
import MyGame.Example as example
|
||||
import flatbuffers
|
||||
|
||||
buf = open('monster.dat', 'rb').read()
|
||||
buf = bytearray(buf)
|
||||
monster = example.GetRootAsMonster(buf, 0)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Now you can access values like this:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py}
|
||||
hp = monster.Hp()
|
||||
pos = monster.Pos()
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
## Text Parsing
|
||||
|
||||
There currently is no support for parsing text (Schema's and JSON) directly
|
||||
from Python, though you could use the C++ parser through SWIG or ctypes. Please
|
||||
see the C++ documentation for more on text parsing.
|
||||
|
||||
<br>
|
||||
32
docs/source/README_TO_GENERATE_DOCS.md
Normal file
@@ -0,0 +1,32 @@
|
||||
## Prerequisites
|
||||
|
||||
To generate the docs for FlatBuffers from the source files, you
|
||||
will first need to install two programs.
|
||||
|
||||
1. You will need to install `doxygen`. See
|
||||
[Download Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html).
|
||||
|
||||
2. You will need to install `doxypypy` to format python comments appropriately.
|
||||
Install it from [here](https://github.com/Feneric/doxypypy).
|
||||
|
||||
*Note: You will need both `doxygen` and `doxypypy` to be in your
|
||||
[PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable.*
|
||||
|
||||
After you have both of those files installed and in your path, you need to
|
||||
set up the `py_filter` to invoke `doxypypy` from `doxygen`.
|
||||
|
||||
Follow the steps
|
||||
[here](https://github.com/Feneric/doxypypy#invoking-doxypypy-from-doxygen).
|
||||
|
||||
## Generating Docs
|
||||
|
||||
Run the following commands to generate the docs:
|
||||
|
||||
`cd flatbuffers/docs/source`
|
||||
`doxygen`
|
||||
|
||||
The output is placed in `flatbuffers/docs/html`.
|
||||
|
||||
*Note: The Go API Reference code must be generated ahead of time. For
|
||||
instructions on how to regenerated this file, please read the comments
|
||||
in `GoApi.md`.*
|
||||
@@ -1,7 +1,8 @@
|
||||
# Writing a schema
|
||||
Writing a schema {#flatbuffers_guide_writing_schema}
|
||||
================
|
||||
|
||||
The syntax of the schema language (aka IDL, Interface Definition
|
||||
Language) should look quite familiar to users of any of the C family of
|
||||
The syntax of the schema language (aka IDL, [Interface Definition Language][])
|
||||
should look quite familiar to users of any of the C family of
|
||||
languages, and also to users of other IDLs. Let's look at an example
|
||||
first:
|
||||
|
||||
@@ -9,6 +10,8 @@ first:
|
||||
|
||||
namespace MyGame;
|
||||
|
||||
attribute "priority";
|
||||
|
||||
enum Color : byte { Red = 1, Green, Blue }
|
||||
|
||||
union Any { Monster, Weapon, Pickup }
|
||||
@@ -32,14 +35,14 @@ first:
|
||||
|
||||
root_type Monster;
|
||||
|
||||
(Weapon & Pickup not defined as part of this example).
|
||||
(`Weapon` & `Pickup` not defined as part of this example).
|
||||
|
||||
### Tables
|
||||
|
||||
Tables are the main way of defining objects in FlatBuffers, and consist
|
||||
of a name (here `Monster`) and a list of fields. Each field has a name,
|
||||
a type, and optionally a default value (if omitted, it defaults to 0 /
|
||||
NULL).
|
||||
a type, and optionally a default value (if omitted, it defaults to `0` /
|
||||
`NULL`).
|
||||
|
||||
Each field is optional: It does not have to appear in the wire
|
||||
representation, and you can choose to omit fields for each individual
|
||||
@@ -66,7 +69,8 @@ and backwards compatibility. Note that:
|
||||
- You may change field names and table names, if you're ok with your
|
||||
code breaking until you've renamed them there too.
|
||||
|
||||
|
||||
See "Schema evolution examples" below for more on this
|
||||
topic.
|
||||
|
||||
### Structs
|
||||
|
||||
@@ -80,15 +84,17 @@ parent object, and use no virtual table).
|
||||
|
||||
### Types
|
||||
|
||||
Builtin scalar types are:
|
||||
Built-in scalar types are:
|
||||
|
||||
- 8 bit: `byte ubyte bool`
|
||||
- 8 bit: `byte`, `ubyte`, `bool`
|
||||
|
||||
- 16 bit: `short ushort`
|
||||
- 16 bit: `short`, `ushort`
|
||||
|
||||
- 32 bit: `int uint float`
|
||||
- 32 bit: `int`, `uint`, `float`
|
||||
|
||||
- 64 bit: `long ulong double`
|
||||
- 64 bit: `long`, `ulong`, `double`
|
||||
|
||||
Built-in non-scalar types:
|
||||
|
||||
- Vector of any other type (denoted with `[type]`). Nesting vectors
|
||||
is not supported, instead you can wrap the inner vector in a table.
|
||||
@@ -106,15 +112,19 @@ high bit yet.
|
||||
|
||||
### (Default) Values
|
||||
|
||||
Values are a sequence of digits, optionally followed by a `.` and more digits
|
||||
for float constants, and optionally prefixed by a `-`. Non-scalar defaults are
|
||||
currently not supported (always NULL).
|
||||
Values are a sequence of digits. Values may be optionally followed by a decimal
|
||||
point (`.`) and more digits, for float constants, or optionally prefixed by
|
||||
a `-`. Floats may also be in scientific notation; optionally ending with an `e`
|
||||
or `E`, followed by a `+` or `-` and more digits.
|
||||
|
||||
Only scalar values can have defaults, non-scalar (string/vector/table) fields
|
||||
default to `NULL` when not present.
|
||||
|
||||
You generally do not want to change default values after they're initially
|
||||
defined. Fields that have the default value are not actually stored in the
|
||||
serialized data but are generated in code, so when you change the default, you'd
|
||||
now get a different value than from code generated from an older version of
|
||||
the schema. There are situations however where this may be
|
||||
the schema. There are situations, however, where this may be
|
||||
desirable, especially if you can ensure a simultaneous rebuild of
|
||||
all code.
|
||||
|
||||
@@ -126,25 +136,51 @@ is `0`. As you can see in the enum declaration, you specify the underlying
|
||||
integral type of the enum with `:` (in this case `byte`), which then determines
|
||||
the type of any fields declared with this enum type.
|
||||
|
||||
Typically, enum values should only ever be added, never removed (there is no
|
||||
deprecation for enums). This requires code to handle forwards compatibility
|
||||
itself, by handling unknown enum values.
|
||||
|
||||
### Unions
|
||||
|
||||
Unions share a lot of properties with enums, but instead of new names
|
||||
for constants, you use names of tables. You can then declare
|
||||
a union field which can hold a reference to any of those types, and
|
||||
a union field, which can hold a reference to any of those types, and
|
||||
additionally a hidden field with the suffix `_type` is generated that
|
||||
holds the corresponding enum value, allowing you to know which type to
|
||||
cast to at runtime.
|
||||
|
||||
Unions are a good way to be able to send multiple message types as a FlatBuffer.
|
||||
Note that because a union field is really two fields, it must always be
|
||||
part of a table, it cannot be the root of a FlatBuffer by itself.
|
||||
|
||||
If you have a need to distinguish between different FlatBuffers in a more
|
||||
open-ended way, for example for use as files, see the file identification
|
||||
feature below.
|
||||
|
||||
### Namespaces
|
||||
|
||||
These will generate the corresponding namespace in C++ for all helper
|
||||
code, and packages in Java. You can use `.` to specify nested namespaces /
|
||||
packages.
|
||||
|
||||
### Includes
|
||||
|
||||
You can include other schemas files in your current one, e.g.:
|
||||
|
||||
include "mydefinitions.fbs";
|
||||
|
||||
This makes it easier to refer to types defined elsewhere. `include`
|
||||
automatically ensures each file is parsed just once, even when referred to
|
||||
more than once.
|
||||
|
||||
When using the `flatc` compiler to generate code for schema definitions,
|
||||
only definitions in the current file will be generated, not those from the
|
||||
included files (those you still generate separately).
|
||||
|
||||
### Root type
|
||||
|
||||
This declares what you consider to be the root table (or struct) of the
|
||||
serialized data. This is particular important for parsing JSON data,
|
||||
serialized data. This is particularly important for parsing JSON data,
|
||||
which doesn't include object type information.
|
||||
|
||||
### File identification and extension
|
||||
@@ -179,6 +215,10 @@ without one, you can always still do so by calling
|
||||
After loading a buffer, you can use a call like
|
||||
`MonsterBufferHasIdentifier` to check if the identifier is present.
|
||||
|
||||
Note that this is best for open-ended uses such as files. If you simply wanted
|
||||
to send one of a set of possible messages over a network for example, you'd
|
||||
be better off with a union.
|
||||
|
||||
Additionally, by default `flatc` will output binary files as `.bin`.
|
||||
This declaration in the schema will change that to whatever you want:
|
||||
|
||||
@@ -196,9 +236,10 @@ in the corresponding C++ code. Multiple such lines per item are allowed.
|
||||
|
||||
Attributes may be attached to a declaration, behind a field, or after
|
||||
the name of a table/struct/enum/union. These may either have a value or
|
||||
not. Some attributes like `deprecated` are understood by the compiler,
|
||||
others are simply ignored (like `priority`), but are available to query
|
||||
if you parse the schema at runtime.
|
||||
not. Some attributes like `deprecated` are understood by the compiler;
|
||||
user defined ones need to be declared with the attribute declaration
|
||||
(like `priority` in the example above), and are
|
||||
available to query if you parse the schema at runtime.
|
||||
This is useful if you write your own code generators/editors etc., and
|
||||
you wish to add additional information specific to your tool (such as a
|
||||
help text).
|
||||
@@ -218,6 +259,16 @@ Current understood attributes:
|
||||
When a new field is added to the schema is must use the next available ID.
|
||||
- `deprecated` (on a field): do not generate accessors for this field
|
||||
anymore, code should stop using this data.
|
||||
- `required` (on a non-scalar table field): this field must always be set.
|
||||
By default, all fields are optional, i.e. may be left out. This is
|
||||
desirable, as it helps with forwards/backwards compatibility, and
|
||||
flexibility of data structures. It is also a burden on the reading code,
|
||||
since for non-scalar fields it requires you to check against NULL and
|
||||
take appropriate action. By specifying this field, you force code that
|
||||
constructs FlatBuffers to ensure this field is initialized, so the reading
|
||||
code may access it directly, without checking for NULL. If the constructing
|
||||
code does not initialize this field, they will get an assert, and also
|
||||
the verifier will fail on buffers that have missing required fields.
|
||||
- `original_order` (on a table): since elements in a table do not need
|
||||
to be stored in any particular order, they are often optimized for
|
||||
space by sorting them to size. This attribute stops that from happening.
|
||||
@@ -230,6 +281,13 @@ Current understood attributes:
|
||||
meaning that any value N specified in the schema will end up
|
||||
representing 1<<N, or if you don't specify values at all, you'll get
|
||||
the sequence 1, 2, 4, 8, ...
|
||||
- `nested_flatbuffer: "table_name"` (on a field): this indicates that the field
|
||||
(which must be a vector of ubyte) contains flatbuffer data, for which the
|
||||
root type is given by `table_name`. The generated code will then produce
|
||||
a convenient accessor for the nested FlatBuffer.
|
||||
- `key` (on a field): this field is meant to be used as a key when sorting
|
||||
a vector of the type of table it sits in. Can be used for in-place
|
||||
binary search.
|
||||
|
||||
## JSON Parsing
|
||||
|
||||
@@ -253,6 +311,33 @@ JSON:
|
||||
representing flags, you may place multiple inside a string
|
||||
separated by spaces to OR them, e.g.
|
||||
`field: "EnumVal1 EnumVal2"` or `field: "Enum.EnumVal1 Enum.EnumVal2"`.
|
||||
- Similarly, for unions, these need to specified with two fields much like
|
||||
you do when serializing from code. E.g. for a field `foo`, you must
|
||||
add a field `foo_type: FooOne` right before the `foo` field, where
|
||||
`FooOne` would be the table out of the union you want to use.
|
||||
- A field that has the value `null` (e.g. `field: null`) is intended to
|
||||
have the default value for that field (thus has the same effect as if
|
||||
that field wasn't specified at all).
|
||||
|
||||
When parsing JSON, it recognizes the following escape codes in strings:
|
||||
|
||||
- `\n` - linefeed.
|
||||
- `\t` - tab.
|
||||
- `\r` - carriage return.
|
||||
- `\b` - backspace.
|
||||
- `\f` - form feed.
|
||||
- `\"` - double quote.
|
||||
- `\\` - backslash.
|
||||
- `\/` - forward slash.
|
||||
- `\uXXXX` - 16-bit unicode code point, converted to the equivalent UTF-8
|
||||
representation.
|
||||
- `\xXX` - 8-bit binary hexadecimal number XX. This is the only one that is
|
||||
not in the JSON spec (see http://json.org/), but is needed to be able to
|
||||
encode arbitrary binary in strings to text and back without losing
|
||||
information (e.g. the byte 0xFF can't be represented in standard JSON).
|
||||
|
||||
It also generates these escape codes back again when generating JSON from a
|
||||
binary representation.
|
||||
|
||||
## Gotchas
|
||||
|
||||
@@ -276,3 +361,68 @@ the world. If this is not practical for you, use explicit field ids, which
|
||||
should always generate a merge conflict if two people try to allocate the same
|
||||
id.
|
||||
|
||||
### Schema evolution examples
|
||||
|
||||
Some examples to clarify what happens as you change a schema:
|
||||
|
||||
If we have the following original schema:
|
||||
|
||||
table { a:int; b:int; }
|
||||
|
||||
And we extend it:
|
||||
|
||||
table { a:int; b:int; c:int; }
|
||||
|
||||
This is ok. Code compiled with the old schema reading data generated with the
|
||||
new one will simply ignore the presence of the new field. Code compiled with the
|
||||
new schema reading old data will get the default value for `c` (which is 0
|
||||
in this case, since it is not specified).
|
||||
|
||||
table { a:int (deprecated); b:int; }
|
||||
|
||||
This is also ok. Code compiled with the old schema reading newer data will now
|
||||
always get the default value for `a` since it is not present. Code compiled
|
||||
with the new schema now cannot read nor write `a` anymore (any existing code
|
||||
that tries to do so will result in compile errors), but can still read
|
||||
old data (they will ignore the field).
|
||||
|
||||
table { c:int a:int; b:int; }
|
||||
|
||||
This is NOT ok, as this makes the schemas incompatible. Old code reading newer
|
||||
data will interpret `c` as if it was `a`, and new code reading old data
|
||||
accessing `a` will instead receive `b`.
|
||||
|
||||
table { c:int (id: 2); a:int (id: 0); b:int (id: 1); }
|
||||
|
||||
This is ok. If your intent was to order/group fields in a way that makes sense
|
||||
semantically, you can do so using explicit id assignment. Now we are compatible
|
||||
with the original schema, and the fields can be ordered in any way, as long as
|
||||
we keep the sequence of ids.
|
||||
|
||||
table { b:int; }
|
||||
|
||||
NOT ok. We can only remove a field by deprecation, regardless of wether we use
|
||||
explicit ids or not.
|
||||
|
||||
table { a:uint; b:uint; }
|
||||
|
||||
This is MAYBE ok, and only in the case where the type change is the same size,
|
||||
like here. If old data never contained any negative numbers, this will be
|
||||
safe to do.
|
||||
|
||||
table { a:int = 1; b:int = 2; }
|
||||
|
||||
Generally NOT ok. Any older data written that had 0 values were not written to
|
||||
the buffer, and rely on the default value to be recreated. These will now have
|
||||
those values appear to `1` and `2` instead. There may be cases in which this
|
||||
is ok, but care must be taken.
|
||||
|
||||
table { aa:int; bb:int; }
|
||||
|
||||
Occasionally ok. You've renamed fields, which will break all code (and JSON
|
||||
files!) that use this schema, but as long as the change is obvious, this is not
|
||||
incompatible with the actual binary buffers, since those only ever address
|
||||
fields by id/offset.
|
||||
<br>
|
||||
|
||||
[Interface Definition Language]: https://en.wikipedia.org/wiki/Interface_description_language
|
||||
|
||||
44
docs/source/Support.md
Executable file
@@ -0,0 +1,44 @@
|
||||
Platform / Language / Feature support {#flatbuffers_support}
|
||||
=====================================
|
||||
|
||||
FlatBuffers is actively being worked on, which means that certain platform /
|
||||
language / feature combinations may not be available yet.
|
||||
|
||||
This page tries to track those issues, to make informed decisions easier.
|
||||
In general:
|
||||
|
||||
* Languages: language support beyond the ones created by the original
|
||||
FlatBuffer authors typically depends on community contributions.
|
||||
* Features: C++ was the first language supported, since our original
|
||||
target was high performance game development. It thus has the richest
|
||||
feature set, and is likely most robust. Other languages are catching up
|
||||
however.
|
||||
* Platforms: All language implementations are typically portable to most
|
||||
platforms, unless where noted otherwise.
|
||||
|
||||
NOTE: this table is a start, it needs to be extended.
|
||||
|
||||
Feature | C++ | Java | C# | Go | Python | JS | C | PHP | Ruby
|
||||
------------------------------ | ------ | ------ | ------ | ------ | ------ | --------- | ---- | --- | ----
|
||||
Codegen for all basic features | Yes | Yes | Yes | Yes | Yes | Yes | WiP | WiP | WiP
|
||||
JSON parsing | Yes | No | No | No | No | No | No | No | No
|
||||
Simple mutation | Yes | WIP | WIP | No | No | No | No | No | No
|
||||
Reflection | Yes | No | No | No | No | No | No | No | No
|
||||
Buffer verifier | Yes | No | No | No | No | No | No | No | No
|
||||
Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | ?
|
||||
Testing: fuzz | Yes | No | No | Yes | Yes | No | ? | ? | ?
|
||||
Performance: | Superb | Great | Great | Great | Ok | ? |Superb| ? | ?
|
||||
Platform: Windows | VS2010 | Yes | Yes | ? | ? | ? | ? | ? | ?
|
||||
Platform: Linux | GCC282 | Yes | ? | Yes | Yes | ? | ? | ? | ?
|
||||
Platform: OS X | Xcode4 | ? | ? | ? | Yes | ? | ? | ? | ?
|
||||
Platform: Android | NDK10d | Yes | ? | ? | ? | ? | ? | ? | ?
|
||||
Platform: iOS | ? | ? | ? | ? | ? | ? | ? | ? | ?
|
||||
Engine: Unity | ? | ? | Yes | ? | ? | ? | ? | ? | ?
|
||||
Primary authors (github) | gwvo | gwvo | ev*/js*| rw | rw | evanw/ev* | mik* | ch* | rw
|
||||
|
||||
* ev = evolutional
|
||||
* js = jonsimantov
|
||||
* mik = mikkelfj
|
||||
* ch = chobie
|
||||
|
||||
<br>
|
||||
1720
docs/source/Tutorial.md
Normal file
@@ -1,4 +1,5 @@
|
||||
# FlatBuffers white paper
|
||||
FlatBuffers white paper {#flatbuffers_white_paper}
|
||||
=======================
|
||||
|
||||
This document tries to shed some light on to the "why" of FlatBuffers, a
|
||||
new serialization library.
|
||||
@@ -124,4 +125,4 @@ offered by .proto files in the following ways:
|
||||
- A parser that can deal with both schemas and data definitions (JSON
|
||||
compatible) uniformly.
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
@@ -88,7 +88,7 @@ OUTPUT_LANGUAGE = English
|
||||
# documentation (similar to Javadoc). Set to NO to disable this.
|
||||
# The default value is: YES.
|
||||
|
||||
BRIEF_MEMBER_DESC = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
|
||||
# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief
|
||||
# description of a member or function before the detailed description
|
||||
@@ -97,7 +97,7 @@ BRIEF_MEMBER_DESC = NO
|
||||
# brief descriptions will be completely suppressed.
|
||||
# The default value is: YES.
|
||||
|
||||
REPEAT_BRIEF = NO
|
||||
REPEAT_BRIEF = YES
|
||||
|
||||
# This tag implements a quasi-intelligent brief description abbreviator that is
|
||||
# used to form the text in various listings. Each string in this list, if found
|
||||
@@ -177,7 +177,7 @@ SHORT_NAMES = NO
|
||||
# description.)
|
||||
# The default value is: NO.
|
||||
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
|
||||
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
|
||||
# line (until the first dot) of a Qt-style comment as the brief description. If
|
||||
@@ -203,7 +203,7 @@ MULTILINE_CPP_IS_BRIEF = NO
|
||||
# documentation from any documented member that it re-implements.
|
||||
# The default value is: YES.
|
||||
|
||||
INHERIT_DOCS = NO
|
||||
INHERIT_DOCS = YES
|
||||
|
||||
# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a
|
||||
# new page for each member. If set to NO, the documentation of a member will be
|
||||
@@ -216,7 +216,7 @@ SEPARATE_MEMBER_PAGES = NO
|
||||
# uses this value to replace tabs by spaces in code fragments.
|
||||
# Minimum value: 1, maximum value: 16, default value: 4.
|
||||
|
||||
TAB_SIZE = 1
|
||||
TAB_SIZE = 2
|
||||
|
||||
# This tag can be used to specify a number of aliases that act as commands in
|
||||
# the documentation. An alias has the form:
|
||||
@@ -296,7 +296,9 @@ MARKDOWN_SUPPORT = YES
|
||||
# or globally by setting AUTOLINK_SUPPORT to NO.
|
||||
# The default value is: YES.
|
||||
|
||||
AUTOLINK_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = NO # Due to the multiple languages included in the API
|
||||
# reference for FlatBuffers, the Auto-links were
|
||||
# wrong more often than not.
|
||||
|
||||
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
|
||||
# to include (a tag file for) the STL sources as input, then you should set this
|
||||
@@ -347,7 +349,7 @@ DISTRIBUTE_GROUP_DOC = NO
|
||||
# \nosubgrouping command.
|
||||
# The default value is: YES.
|
||||
|
||||
SUBGROUPING = NO
|
||||
SUBGROUPING = YES
|
||||
|
||||
# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
|
||||
# are shown inside the group in which they are included (e.g. using \ingroup)
|
||||
@@ -424,7 +426,7 @@ EXTRACT_PACKAGE = NO
|
||||
# included in the documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_STATIC = YES
|
||||
|
||||
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined
|
||||
# locally in source files will be included in the documentation. If set to NO
|
||||
@@ -508,7 +510,7 @@ HIDE_SCOPE_NAMES = NO
|
||||
# the files that are included by a file in the documentation of that file.
|
||||
# The default value is: YES.
|
||||
|
||||
SHOW_INCLUDE_FILES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
|
||||
# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
|
||||
# files with double quotes in the documentation rather than with sharp brackets.
|
||||
@@ -520,21 +522,21 @@ FORCE_LOCAL_INCLUDES = NO
|
||||
# documentation for inline members.
|
||||
# The default value is: YES.
|
||||
|
||||
INLINE_INFO = NO
|
||||
INLINE_INFO = YES
|
||||
|
||||
# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
|
||||
# (detailed) documentation of file and class members alphabetically by member
|
||||
# name. If set to NO the members will appear in declaration order.
|
||||
# The default value is: YES.
|
||||
|
||||
SORT_MEMBER_DOCS = NO
|
||||
SORT_MEMBER_DOCS = YES
|
||||
|
||||
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
|
||||
# descriptions of file, namespace and class members alphabetically by member
|
||||
# name. If set to NO the members will appear in declaration order.
|
||||
# The default value is: NO.
|
||||
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BRIEF_DOCS = YES
|
||||
|
||||
# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
|
||||
# (brief and detailed) documentation of class members so that constructors and
|
||||
@@ -600,7 +602,7 @@ GENERATE_BUGLIST = NO
|
||||
# the documentation.
|
||||
# The default value is: YES.
|
||||
|
||||
GENERATE_DEPRECATEDLIST= NO
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
|
||||
# The ENABLED_SECTIONS tag can be used to enable conditional documentation
|
||||
# sections, marked by \if <section_label> ... \endif and \cond <section_label>
|
||||
@@ -624,21 +626,21 @@ MAX_INITIALIZER_LINES = 30
|
||||
# will mention the files that were used to generate the documentation.
|
||||
# The default value is: YES.
|
||||
|
||||
SHOW_USED_FILES = NO
|
||||
SHOW_USED_FILES = YES
|
||||
|
||||
# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
|
||||
# will remove the Files entry from the Quick Index and from the Folder Tree View
|
||||
# (if specified).
|
||||
# The default value is: YES.
|
||||
|
||||
SHOW_FILES = NO
|
||||
SHOW_FILES = YES
|
||||
|
||||
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
|
||||
# page. This will remove the Namespaces entry from the Quick Index and from the
|
||||
# Folder Tree View (if specified).
|
||||
# The default value is: YES.
|
||||
|
||||
SHOW_NAMESPACES = NO
|
||||
SHOW_NAMESPACES = YES
|
||||
|
||||
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
|
||||
# doxygen should invoke to get the current version for each file (typically from
|
||||
@@ -661,7 +663,7 @@ FILE_VERSION_FILTER =
|
||||
# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
|
||||
# tag is left empty.
|
||||
|
||||
LAYOUT_FILE =
|
||||
LAYOUT_FILE = doxygen_layout.xml
|
||||
|
||||
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
|
||||
# the reference definitions. This must be a list of .bib files. The .bib
|
||||
@@ -692,14 +694,14 @@ QUIET = NO
|
||||
# Tip: Turn warnings on while writing the documentation.
|
||||
# The default value is: YES.
|
||||
|
||||
WARNINGS = NO
|
||||
WARNINGS = YES
|
||||
|
||||
# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate
|
||||
# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
|
||||
# will automatically be disabled.
|
||||
# The default value is: YES.
|
||||
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
|
||||
# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
|
||||
# potential errors in the documentation, such as not documenting some parameters
|
||||
@@ -749,11 +751,26 @@ INPUT = "FlatBuffers.md" \
|
||||
"Schemas.md" \
|
||||
"CppUsage.md" \
|
||||
"GoUsage.md" \
|
||||
"JavaUsage.md" \
|
||||
"JavaCsharpUsage.md" \
|
||||
"JavaScriptUsage.md" \
|
||||
"PHPUsage.md" \
|
||||
"PythonUsage.md" \
|
||||
"Support.md" \
|
||||
"Benchmarks.md" \
|
||||
"WhitePaper.md" \
|
||||
"Internals.md" \
|
||||
"Grammar.md"
|
||||
"Grammar.md" \
|
||||
"CONTRIBUTING.md" \
|
||||
"Tutorial.md" \
|
||||
"GoApi.md" \
|
||||
"groups" \
|
||||
"../../java/com/google/flatbuffers" \
|
||||
"../../python/flatbuffers/builder.py" \
|
||||
"../../js/flatbuffers.js" \
|
||||
"../../php/FlatbufferBuilder.php" \
|
||||
"../../net/FlatBuffers/FlatBufferBuilder.cs" \
|
||||
"../../include/flatbuffers/flatbuffers.h" \
|
||||
"../../go/builder.go"
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@@ -814,13 +831,14 @@ FILE_PATTERNS = *.c \
|
||||
*.ucf \
|
||||
*.qsf \
|
||||
*.as \
|
||||
*.js
|
||||
*.js \
|
||||
*.go
|
||||
|
||||
# The RECURSIVE tag can be used to specify whether or not subdirectories should
|
||||
# be searched for input files as well.
|
||||
# The default value is: NO.
|
||||
|
||||
RECURSIVE = NO
|
||||
RECURSIVE = YES
|
||||
|
||||
# The EXCLUDE tag can be used to specify files and/or directories that should be
|
||||
# excluded from the INPUT source files. This way you can easily exclude a
|
||||
@@ -845,7 +863,8 @@ EXCLUDE_SYMLINKS = NO
|
||||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_PATTERNS = *_test.py |
|
||||
__init__.py
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||
@@ -862,7 +881,7 @@ EXCLUDE_SYMBOLS =
|
||||
# that contain example code fragments that are included (see the \include
|
||||
# command).
|
||||
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATH = "GoApi_generated.txt"
|
||||
|
||||
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
|
||||
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
|
||||
@@ -908,7 +927,7 @@ INPUT_FILTER =
|
||||
# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
|
||||
# patterns match the file name, INPUT_FILTER is applied.
|
||||
|
||||
FILTER_PATTERNS =
|
||||
FILTER_PATTERNS = *.py=py_filter
|
||||
|
||||
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
|
||||
# INPUT_FILTER ) will also be used to filter the input files that are used for
|
||||
@@ -976,7 +995,7 @@ REFERENCES_RELATION = NO
|
||||
# link to the documentation.
|
||||
# The default value is: YES.
|
||||
|
||||
REFERENCES_LINK_SOURCE = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
|
||||
# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
|
||||
# source code will show a tooltip with additional information such as prototype,
|
||||
@@ -1016,26 +1035,7 @@ USE_HTAGS = NO
|
||||
# See also: Section \class.
|
||||
# The default value is: YES.
|
||||
|
||||
VERBATIM_HEADERS = NO
|
||||
|
||||
# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the
|
||||
# clang parser (see: http://clang.llvm.org/) for more acurate parsing at the
|
||||
# cost of reduced performance. This can be particularly helpful with template
|
||||
# rich C++ code for which doxygen's built-in parser lacks the necessary type
|
||||
# information.
|
||||
# Note: The availability of this option depends on whether or not doxygen was
|
||||
# compiled with the --with-libclang option.
|
||||
# The default value is: NO.
|
||||
|
||||
CLANG_ASSISTED_PARSING = NO
|
||||
|
||||
# If clang assisted parsing is enabled you can provide the compiler with command
|
||||
# line options that you would normally use when invoking the compiler. Note that
|
||||
# the include paths will already be set by doxygen for the files and directories
|
||||
# specified with INPUT and INCLUDE_PATH.
|
||||
# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
|
||||
|
||||
CLANG_OPTIONS =
|
||||
VERBATIM_HEADERS = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
@@ -1046,7 +1046,7 @@ CLANG_OPTIONS =
|
||||
# classes, structs, unions or interfaces.
|
||||
# The default value is: YES.
|
||||
|
||||
ALPHABETICAL_INDEX = NO
|
||||
ALPHABETICAL_INDEX = YES
|
||||
|
||||
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
|
||||
# which the alphabetical index list will be split.
|
||||
@@ -1105,7 +1105,7 @@ HTML_FILE_EXTENSION = .html
|
||||
# of the possible markers and block names see the documentation.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_HEADER =
|
||||
HTML_HEADER = ../header.html
|
||||
|
||||
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
|
||||
# generated HTML page. If the tag is left blank doxygen will generate a standard
|
||||
@@ -1138,7 +1138,7 @@ HTML_STYLESHEET =
|
||||
# see the documentation.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_EXTRA_STYLESHEET =
|
||||
HTML_EXTRA_STYLESHEET = style.css
|
||||
|
||||
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
||||
# other source files which should be copied to the HTML output directory. Note
|
||||
@@ -1148,7 +1148,9 @@ HTML_EXTRA_STYLESHEET =
|
||||
# files will be copied as-is; there are no commands or markers available.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_EXTRA_FILES =
|
||||
HTML_EXTRA_FILES = "../images/fpl_logo_small.png" \
|
||||
"../images/ftv2mnode.png" \
|
||||
"../images/ftv2pnode.png"
|
||||
|
||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||
# will adjust the colors in the stylesheet and background images according to
|
||||
@@ -1405,7 +1407,7 @@ ECLIPSE_DOC_ID = org.doxygen.Project
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
DISABLE_INDEX = YES
|
||||
DISABLE_INDEX = NO
|
||||
|
||||
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
|
||||
# structure should be generated to display hierarchical information. If the tag
|
||||
@@ -1536,7 +1538,7 @@ MATHJAX_CODEFILE =
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
SEARCHENGINE = NO
|
||||
SEARCHENGINE = YES
|
||||
|
||||
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
|
||||
# implemented using a web server instead of a web client using Javascript. There
|
||||
@@ -2069,7 +2071,7 @@ EXTERNAL_GROUPS = NO
|
||||
# be listed.
|
||||
# The default value is: YES.
|
||||
|
||||
EXTERNAL_PAGES = NO
|
||||
EXTERNAL_PAGES = YES
|
||||
|
||||
# The PERL_PATH should be the absolute path and name of the perl script
|
||||
# interpreter (i.e. the result of 'which perl').
|
||||
|
||||