diff options
102 files changed, 12647 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 00000000..176a458f --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100755 index 00000000..c6bcf20d --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +*_wire.txt +*_wire.bin +.DS_Store +*.o +*.o.d +*.class +*.a +*~ +*.vcxproj +*.vcxproj.filters +*.vcxproj.user +*.sln +*.suo +*.keystore +**/bin/** +**/gen/** +**/libs/** +**/obj/** +**/*.dir/** +**/CMakeFiles/** +**/cmake_install.cmake +**/CMakeCache.txt +**/Debug/** +**/Release/** +build.xml +local.properties +project.properties +proguard-project.txt +linklint_results +Makefile +flatc +flattests +flatsamplebinary +flatsampletext +snapshot.sh + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..2fa4160b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 2.8) + +project(FlatBuffers) + +# NOTE: Code coverage only works on Linux & OSX. +option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF) + +set(FlatBuffers_Compiler_SRCS + include/flatbuffers/flatbuffers.h + include/flatbuffers/idl.h + include/flatbuffers/util.h + src/idl_parser.cpp + src/idl_gen_cpp.cpp + src/idl_gen_java.cpp + src/idl_gen_text.cpp + src/flatc.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 + tests/test.cpp + # file generate by running compiler on tests/monster_test.fbs + 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 +) + +set(FlatBuffers_Sample_Text_SRCS + include/flatbuffers/flatbuffers.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 +) + +set(CMAKE_BUILD_TYPE Debug) + +# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS}) +# source_group(Tests FILES ${FlatBuffers_Tests_SRCS}) + +if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions("-std=c++0x") + add_definitions("-Wall") +endif() +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + add_definitions("-std=c++0x") +endif() + +if(FLATBUFFERS_CODE_COVERAGE) + add_definitions("-g -fprofile-arcs -ftest-coverage") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") +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}) + +add_test(NAME flattest + CONFIGURATIONS Debug + WORKING_DIRECTORY tests + COMMAND flattests) diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100755 index 00000000..d6456956 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/android/.project b/android/.project new file mode 100755 index 00000000..e7d5931b --- /dev/null +++ b/android/.project @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (c) 2014 Google, Inc. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + --> +<projectDescription> + <name>FlatBufferTest</name> +</projectDescription> diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml new file mode 100755 index 00000000..a15f547b --- /dev/null +++ b/android/AndroidManifest.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2013 Google, Inc. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + --> +<!-- BEGIN_INCLUDE(manifest) --> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.FlatBufferTest" + android:versionCode="1" + android:versionName="1.0"> + + <uses-feature android:glEsVersion="0x00020000"></uses-feature> + <!-- This is the platform API where NativeActivity was introduced. --> + <uses-sdk android:minSdkVersion="9" /> + + <!-- This .apk has no Java code itself, so set hasCode to false. --> + <application android:label="@string/app_name" android:hasCode="false"> + + <!-- Our activity is the built-in NativeActivity framework class. + This will take care of integrating with our NDK code. --> + <activity android:name="android.app.NativeActivity" + android:label="@string/app_name" + android:configChanges="orientation|keyboardHidden" + android:screenOrientation="landscape"> + <!-- Tell NativeActivity the name of or .so --> + <meta-data android:name="android.app.lib_name" + android:value="FlatBufferTest" /> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> +<!-- END_INCLUDE(manifest) --> diff --git a/android/build_apk.sh b/android/build_apk.sh new file mode 100755 index 00000000..3520626d --- /dev/null +++ b/android/build_apk.sh @@ -0,0 +1,500 @@ +#!/bin/bash -eu +# Copyright (c) 2013 Google, Inc. +# +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the authors be held liable for any damages +# arising from the use of this software. +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# 1. The origin of this software must not be misrepresented; you must not +# claim that you wrote the original software. If you use this software +# in a product, an acknowledgment in the product documentation would be +# appreciated but is not required. +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# 3. This notice may not be removed or altered from any source distribution. +# +# Build, deploy, debug / execute a native Android package based upon +# NativeActivity. + +declare -r script_directory=$(dirname $0) +declare -r android_root=${script_directory}/../../../../../../ +declare -r script_name=$(basename $0) +declare -r android_manifest=AndroidManifest.xml +declare -r os_name=$(uname -s) + +# Minimum Android target version supported by this project. +: ${BUILDAPK_ANDROID_TARGET_MINVERSION:=10} +# Directory containing the Android SDK +# (http://developer.android.com/sdk/index.html). +: ${ANDROID_SDK_HOME:=} +# Directory containing the Android NDK +# (http://developer.android.com/tools/sdk/ndk/index.html). +: ${NDK_HOME:=} + +# Display script help and exit. +usage() { + echo " +Build the Android package in the current directory and deploy it to a +connected device. + +Usage: ${script_name} \\ + [ADB_DEVICE=serial_number] [BUILD=0] [DEPLOY=0] [RUN_DEBUGGER=1] \ + [LAUNCH=0] [SWIG_BIN=swig_binary_directory] [SWIG_LIB=swig_include_directory] [ndk-build arguments ...] + +ADB_DEVICE=serial_number: + serial_number specifies the device to deploy the built apk to if multiple + Android devices are connected to the host. +BUILD=0: + Disables the build of the package. +DEPLOY=0: + Disables the deployment of the built apk to the Android device. +RUN_DEBUGGER=1: + Launches the application in gdb after it has been deployed. To debug in + gdb, NDK_DEBUG=1 must also be specified on the command line to build a + debug apk. +LAUNCH=0: + Disable the launch of the apk on the Android device. +SWIG_BIN=swig_binary_directory: + The directory where the SWIG binary lives. No need to set this if SWIG is + installed and point to from your PATH variable. +SWIG_LIB=swig_include_directory: + The directory where SWIG shared include files are, usually obtainable from + commandline with \"swig -swiglib\". No need to set this if SWIG is installed + and point to from your PATH variable. +ndk-build arguments...: + Additional arguments for ndk-build. See ndk-build -h for more information. +" >&2 + exit 1 +} + +# Get the number of CPU cores present on the host. +get_number_of_cores() { + case ${os_name} in + Darwin) + sysctl hw.ncpu | awk '{ print $2 }' + ;; + CYGWIN*|Linux) + awk '/^processor/ { n=$3 } END { print n + 1 }' /proc/cpuinfo + ;; + *) + echo 1 + ;; + esac +} + +# Get the package name from an AndroidManifest.xml file. +get_package_name_from_manifest() { + xmllint --xpath 'string(/manifest/@package)' "${1}" +} + +# Get the library name from an AndroidManifest.xml file. +get_library_name_from_manifest() { + echo "\ +setns android=http://schemas.android.com/apk/res/android +xpath string(/manifest/application/activity\ +[@android:name=\"android.app.NativeActivity\"]/meta-data\ +[@android:name=\"android.app.lib_name\"]/@android:value)" | + xmllint --shell "${1}" | awk '/Object is a string/ { print $NF }' +} + +# Get the number of Android devices connected to the system. +get_number_of_devices_connected() { + adb devices -l | \ + awk '/^..*$/ { if (p) { print $0 } } + /List of devices attached/ { p = 1 }' | \ + wc -l + return ${PIPESTATUS[0]} +} + +# Kill a process and its' children. This is provided for cygwin which +# doesn't ship with pkill. +kill_process_group() { + local parent_pid="${1}" + local child_pid= + for child_pid in $(ps -f | \ + awk '{ if ($3 == '"${parent_pid}"') { print $2 } }'); do + kill_process_group "${child_pid}" + done + kill "${parent_pid}" 2>/dev/null +} + +# Find and run "adb". +adb() { + local adb_path= + for path in "$(which adb 2>/dev/null)" \ + "${ANDROID_SDK_HOME}/sdk/platform-tools/adb" \ + "${android_root}/prebuilts/sdk/platform-tools/adb"; do + if [[ -e "${path}" ]]; then + adb_path="${path}" + break + fi + done + if [[ "${adb_path}" == "" ]]; then + echo -e "Unable to find adb." \ + "\nAdd the Android ADT sdk/platform-tools directory to the" \ + "PATH." >&2 + exit 1 + fi + "${adb_path}" "$@" +} + +# Find and run "android". +android() { + local android_executable=android + if echo "${os_name}" | grep -q CYGWIN; then + android_executable=android.bat + fi + local android_path= + for path in "$(which ${android_executable})" \ + "${ANDROID_SDK_HOME}/sdk/tools/${android_executable}" \ + "${android_root}/prebuilts/sdk/tools/${android_executable}"; do + if [[ -e "${path}" ]]; then + android_path="${path}" + break + fi + done + if [[ "${android_path}" == "" ]]; then + echo -e "Unable to find android tool." \ + "\nAdd the Android ADT sdk/tools directory to the PATH." >&2 + exit 1 + fi + # Make sure ant is installed. + if [[ "$(which ant)" == "" ]]; then + echo -e "Unable to find ant." \ + "\nPlease install ant and add to the PATH." >&2 + exit 1 + fi + + "${android_path}" "$@" +} + +# Find and run "ndk-build" +ndkbuild() { + local ndkbuild_path= + for path in "$(which ndk-build 2>/dev/null)" \ + "${NDK_HOME}/ndk-build" \ + "${android_root}/prebuilts/ndk/current/ndk-build"; do + if [[ -e "${path}" ]]; then + ndkbuild_path="${path}" + break + fi + done + if [[ "${ndkbuild_path}" == "" ]]; then + echo -e "Unable to find ndk-build." \ + "\nAdd the Android NDK directory to the PATH." >&2 + exit 1 + fi + "${ndkbuild_path}" "$@" +} + +# Get file modification time of $1 in seconds since the epoch. +stat_mtime() { + local filename="${1}" + case ${os_name} in + Darwin) stat -f%m "${filename}" 2>/dev/null || echo 0 ;; + *) stat -c%Y "${filename}" 2>/dev/null || echo 0 ;; + esac +} + +# Build the native (C/C++) build targets in the current directory. +build_native_targets() { + # Save the list of output modules in the install directory so that it's + # possible to restore their timestamps after the build is complete. This + # works around a bug in ndk/build/core/setup-app.mk which results in the + # unconditional execution of the clean-installed-binaries rule. + restore_libraries="$(find libs -type f 2>/dev/null | \ + sed -E 's@^libs/(.*)@\1@')" + + # Build native code. + ndkbuild -j$(get_number_of_cores) "$@" + + # Restore installed libraries. + # Obviously this is a nasty hack (along with ${restore_libraries} above) as + # it assumes it knows where the NDK will be placing output files. + ( + IFS=$'\n' + for libpath in ${restore_libraries}; do + source_library="obj/local/${libpath}" + target_library="libs/${libpath}" + if [[ -e "${source_library}" ]]; then + cp -a "${source_library}" "${target_library}" + fi + done + ) +} + +# Select the oldest installed android build target that is at least as new as +# BUILDAPK_ANDROID_TARGET_MINVERSION. If a suitable build target isn't found, +# this function prints an error message and exits with an error. +select_android_build_target() { + local -r android_targets_installed=$( \ + android list targets | \ + awk -F'"' '/^id:.*android/ { print $2 }') + local android_build_target= + for android_target in $(echo "${android_targets_installed}" | \ + awk -F- '{ print $2 }' | sort -n); do + if [[ $((android_target)) -ge \ + $((BUILDAPK_ANDROID_TARGET_MINVERSION)) ]]; then + android_build_target="android-${android_target}" + break + fi + done + if [[ "${android_build_target}" == "" ]]; then + echo -e \ + "Found installed Android targets:" \ + "$(echo ${android_targets_installed} | sed 's/ /\n /g;s/^/\n /;')" \ + "\nAndroid SDK platform" \ + "android-$((BUILDAPK_ANDROID_TARGET_MINVERSION))" \ + "must be installed to build this project." \ + "\nUse the \"android\" application to install API" \ + "$((BUILDAPK_ANDROID_TARGET_MINVERSION)) or newer." >&2 + exit 1 + fi + echo "${android_build_target}" +} + +# Sign unsigned apk $1 and write the result to $2 with key store file $3 and +# password $4. +# If a key store file $3 and password $4 aren't specified, a temporary +# (60 day) key is generated and used to sign the package. +sign_apk() { + local unsigned_apk="${1}" + local signed_apk="${2}" + if [[ $(stat_mtime "${unsigned_apk}") -gt \ + $(stat_mtime "${signed_apk}") ]]; then + local -r key_alias=$(basename ${signed_apk} .apk) + local keystore="${3}" + local key_password="${4}" + [[ "${keystore}" == "" ]] && keystore="${unsigned_apk}.keystore" + [[ "${key_password}" == "" ]] && \ + key_password="${key_alias}123456" + if [[ ! -e ${keystore} ]]; then + keytool -genkey -v -dname "cn=, ou=${key_alias}, o=fpl" \ + -storepass ${key_password} \ + -keypass ${key_password} -keystore ${keystore} \ + -alias ${key_alias} -keyalg RSA -keysize 2048 -validity 60 + fi + cp "${unsigned_apk}" "${signed_apk}" + jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \ + -keystore ${keystore} -storepass ${key_password} \ + -keypass ${key_password} "${signed_apk}" ${key_alias} + fi +} + +# Build the apk $1 for package filename $2 in the current directory using the +# ant build target $3. +build_apk() { + local -r output_apk="${1}" + local -r package_filename="${2}" + local -r ant_target="${3}" + # Get the list of installed android targets and select the oldest target + # that is at least as new as BUILDAPK_ANDROID_TARGET_MINVERSION. + local -r android_build_target=$(select_android_build_target) + [[ "${android_build_target}" == "" ]] && exit 1 + echo "Building ${output_apk} for target ${android_build_target}" >&2 + + # Create / update build.xml and local.properties files. + if [[ $(stat_mtime "${android_manifest}") -gt \ + $(stat_mtime build.xml) ]]; then + android update project --target "${android_build_target}" \ + -n ${package_filename} --path . + fi + + # Use ant to build the apk. + ant -quiet ${ant_target} + + # Sign release apks with a temporary key as these packages will not be + # redistributed. + local unsigned_apk="bin/${package_filename}-${ant_target}-unsigned.apk" + if [[ "${ant_target}" == "release" ]]; then + sign_apk "${unsigned_apk}" "${output_apk}" "" "" + fi +} + +# Uninstall package $1 and install apk $2 on device $3 where $3 is "-s device" +# or an empty string. If $3 is an empty string adb will fail when multiple +# devices are connected to the host system. +install_apk() { + local -r uninstall_package_name="${1}" + local -r install_apk="${2}" + local -r adb_device="${3}" + # Uninstall the package if it's already installed. + adb ${adb_device} uninstall "${uninstall_package_name}" 1>&2 > /dev/null || \ + true # no error check + + # Install the apk. + # NOTE: The following works around adb not returning an error code when + # it fails to install an apk. + echo "Install ${install_apk}" >&2 + local -r adb_install_result=$(adb ${adb_device} install "${install_apk}") + echo "${adb_install_result}" + if echo "${adb_install_result}" | grep -qF 'Failure ['; then + exit 1 + fi +} + +# Launch previously installed package $1 on device $2. +# If $2 is an empty string adb will fail when multiple devices are connected +# to the host system. +launch_package() { + ( + # Determine the SDK version of Android on the device. + local -r android_sdk_version=$( + adb ${adb_device} shell cat system/build.prop | \ + awk -F= '/ro.build.version.sdk/ { + v=$2; sub(/[ \r\n]/, "", v); print v + }') + + # Clear logs from previous runs. + # Note that logcat does not just 'tail' the logs, it dumps the entire log + # history. + adb ${adb_device} logcat -c + + local finished_msg='Displayed '"${package_name}" + local timeout_msg='Activity destroy timeout.*'"${package_name}" + # Maximum time to wait before stopping log monitoring. 0 = infinity. + local launch_timeout=0 + # If this is a Gingerbread device, kill log monitoring after 10 seconds. + if [[ $((android_sdk_version)) -le 10 ]]; then + launch_timeout=10 + fi + # Display logcat in the background. + # Stop displaying the log when the app launch / execution completes or the + # logcat + ( + adb ${adb_device} logcat | \ + awk " + { + print \$0 + } + + /ActivityManager.*: ${finished_msg}/ { + exit 0 + } + + /ActivityManager.*: ${timeout_msg}/ { + exit 0 + }" & + adb_logcat_pid=$!; + if [[ $((launch_timeout)) -gt 0 ]]; then + sleep $((launch_timeout)); + kill ${adb_logcat_pid}; + else + wait ${adb_logcat_pid}; + fi + ) & + logcat_pid=$! + # Kill adb logcat if this shell exits. + trap "kill_process_group ${logcat_pid}" SIGINT SIGTERM EXIT + + # If the SDK is newer than 10, "am" supports stopping an activity. + adb_stop_activity= + if [[ $((android_sdk_version)) -gt 10 ]]; then + adb_stop_activity=-S + fi + + # Launch the activity and wait for it to complete. + adb ${adb_device} shell am start ${adb_stop_activity} -n \ + ${package_name}/android.app.NativeActivity + + wait "${logcat_pid}" + ) +} + +# See usage(). +main() { + # Parse arguments for this script. + local adb_device= + local ant_target=release + local disable_deploy=0 + local disable_build=0 + local run_debugger=0 + local launch=1 + local build_package=1 + for opt; do + case ${opt} in + NDK_DEBUG=1) 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 ;; + -h|--help|help) usage ;; + esac + done + + # If a target device hasn't been specified and multiple devices are connected + # to the host machine, display an error. + local -r devices_connected=$(get_number_of_devices_connected) + if [[ "${adb_device}" == "" && $((devices_connected)) -gt 1 && \ + ($((disable_deploy)) -eq 0 || $((launch)) -ne 0 || \ + $((run_debugger)) -ne 0) ]]; then + if [[ $((disable_deploy)) -ne 0 ]]; then + echo "Deployment enabled, disable using DEPLOY=0" >&2 + fi + if [[ $((launch)) -ne 0 ]]; then + echo "Launch enabled." >&2 + fi + if [[ $((disable_deploy)) -eq 0 ]]; then + echo "Deployment enabled." >&2 + fi + if [[ $((run_debugger)) -ne 0 ]]; then + echo "Debugger launch enabled." >&2 + fi + echo " +Multiple Android devices are connected to this host. Either disable deployment +and execution of the built .apk using: + \"${script_name} DEPLOY=0 LAUNCH=0\" + +or specify a device to deploy to using: + \"${script_name} ADB_DEVICE=\${device_serial}\". + +The Android devices connected to this machine are: +$(adb devices -l) +" >&2 + exit 1 + fi + + if [[ $((disable_build)) -eq 0 ]]; then + # Build the native target. + build_native_targets "$@" + fi + + # Get the package name from the manifest. + local -r package_name=$(get_package_name_from_manifest "${android_manifest}") + if [[ "${package_name}" == "" ]]; then + echo -e "No package name specified in ${android_manifest},"\ + "skipping apk build, deploy" + "\nand launch steps." >&2 + exit 0 + fi + local -r package_basename=${package_name/*./} + local package_filename=$(get_library_name_from_manifest ${android_manifest}) + [[ "${package_filename}" == "" ]] && package_filename="${package_basename}" + + # Output apk name. + local -r output_apk="bin/${package_filename}-${ant_target}.apk" + + if [[ $((disable_build)) -eq 0 && $((build_package)) -eq 1 ]]; then + # Build the apk. + build_apk "${output_apk}" "${package_filename}" "${ant_target}" + fi + + # Deploy to the device. + if [[ $((disable_deploy)) -eq 0 ]]; then + install_apk "${package_name}" "${output_apk}" "${adb_device}" + fi + + if [[ "${ant_target}" == "debug" && $((run_debugger)) -eq 1 ]]; then + # Start debugging. + ndk-gdb ${adb_device} --start + elif [[ $((launch)) -eq 1 ]]; then + launch_package "${package_name}" "${adb_device}" + fi +} + +main "$@" diff --git a/android/jni/Android.mk b/android/jni/Android.mk new file mode 100755 index 00000000..2418566d --- /dev/null +++ b/android/jni/Android.mk @@ -0,0 +1,33 @@ +# Copyright (c) 2013 Google, Inc. +# +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the authors be held liable for any damages +# arising from the use of this software. +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# 1. The origin of this software must not be misrepresented; you must not +# claim that you wrote the original software. If you use this software +# in a product, an acknowledgment in the product documentation would be +# appreciated but is not required. +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# 3. This notice may not be removed or altered from any source distribution. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +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 + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,android/native_app_glue) + +$(call import-add-path,../..) diff --git a/android/jni/Application.mk b/android/jni/Application.mk new file mode 100755 index 00000000..56952fc9 --- /dev/null +++ b/android/jni/Application.mk @@ -0,0 +1,22 @@ +# Copyright (c) 2014 Google, Inc. +# +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the authors be held liable for any damages +# arising from the use of this software. +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# 1. The origin of this software must not be misrepresented; you must not +# claim that you wrote the original software. If you use this software +# in a product, an acknowledgment in the product documentation would be +# appreciated but is not required. +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# 3. This notice may not be removed or altered from any source distribution. +APP_PLATFORM := android-10 +APP_PROJECT_PATH := $(call my-dir)/.. +APP_STL := gnustl_static + +APP_ABI := armeabi-v7a +NDK_TOOLCHAIN_VERSION := 4.8 +APP_CPPFLAGS += -std=c++11 diff --git a/android/jni/main.cpp b/android/jni/main.cpp new file mode 100755 index 00000000..0d643495 --- /dev/null +++ b/android/jni/main.cpp @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#include <android_native_app_glue.h> + +extern int main(int argc, char **argv); + +void android_main(android_app *app) { + // Make sure glue isn't stripped. + app_dummy(); + + main(0, NULL); +} diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml new file mode 100755 index 00000000..ec752393 --- /dev/null +++ b/android/res/values/strings.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2014 Google, Inc. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + --> +<resources> + <string name="app_name">FlatBufferTest</string> +</resources> diff --git a/docs/documentation.html b/docs/documentation.html new file mode 100755 index 00000000..1f279d9e --- /dev/null +++ b/docs/documentation.html @@ -0,0 +1,8 @@ +<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> diff --git a/docs/footer.html b/docs/footer.html new file mode 100755 index 00000000..42bc5f2b --- /dev/null +++ b/docs/footer.html @@ -0,0 +1,14 @@ +<!-- 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> diff --git a/docs/html/bc_s.png b/docs/html/bc_s.png Binary files differnew file mode 100644 index 00000000..224b29aa --- /dev/null +++ b/docs/html/bc_s.png diff --git a/docs/html/bdwn.png b/docs/html/bdwn.png Binary files differnew file mode 100644 index 00000000..940a0b95 --- /dev/null +++ b/docs/html/bdwn.png diff --git a/docs/html/closed.png b/docs/html/closed.png Binary files differnew file mode 100644 index 00000000..98cc2c90 --- /dev/null +++ b/docs/html/closed.png diff --git a/docs/html/doxygen.css b/docs/html/doxygen.css new file mode 100644 index 00000000..4699e697 --- /dev/null +++ b/docs/html/doxygen.css @@ -0,0 +1,1357 @@ +/* The standard CSS for doxygen 1.8.5 */ + +body, table, div, p, dl { + font: 400 14px/22px Roboto,sans-serif; +} + +/* @group Heading Levels */ + +h1.groupheader { + font-size: 150%; +} + +.title { + font: 400 14px/28px Roboto,sans-serif; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h2.groupheader { + border-bottom: 1px solid #879ECB; + color: #354C7B; + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd, p.starttd { + margin-top: 2px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 0px; + margin: 0px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line.glow { + background-color: cyan; + box-shadow: 0 0 10px cyan; +} + + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: cyan; + box-shadow: 0 0 15px cyan; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memSeparator { + border-bottom: 1px solid #DEE4F0; + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; + font-size: 80%; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + font-weight: bold; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 4px; + border-top-left-radius: 4px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 4px; + -moz-border-radius-topleft: 4px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 4px; + -webkit-border-top-left-radius: 4px; + +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 10px 2px 10px; + background-color: #FBFCFD; + border-top-width: 0; + background-image:url('nav_g.png'); + background-repeat:repeat-x; + background-color: #FFFFFF; + /* opera specific markup */ + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-bottomright: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} +.paramname code { + line-height: 14px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: #728DC1; + border-top:1px solid #5373B4; + border-left:1px solid #5373B4; + border-right:1px solid #C4CFE5; + border-bottom:1px solid #C4CFE5; + text-shadow: none; + color: white; + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + + + +/* @end */ + +/* these are for tree view when not used as main index */ + +div.directory { + margin: 10px 0px; + border-top: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + width: 100%; +} + +.directory table { + border-collapse:collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: top; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 3px; +} + +.directory td.entry a { + outline:none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + border-left: 1px solid rgba(0,0,0,0.05); +} + +.directory tr.even { + padding-left: 6px; + background-color: #F7F8FB; +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: #3D578C; +} + +div.dynheader { + margin-top: 8px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + /*width: 100%;*/ + margin-bottom: 10px; + border: 1px solid #A8B8D9; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #A8B8D9; + /*width: 100%;*/ +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + font-size: 90%; + color: #253555; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #A8B8D9; +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + background-position: 0 -5px; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; + color: #283A5D; + font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.ingroups +{ + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +dl +{ + padding: 0 0 0 10px; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug */ +dl.section +{ + margin-left: 0px; + padding-left: 0px; +} + +dl.note +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #00D000; +} + +dl.deprecated +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #505050; +} + +dl.todo +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #00C0E0; +} + +dl.test +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #3030E0; +} + +dl.bug +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectname +{ + font: 300% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +div.zoom +{ + border: 1px solid #90A5CE; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:#334975; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd { + margin:2px 0; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F4F6FA; + border: 1px solid #D8DFEE; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 20px 10px 10px; + width: 200px; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +div.toc h3 { + font: bold 12px/1.2 Arial,FreeSans,sans-serif; + color: #4665A2; + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +.inherit_header { + font-weight: bold; + color: gray; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ + +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + white-space: nowrap; + background-color: white; + border: 1px solid gray; + border-radius: 4px 4px 4px 4px; + box-shadow: 1px 1px 7px gray; + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: grey; + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: #006318; +} + +#powerTip div { + margin: 0px; + padding: 0px; + font: 12px/16px Roboto,sans-serif; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, +#powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, +#powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, +#powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, +#powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, +#powerTip.sw:before, #powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: #ffffff; + border-width: 10px; + margin: 0px -10px; +} +#powerTip.n:before { + border-top-color: #808080; + border-width: 11px; + margin: 0px -11px; +} +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: #ffffff; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} +#powerTip.e:after { + border-left-color: #ffffff; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.e:before { + border-left-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} +#powerTip.w:after { + border-right-color: #ffffff; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.w:before { + border-right-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } +} + diff --git a/docs/html/doxygen.png b/docs/html/doxygen.png Binary files differnew file mode 100644 index 00000000..3ff17d80 --- /dev/null +++ b/docs/html/doxygen.png diff --git a/docs/html/dynsections.js b/docs/html/dynsections.js new file mode 100644 index 00000000..ed092c7f --- /dev/null +++ b/docs/html/dynsections.js @@ -0,0 +1,97 @@ +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.attr('src','ftv2folderopen.png'); + a.attr('src','ftv2mnode.png'); + $(this).show(); + } else if (l==level+1) { + i.attr('src','ftv2folderclosed.png'); + a.attr('src','ftv2pnode.png'); + $(this).show(); + } else { + $(this).hide(); + } + }); + updateStripes(); +} + +function toggleFolder(id) +{ + //The clicked row + var currentRow = $('#row_'+id); + var currentRowImages = currentRow.find("img"); + + //All rows after the clicked row + var rows = currentRow.nextAll("tr"); + + //Only match elements AFTER this one (can't hide elements before) + var childRows = rows.filter(function() { + var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub + return this.id.match(re); + }); + + //First row is visible we are HIDING + if (childRows.filter(':first').is(':visible')===true) { + currentRowImages.filter("[id^=arr]").attr('src', 'ftv2pnode.png'); + currentRowImages.filter("[id^=img]").attr('src', 'ftv2folderclosed.png'); + rows.filter("[id^=row_"+id+"]").hide(); + } else { //We are SHOWING + //All sub images + var childImages = childRows.find("img"); + var childImg = childImages.filter("[id^=img]"); + var childArr = childImages.filter("[id^=arr]"); + + currentRow.find("[id^=arr]").attr('src', 'ftv2mnode.png'); //open row + currentRow.find("[id^=img]").attr('src', 'ftv2folderopen.png'); //open row + childImg.attr('src','ftv2folderclosed.png'); //children closed + childArr.attr('src','ftv2pnode.png'); //children closed + 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'); + } +} + diff --git a/docs/html/ftv2blank.png b/docs/html/ftv2blank.png Binary files differnew file mode 100644 index 00000000..63c605bb --- /dev/null +++ b/docs/html/ftv2blank.png diff --git a/docs/html/ftv2cl.png b/docs/html/ftv2cl.png Binary files differnew file mode 100644 index 00000000..132f6577 --- /dev/null +++ b/docs/html/ftv2cl.png diff --git a/docs/html/ftv2doc.png b/docs/html/ftv2doc.png Binary files differnew file mode 100644 index 00000000..17edabff --- /dev/null +++ b/docs/html/ftv2doc.png diff --git a/docs/html/ftv2folderclosed.png b/docs/html/ftv2folderclosed.png Binary files differnew file mode 100644 index 00000000..bb8ab35e --- /dev/null +++ b/docs/html/ftv2folderclosed.png diff --git a/docs/html/ftv2folderopen.png b/docs/html/ftv2folderopen.png Binary files differnew file mode 100644 index 00000000..d6c7f676 --- /dev/null +++ b/docs/html/ftv2folderopen.png diff --git a/docs/html/ftv2lastnode.png b/docs/html/ftv2lastnode.png Binary files differnew file mode 100644 index 00000000..63c605bb --- /dev/null +++ b/docs/html/ftv2lastnode.png diff --git a/docs/html/ftv2link.png b/docs/html/ftv2link.png Binary files differnew file mode 100644 index 00000000..17edabff --- /dev/null +++ b/docs/html/ftv2link.png diff --git a/docs/html/ftv2mlastnode.png b/docs/html/ftv2mlastnode.png Binary files differnew file mode 100644 index 00000000..0b63f6d3 --- /dev/null +++ b/docs/html/ftv2mlastnode.png diff --git a/docs/html/ftv2mnode.png b/docs/html/ftv2mnode.png Binary files differnew file mode 100644 index 00000000..0b63f6d3 --- /dev/null +++ b/docs/html/ftv2mnode.png diff --git a/docs/html/ftv2mo.png b/docs/html/ftv2mo.png Binary files differnew file mode 100644 index 00000000..4bfb80f7 --- /dev/null +++ b/docs/html/ftv2mo.png diff --git a/docs/html/ftv2node.png b/docs/html/ftv2node.png Binary files differnew file mode 100644 index 00000000..63c605bb --- /dev/null +++ b/docs/html/ftv2node.png diff --git a/docs/html/ftv2ns.png b/docs/html/ftv2ns.png Binary files differnew file mode 100644 index 00000000..72e3d71c --- /dev/null +++ b/docs/html/ftv2ns.png diff --git a/docs/html/ftv2plastnode.png b/docs/html/ftv2plastnode.png Binary files differnew file mode 100644 index 00000000..c6ee22f9 --- /dev/null +++ b/docs/html/ftv2plastnode.png diff --git a/docs/html/ftv2pnode.png b/docs/html/ftv2pnode.png Binary files differnew file mode 100644 index 00000000..c6ee22f9 --- /dev/null +++ b/docs/html/ftv2pnode.png diff --git a/docs/html/ftv2splitbar.png b/docs/html/ftv2splitbar.png Binary files differnew file mode 100644 index 00000000..fe895f2c --- /dev/null +++ b/docs/html/ftv2splitbar.png diff --git a/docs/html/ftv2vertline.png b/docs/html/ftv2vertline.png Binary files differnew file mode 100644 index 00000000..63c605bb --- /dev/null +++ b/docs/html/ftv2vertline.png diff --git a/docs/html/index.html b/docs/html/index.html new file mode 100644 index 00000000..363c884a --- /dev/null +++ b/docs/html/index.html @@ -0,0 +1,115 @@ +<!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.5"/> +<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.5 --> +</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 in for C++ and Java. 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 code supports object-reuse.</p> +</li> +<li><b>Cross platform C++11/Java 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 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>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> diff --git a/docs/html/jquery.js b/docs/html/jquery.js new file mode 100644 index 00000000..3db33e62 --- /dev/null +++ b/docs/html/jquery.js @@ -0,0 +1,72 @@ +/*! + * jQuery JavaScript Library v1.7.1 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Nov 21 21:11:03 2011 -0500 + */ +(function(bb,L){var av=bb.document,bu=bb.navigator,bl=bb.location;var b=(function(){var bF=function(b0,b1){return new bF.fn.init(b0,b1,bD)},bU=bb.jQuery,bH=bb.$,bD,bY=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,bM=/\S/,bI=/^\s+/,bE=/\s+$/,bA=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,bN=/^[\],:{}\s]*$/,bW=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,bP=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,bJ=/(?:^|:|,)(?:\s*\[)+/g,by=/(webkit)[ \/]([\w.]+)/,bR=/(opera)(?:.*version)?[ \/]([\w.]+)/,bQ=/(msie) ([\w.]+)/,bS=/(mozilla)(?:.*? rv:([\w.]+))?/,bB=/-([a-z]|[0-9])/ig,bZ=/^-ms-/,bT=function(b0,b1){return(b1+"").toUpperCase()},bX=bu.userAgent,bV,bC,e,bL=Object.prototype.toString,bG=Object.prototype.hasOwnProperty,bz=Array.prototype.push,bK=Array.prototype.slice,bO=String.prototype.trim,bv=Array.prototype.indexOf,bx={};bF.fn=bF.prototype={constructor:bF,init:function(b0,b4,b3){var b2,b5,b1,b6;if(!b0){return this}if(b0.nodeType){this.context=this[0]=b0;this.length=1;return this}if(b0==="body"&&!b4&&av.body){this.context=av;this[0]=av.body;this.selector=b0;this.length=1;return this}if(typeof b0==="string"){if(b0.charAt(0)==="<"&&b0.charAt(b0.length-1)===">"&&b0.length>=3){b2=[null,b0,null]}else{b2=bY.exec(b0)}if(b2&&(b2[1]||!b4)){if(b2[1]){b4=b4 instanceof bF?b4[0]:b4;b6=(b4?b4.ownerDocument||b4:av);b1=bA.exec(b0);if(b1){if(bF.isPlainObject(b4)){b0=[av.createElement(b1[1])];bF.fn.attr.call(b0,b4,true)}else{b0=[b6.createElement(b1[1])]}}else{b1=bF.buildFragment([b2[1]],[b6]);b0=(b1.cacheable?bF.clone(b1.fragment):b1.fragment).childNodes}return bF.merge(this,b0)}else{b5=av.getElementById(b2[2]);if(b5&&b5.parentNode){if(b5.id!==b2[2]){return b3.find(b0)}this.length=1;this[0]=b5}this.context=av;this.selector=b0;return this}}else{if(!b4||b4.jquery){return(b4||b3).find(b0)}else{return this.constructor(b4).find(b0)}}}else{if(bF.isFunction(b0)){return b3.ready(b0)}}if(b0.selector!==L){this.selector=b0.selector;this.context=b0.context}return bF.makeArray(b0,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return bK.call(this,0)},get:function(b0){return b0==null?this.toArray():(b0<0?this[this.length+b0]:this[b0])},pushStack:function(b1,b3,b0){var b2=this.constructor();if(bF.isArray(b1)){bz.apply(b2,b1)}else{bF.merge(b2,b1)}b2.prevObject=this;b2.context=this.context;if(b3==="find"){b2.selector=this.selector+(this.selector?" ":"")+b0}else{if(b3){b2.selector=this.selector+"."+b3+"("+b0+")"}}return b2},each:function(b1,b0){return bF.each(this,b1,b0)},ready:function(b0){bF.bindReady();bC.add(b0);return this},eq:function(b0){b0=+b0;return b0===-1?this.slice(b0):this.slice(b0,b0+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(bK.apply(this,arguments),"slice",bK.call(arguments).join(","))},map:function(b0){return this.pushStack(bF.map(this,function(b2,b1){return b0.call(b2,b1,b2)}))},end:function(){return this.prevObject||this.constructor(null)},push:bz,sort:[].sort,splice:[].splice};bF.fn.init.prototype=bF.fn;bF.extend=bF.fn.extend=function(){var b9,b2,b0,b1,b6,b7,b5=arguments[0]||{},b4=1,b3=arguments.length,b8=false;if(typeof b5==="boolean"){b8=b5;b5=arguments[1]||{};b4=2}if(typeof b5!=="object"&&!bF.isFunction(b5)){b5={}}if(b3===b4){b5=this;--b4}for(;b4<b3;b4++){if((b9=arguments[b4])!=null){for(b2 in b9){b0=b5[b2];b1=b9[b2];if(b5===b1){continue}if(b8&&b1&&(bF.isPlainObject(b1)||(b6=bF.isArray(b1)))){if(b6){b6=false;b7=b0&&bF.isArray(b0)?b0:[]}else{b7=b0&&bF.isPlainObject(b0)?b0:{}}b5[b2]=bF.extend(b8,b7,b1)}else{if(b1!==L){b5[b2]=b1}}}}}return b5};bF.extend({noConflict:function(b0){if(bb.$===bF){bb.$=bH}if(b0&&bb.jQuery===bF){bb.jQuery=bU}return bF},isReady:false,readyWait:1,holdReady:function(b0){if(b0){bF.readyWait++}else{bF.ready(true)}},ready:function(b0){if((b0===true&&!--bF.readyWait)||(b0!==true&&!bF.isReady)){if(!av.body){return setTimeout(bF.ready,1)}bF.isReady=true;if(b0!==true&&--bF.readyWait>0){return}bC.fireWith(av,[bF]);if(bF.fn.trigger){bF(av).trigger("ready").off("ready")}}},bindReady:function(){if(bC){return}bC=bF.Callbacks("once memory");if(av.readyState==="complete"){return setTimeout(bF.ready,1)}if(av.addEventListener){av.addEventListener("DOMContentLoaded",e,false);bb.addEventListener("load",bF.ready,false)}else{if(av.attachEvent){av.attachEvent("onreadystatechange",e);bb.attachEvent("onload",bF.ready);var b0=false;try{b0=bb.frameElement==null}catch(b1){}if(av.documentElement.doScroll&&b0){bw()}}}},isFunction:function(b0){return bF.type(b0)==="function"},isArray:Array.isArray||function(b0){return bF.type(b0)==="array"},isWindow:function(b0){return b0&&typeof b0==="object"&&"setInterval" in b0},isNumeric:function(b0){return !isNaN(parseFloat(b0))&&isFinite(b0)},type:function(b0){return b0==null?String(b0):bx[bL.call(b0)]||"object"},isPlainObject:function(b2){if(!b2||bF.type(b2)!=="object"||b2.nodeType||bF.isWindow(b2)){return false}try{if(b2.constructor&&!bG.call(b2,"constructor")&&!bG.call(b2.constructor.prototype,"isPrototypeOf")){return false}}catch(b1){return false}var b0;for(b0 in b2){}return b0===L||bG.call(b2,b0)},isEmptyObject:function(b1){for(var b0 in b1){return false}return true},error:function(b0){throw new Error(b0)},parseJSON:function(b0){if(typeof b0!=="string"||!b0){return null}b0=bF.trim(b0);if(bb.JSON&&bb.JSON.parse){return bb.JSON.parse(b0)}if(bN.test(b0.replace(bW,"@").replace(bP,"]").replace(bJ,""))){return(new Function("return "+b0))()}bF.error("Invalid JSON: "+b0)},parseXML:function(b2){var b0,b1;try{if(bb.DOMParser){b1=new DOMParser();b0=b1.parseFromString(b2,"text/xml")}else{b0=new ActiveXObject("Microsoft.XMLDOM");b0.async="false";b0.loadXML(b2)}}catch(b3){b0=L}if(!b0||!b0.documentElement||b0.getElementsByTagName("parsererror").length){bF.error("Invalid XML: "+b2)}return b0},noop:function(){},globalEval:function(b0){if(b0&&bM.test(b0)){(bb.execScript||function(b1){bb["eval"].call(bb,b1)})(b0)}},camelCase:function(b0){return b0.replace(bZ,"ms-").replace(bB,bT)},nodeName:function(b1,b0){return b1.nodeName&&b1.nodeName.toUpperCase()===b0.toUpperCase()},each:function(b3,b6,b2){var b1,b4=0,b5=b3.length,b0=b5===L||bF.isFunction(b3);if(b2){if(b0){for(b1 in b3){if(b6.apply(b3[b1],b2)===false){break}}}else{for(;b4<b5;){if(b6.apply(b3[b4++],b2)===false){break}}}}else{if(b0){for(b1 in b3){if(b6.call(b3[b1],b1,b3[b1])===false){break}}}else{for(;b4<b5;){if(b6.call(b3[b4],b4,b3[b4++])===false){break}}}}return b3},trim:bO?function(b0){return b0==null?"":bO.call(b0)}:function(b0){return b0==null?"":b0.toString().replace(bI,"").replace(bE,"")},makeArray:function(b3,b1){var b0=b1||[];if(b3!=null){var b2=bF.type(b3);if(b3.length==null||b2==="string"||b2==="function"||b2==="regexp"||bF.isWindow(b3)){bz.call(b0,b3)}else{bF.merge(b0,b3)}}return b0},inArray:function(b2,b3,b1){var b0;if(b3){if(bv){return bv.call(b3,b2,b1)}b0=b3.length;b1=b1?b1<0?Math.max(0,b0+b1):b1:0;for(;b1<b0;b1++){if(b1 in b3&&b3[b1]===b2){return b1}}}return -1},merge:function(b4,b2){var b3=b4.length,b1=0;if(typeof b2.length==="number"){for(var b0=b2.length;b1<b0;b1++){b4[b3++]=b2[b1]}}else{while(b2[b1]!==L){b4[b3++]=b2[b1++]}}b4.length=b3;return b4},grep:function(b1,b6,b0){var b2=[],b5;b0=!!b0;for(var b3=0,b4=b1.length;b3<b4;b3++){b5=!!b6(b1[b3],b3);if(b0!==b5){b2.push(b1[b3])}}return b2},map:function(b0,b7,b8){var b5,b6,b4=[],b2=0,b1=b0.length,b3=b0 instanceof bF||b1!==L&&typeof b1==="number"&&((b1>0&&b0[0]&&b0[b1-1])||b1===0||bF.isArray(b0));if(b3){for(;b2<b1;b2++){b5=b7(b0[b2],b2,b8);if(b5!=null){b4[b4.length]=b5}}}else{for(b6 in b0){b5=b7(b0[b6],b6,b8);if(b5!=null){b4[b4.length]=b5}}}return b4.concat.apply([],b4)},guid:1,proxy:function(b4,b3){if(typeof b3==="string"){var b2=b4[b3];b3=b4;b4=b2}if(!bF.isFunction(b4)){return L}var b0=bK.call(arguments,2),b1=function(){return b4.apply(b3,b0.concat(bK.call(arguments)))};b1.guid=b4.guid=b4.guid||b1.guid||bF.guid++;return b1},access:function(b0,b8,b6,b2,b5,b7){var b1=b0.length;if(typeof b8==="object"){for(var b3 in b8){bF.access(b0,b3,b8[b3],b2,b5,b6)}return b0}if(b6!==L){b2=!b7&&b2&&bF.isFunction(b6);for(var b4=0;b4<b1;b4++){b5(b0[b4],b8,b2?b6.call(b0[b4],b4,b5(b0[b4],b8)):b6,b7)}return b0}return b1?b5(b0[0],b8):L},now:function(){return(new Date()).getTime()},uaMatch:function(b1){b1=b1.toLowerCase();var b0=by.exec(b1)||bR.exec(b1)||bQ.exec(b1)||b1.indexOf("compatible")<0&&bS.exec(b1)||[];return{browser:b0[1]||"",version:b0[2]||"0"}},sub:function(){function b0(b3,b4){return new b0.fn.init(b3,b4)}bF.extend(true,b0,this);b0.superclass=this;b0.fn=b0.prototype=this();b0.fn.constructor=b0;b0.sub=this.sub;b0.fn.init=function b2(b3,b4){if(b4&&b4 instanceof bF&&!(b4 instanceof b0)){b4=b0(b4)}return bF.fn.init.call(this,b3,b4,b1)};b0.fn.init.prototype=b0.fn;var b1=b0(av);return b0},browser:{}});bF.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(b1,b0){bx["[object "+b0+"]"]=b0.toLowerCase()});bV=bF.uaMatch(bX);if(bV.browser){bF.browser[bV.browser]=true;bF.browser.version=bV.version}if(bF.browser.webkit){bF.browser.safari=true}if(bM.test("\xA0")){bI=/^[\s\xA0]+/;bE=/[\s\xA0]+$/}bD=bF(av);if(av.addEventListener){e=function(){av.removeEventListener("DOMContentLoaded",e,false);bF.ready()}}else{if(av.attachEvent){e=function(){if(av.readyState==="complete"){av.detachEvent("onreadystatechange",e);bF.ready()}}}}function bw(){if(bF.isReady){return}try{av.documentElement.doScroll("left")}catch(b0){setTimeout(bw,1);return}bF.ready()}return bF})();var a2={};function X(e){var bv=a2[e]={},bw,bx;e=e.split(/\s+/);for(bw=0,bx=e.length;bw<bx;bw++){bv[e[bw]]=true}return bv}b.Callbacks=function(bw){bw=bw?(a2[bw]||X(bw)):{};var bB=[],bC=[],bx,by,bv,bz,bA,bE=function(bF){var bG,bJ,bI,bH,bK;for(bG=0,bJ=bF.length;bG<bJ;bG++){bI=bF[bG];bH=b.type(bI);if(bH==="array"){bE(bI)}else{if(bH==="function"){if(!bw.unique||!bD.has(bI)){bB.push(bI)}}}}},e=function(bG,bF){bF=bF||[];bx=!bw.memory||[bG,bF];by=true;bA=bv||0;bv=0;bz=bB.length;for(;bB&&bA<bz;bA++){if(bB[bA].apply(bG,bF)===false&&bw.stopOnFalse){bx=true;break}}by=false;if(bB){if(!bw.once){if(bC&&bC.length){bx=bC.shift();bD.fireWith(bx[0],bx[1])}}else{if(bx===true){bD.disable()}else{bB=[]}}}},bD={add:function(){if(bB){var bF=bB.length;bE(arguments);if(by){bz=bB.length}else{if(bx&&bx!==true){bv=bF;e(bx[0],bx[1])}}}return this},remove:function(){if(bB){var bF=arguments,bH=0,bI=bF.length;for(;bH<bI;bH++){for(var bG=0;bG<bB.length;bG++){if(bF[bH]===bB[bG]){if(by){if(bG<=bz){bz--;if(bG<=bA){bA--}}}bB.splice(bG--,1);if(bw.unique){break}}}}}return this},has:function(bG){if(bB){var bF=0,bH=bB.length;for(;bF<bH;bF++){if(bG===bB[bF]){return true}}}return false},empty:function(){bB=[];return this},disable:function(){bB=bC=bx=L;return this},disabled:function(){return !bB},lock:function(){bC=L;if(!bx||bx===true){bD.disable()}return this},locked:function(){return !bC},fireWith:function(bG,bF){if(bC){if(by){if(!bw.once){bC.push([bG,bF])}}else{if(!(bw.once&&bx)){e(bG,bF)}}}return this},fire:function(){bD.fireWith(this,arguments);return this},fired:function(){return !!bx}};return bD};var aJ=[].slice;b.extend({Deferred:function(by){var bx=b.Callbacks("once memory"),bw=b.Callbacks("once memory"),bv=b.Callbacks("memory"),e="pending",bA={resolve:bx,reject:bw,notify:bv},bC={done:bx.add,fail:bw.add,progress:bv.add,state:function(){return e},isResolved:bx.fired,isRejected:bw.fired,then:function(bE,bD,bF){bB.done(bE).fail(bD).progress(bF);return this},always:function(){bB.done.apply(bB,arguments).fail.apply(bB,arguments);return this},pipe:function(bF,bE,bD){return b.Deferred(function(bG){b.each({done:[bF,"resolve"],fail:[bE,"reject"],progress:[bD,"notify"]},function(bI,bL){var bH=bL[0],bK=bL[1],bJ;if(b.isFunction(bH)){bB[bI](function(){bJ=bH.apply(this,arguments);if(bJ&&b.isFunction(bJ.promise)){bJ.promise().then(bG.resolve,bG.reject,bG.notify)}else{bG[bK+"With"](this===bB?bG:this,[bJ])}})}else{bB[bI](bG[bK])}})}).promise()},promise:function(bE){if(bE==null){bE=bC}else{for(var bD in bC){bE[bD]=bC[bD]}}return bE}},bB=bC.promise({}),bz;for(bz in bA){bB[bz]=bA[bz].fire;bB[bz+"With"]=bA[bz].fireWith}bB.done(function(){e="resolved"},bw.disable,bv.lock).fail(function(){e="rejected"},bx.disable,bv.lock);if(by){by.call(bB,bB)}return bB},when:function(bA){var bx=aJ.call(arguments,0),bv=0,e=bx.length,bB=new Array(e),bw=e,by=e,bC=e<=1&&bA&&b.isFunction(bA.promise)?bA:b.Deferred(),bE=bC.promise();function bD(bF){return function(bG){bx[bF]=arguments.length>1?aJ.call(arguments,0):bG;if(!(--bw)){bC.resolveWith(bC,bx)}}}function bz(bF){return function(bG){bB[bF]=arguments.length>1?aJ.call(arguments,0):bG;bC.notifyWith(bE,bB)}}if(e>1){for(;bv<e;bv++){if(bx[bv]&&bx[bv].promise&&b.isFunction(bx[bv].promise)){bx[bv].promise().then(bD(bv),bC.reject,bz(bv)) +}else{--bw}}if(!bw){bC.resolveWith(bC,bx)}}else{if(bC!==bA){bC.resolveWith(bC,e?[bA]:[])}}return bE}});b.support=(function(){var bJ,bI,bF,bG,bx,bE,bA,bD,bz,bK,bB,by,bw,bv=av.createElement("div"),bH=av.documentElement;bv.setAttribute("className","t");bv.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";bI=bv.getElementsByTagName("*");bF=bv.getElementsByTagName("a")[0];if(!bI||!bI.length||!bF){return{}}bG=av.createElement("select");bx=bG.appendChild(av.createElement("option"));bE=bv.getElementsByTagName("input")[0];bJ={leadingWhitespace:(bv.firstChild.nodeType===3),tbody:!bv.getElementsByTagName("tbody").length,htmlSerialize:!!bv.getElementsByTagName("link").length,style:/top/.test(bF.getAttribute("style")),hrefNormalized:(bF.getAttribute("href")==="/a"),opacity:/^0.55/.test(bF.style.opacity),cssFloat:!!bF.style.cssFloat,checkOn:(bE.value==="on"),optSelected:bx.selected,getSetAttribute:bv.className!=="t",enctype:!!av.createElement("form").enctype,html5Clone:av.createElement("nav").cloneNode(true).outerHTML!=="<:nav></:nav>",submitBubbles:true,changeBubbles:true,focusinBubbles:false,deleteExpando:true,noCloneEvent:true,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableMarginRight:true};bE.checked=true;bJ.noCloneChecked=bE.cloneNode(true).checked;bG.disabled=true;bJ.optDisabled=!bx.disabled;try{delete bv.test}catch(bC){bJ.deleteExpando=false}if(!bv.addEventListener&&bv.attachEvent&&bv.fireEvent){bv.attachEvent("onclick",function(){bJ.noCloneEvent=false});bv.cloneNode(true).fireEvent("onclick")}bE=av.createElement("input");bE.value="t";bE.setAttribute("type","radio");bJ.radioValue=bE.value==="t";bE.setAttribute("checked","checked");bv.appendChild(bE);bD=av.createDocumentFragment();bD.appendChild(bv.lastChild);bJ.checkClone=bD.cloneNode(true).cloneNode(true).lastChild.checked;bJ.appendChecked=bE.checked;bD.removeChild(bE);bD.appendChild(bv);bv.innerHTML="";if(bb.getComputedStyle){bA=av.createElement("div");bA.style.width="0";bA.style.marginRight="0";bv.style.width="2px";bv.appendChild(bA);bJ.reliableMarginRight=(parseInt((bb.getComputedStyle(bA,null)||{marginRight:0}).marginRight,10)||0)===0}if(bv.attachEvent){for(by in {submit:1,change:1,focusin:1}){bB="on"+by;bw=(bB in bv);if(!bw){bv.setAttribute(bB,"return;");bw=(typeof bv[bB]==="function")}bJ[by+"Bubbles"]=bw}}bD.removeChild(bv);bD=bG=bx=bA=bv=bE=null;b(function(){var bM,bU,bV,bT,bN,bO,bL,bS,bR,e,bP,bQ=av.getElementsByTagName("body")[0];if(!bQ){return}bL=1;bS="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";bR="visibility:hidden;border:0;";e="style='"+bS+"border:5px solid #000;padding:0;'";bP="<div "+e+"><div></div></div><table "+e+" cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";bM=av.createElement("div");bM.style.cssText=bR+"width:0;height:0;position:static;top:0;margin-top:"+bL+"px";bQ.insertBefore(bM,bQ.firstChild);bv=av.createElement("div");bM.appendChild(bv);bv.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";bz=bv.getElementsByTagName("td");bw=(bz[0].offsetHeight===0);bz[0].style.display="";bz[1].style.display="none";bJ.reliableHiddenOffsets=bw&&(bz[0].offsetHeight===0);bv.innerHTML="";bv.style.width=bv.style.paddingLeft="1px";b.boxModel=bJ.boxModel=bv.offsetWidth===2;if(typeof bv.style.zoom!=="undefined"){bv.style.display="inline";bv.style.zoom=1;bJ.inlineBlockNeedsLayout=(bv.offsetWidth===2);bv.style.display="";bv.innerHTML="<div style='width:4px;'></div>";bJ.shrinkWrapBlocks=(bv.offsetWidth!==2)}bv.style.cssText=bS+bR;bv.innerHTML=bP;bU=bv.firstChild;bV=bU.firstChild;bN=bU.nextSibling.firstChild.firstChild;bO={doesNotAddBorder:(bV.offsetTop!==5),doesAddBorderForTableAndCells:(bN.offsetTop===5)};bV.style.position="fixed";bV.style.top="20px";bO.fixedPosition=(bV.offsetTop===20||bV.offsetTop===15);bV.style.position=bV.style.top="";bU.style.overflow="hidden";bU.style.position="relative";bO.subtractsBorderForOverflowNotVisible=(bV.offsetTop===-5);bO.doesNotIncludeMarginInBodyOffset=(bQ.offsetTop!==bL);bQ.removeChild(bM);bv=bM=null;b.extend(bJ,bO)});return bJ})();var aS=/^(?:\{.*\}|\[.*\])$/,aA=/([A-Z])/g;b.extend({cache:{},uuid:0,expando:"jQuery"+(b.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},hasData:function(e){e=e.nodeType?b.cache[e[b.expando]]:e[b.expando];return !!e&&!S(e)},data:function(bx,bv,bz,by){if(!b.acceptData(bx)){return}var bG,bA,bD,bE=b.expando,bC=typeof bv==="string",bF=bx.nodeType,e=bF?b.cache:bx,bw=bF?bx[bE]:bx[bE]&&bE,bB=bv==="events";if((!bw||!e[bw]||(!bB&&!by&&!e[bw].data))&&bC&&bz===L){return}if(!bw){if(bF){bx[bE]=bw=++b.uuid}else{bw=bE}}if(!e[bw]){e[bw]={};if(!bF){e[bw].toJSON=b.noop}}if(typeof bv==="object"||typeof bv==="function"){if(by){e[bw]=b.extend(e[bw],bv)}else{e[bw].data=b.extend(e[bw].data,bv)}}bG=bA=e[bw];if(!by){if(!bA.data){bA.data={}}bA=bA.data}if(bz!==L){bA[b.camelCase(bv)]=bz}if(bB&&!bA[bv]){return bG.events}if(bC){bD=bA[bv];if(bD==null){bD=bA[b.camelCase(bv)]}}else{bD=bA}return bD},removeData:function(bx,bv,by){if(!b.acceptData(bx)){return}var bB,bA,bz,bC=b.expando,bD=bx.nodeType,e=bD?b.cache:bx,bw=bD?bx[bC]:bC;if(!e[bw]){return}if(bv){bB=by?e[bw]:e[bw].data;if(bB){if(!b.isArray(bv)){if(bv in bB){bv=[bv]}else{bv=b.camelCase(bv);if(bv in bB){bv=[bv]}else{bv=bv.split(" ")}}}for(bA=0,bz=bv.length;bA<bz;bA++){delete bB[bv[bA]]}if(!(by?S:b.isEmptyObject)(bB)){return}}}if(!by){delete e[bw].data;if(!S(e[bw])){return}}if(b.support.deleteExpando||!e.setInterval){delete e[bw]}else{e[bw]=null}if(bD){if(b.support.deleteExpando){delete bx[bC]}else{if(bx.removeAttribute){bx.removeAttribute(bC)}else{bx[bC]=null}}}},_data:function(bv,e,bw){return b.data(bv,e,bw,true)},acceptData:function(bv){if(bv.nodeName){var e=b.noData[bv.nodeName.toLowerCase()];if(e){return !(e===true||bv.getAttribute("classid")!==e)}}return true}});b.fn.extend({data:function(by,bA){var bB,e,bw,bz=null;if(typeof by==="undefined"){if(this.length){bz=b.data(this[0]);if(this[0].nodeType===1&&!b._data(this[0],"parsedAttrs")){e=this[0].attributes;for(var bx=0,bv=e.length;bx<bv;bx++){bw=e[bx].name;if(bw.indexOf("data-")===0){bw=b.camelCase(bw.substring(5));a5(this[0],bw,bz[bw])}}b._data(this[0],"parsedAttrs",true)}}return bz}else{if(typeof by==="object"){return this.each(function(){b.data(this,by)})}}bB=by.split(".");bB[1]=bB[1]?"."+bB[1]:"";if(bA===L){bz=this.triggerHandler("getData"+bB[1]+"!",[bB[0]]);if(bz===L&&this.length){bz=b.data(this[0],by);bz=a5(this[0],by,bz)}return bz===L&&bB[1]?this.data(bB[0]):bz}else{return this.each(function(){var bC=b(this),bD=[bB[0],bA];bC.triggerHandler("setData"+bB[1]+"!",bD);b.data(this,by,bA);bC.triggerHandler("changeData"+bB[1]+"!",bD)})}},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function a5(bx,bw,by){if(by===L&&bx.nodeType===1){var bv="data-"+bw.replace(aA,"-$1").toLowerCase();by=bx.getAttribute(bv);if(typeof by==="string"){try{by=by==="true"?true:by==="false"?false:by==="null"?null:b.isNumeric(by)?parseFloat(by):aS.test(by)?b.parseJSON(by):by}catch(bz){}b.data(bx,bw,by)}else{by=L}}return by}function S(bv){for(var e in bv){if(e==="data"&&b.isEmptyObject(bv[e])){continue}if(e!=="toJSON"){return false}}return true}function bi(by,bx,bA){var bw=bx+"defer",bv=bx+"queue",e=bx+"mark",bz=b._data(by,bw);if(bz&&(bA==="queue"||!b._data(by,bv))&&(bA==="mark"||!b._data(by,e))){setTimeout(function(){if(!b._data(by,bv)&&!b._data(by,e)){b.removeData(by,bw,true);bz.fire()}},0)}}b.extend({_mark:function(bv,e){if(bv){e=(e||"fx")+"mark";b._data(bv,e,(b._data(bv,e)||0)+1)}},_unmark:function(by,bx,bv){if(by!==true){bv=bx;bx=by;by=false}if(bx){bv=bv||"fx";var e=bv+"mark",bw=by?0:((b._data(bx,e)||1)-1);if(bw){b._data(bx,e,bw)}else{b.removeData(bx,e,true);bi(bx,bv,"mark")}}},queue:function(bv,e,bx){var bw;if(bv){e=(e||"fx")+"queue";bw=b._data(bv,e);if(bx){if(!bw||b.isArray(bx)){bw=b._data(bv,e,b.makeArray(bx))}else{bw.push(bx)}}return bw||[]}},dequeue:function(by,bx){bx=bx||"fx";var bv=b.queue(by,bx),bw=bv.shift(),e={};if(bw==="inprogress"){bw=bv.shift()}if(bw){if(bx==="fx"){bv.unshift("inprogress")}b._data(by,bx+".run",e);bw.call(by,function(){b.dequeue(by,bx)},e)}if(!bv.length){b.removeData(by,bx+"queue "+bx+".run",true);bi(by,bx,"queue")}}});b.fn.extend({queue:function(e,bv){if(typeof e!=="string"){bv=e;e="fx"}if(bv===L){return b.queue(this[0],e)}return this.each(function(){var bw=b.queue(this,e,bv);if(e==="fx"&&bw[0]!=="inprogress"){b.dequeue(this,e)}})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(bv,e){bv=b.fx?b.fx.speeds[bv]||bv:bv;e=e||"fx";return this.queue(e,function(bx,bw){var by=setTimeout(bx,bv);bw.stop=function(){clearTimeout(by)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(bD,bw){if(typeof bD!=="string"){bw=bD;bD=L}bD=bD||"fx";var e=b.Deferred(),bv=this,by=bv.length,bB=1,bz=bD+"defer",bA=bD+"queue",bC=bD+"mark",bx;function bE(){if(!(--bB)){e.resolveWith(bv,[bv])}}while(by--){if((bx=b.data(bv[by],bz,L,true)||(b.data(bv[by],bA,L,true)||b.data(bv[by],bC,L,true))&&b.data(bv[by],bz,b.Callbacks("once memory"),true))){bB++;bx.add(bE)}}bE();return e.promise()}});var aP=/[\n\t\r]/g,af=/\s+/,aU=/\r/g,g=/^(?:button|input)$/i,D=/^(?:button|input|object|select|textarea)$/i,l=/^a(?:rea)?$/i,ao=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,F=b.support.getSetAttribute,be,aY,aF;b.fn.extend({attr:function(e,bv){return b.access(this,e,bv,true,b.attr)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,bv){return b.access(this,e,bv,true,b.prop)},removeProp:function(e){e=b.propFix[e]||e;return this.each(function(){try{this[e]=L;delete this[e]}catch(bv){}})},addClass:function(by){var bA,bw,bv,bx,bz,bB,e;if(b.isFunction(by)){return this.each(function(bC){b(this).addClass(by.call(this,bC,this.className))})}if(by&&typeof by==="string"){bA=by.split(af);for(bw=0,bv=this.length;bw<bv;bw++){bx=this[bw];if(bx.nodeType===1){if(!bx.className&&bA.length===1){bx.className=by}else{bz=" "+bx.className+" ";for(bB=0,e=bA.length;bB<e;bB++){if(!~bz.indexOf(" "+bA[bB]+" ")){bz+=bA[bB]+" "}}bx.className=b.trim(bz)}}}}return this},removeClass:function(bz){var bA,bw,bv,by,bx,bB,e;if(b.isFunction(bz)){return this.each(function(bC){b(this).removeClass(bz.call(this,bC,this.className))})}if((bz&&typeof bz==="string")||bz===L){bA=(bz||"").split(af);for(bw=0,bv=this.length;bw<bv;bw++){by=this[bw];if(by.nodeType===1&&by.className){if(bz){bx=(" "+by.className+" ").replace(aP," ");for(bB=0,e=bA.length;bB<e;bB++){bx=bx.replace(" "+bA[bB]+" "," ")}by.className=b.trim(bx)}else{by.className=""}}}}return this},toggleClass:function(bx,bv){var bw=typeof bx,e=typeof bv==="boolean";if(b.isFunction(bx)){return this.each(function(by){b(this).toggleClass(bx.call(this,by,this.className,bv),bv)})}return this.each(function(){if(bw==="string"){var bA,bz=0,by=b(this),bB=bv,bC=bx.split(af);while((bA=bC[bz++])){bB=e?bB:!by.hasClass(bA);by[bB?"addClass":"removeClass"](bA)}}else{if(bw==="undefined"||bw==="boolean"){if(this.className){b._data(this,"__className__",this.className)}this.className=this.className||bx===false?"":b._data(this,"__className__")||""}}})},hasClass:function(e){var bx=" "+e+" ",bw=0,bv=this.length;for(;bw<bv;bw++){if(this[bw].nodeType===1&&(" "+this[bw].className+" ").replace(aP," ").indexOf(bx)>-1){return true}}return false},val:function(bx){var e,bv,by,bw=this[0];if(!arguments.length){if(bw){e=b.valHooks[bw.nodeName.toLowerCase()]||b.valHooks[bw.type];if(e&&"get" in e&&(bv=e.get(bw,"value"))!==L){return bv}bv=bw.value;return typeof bv==="string"?bv.replace(aU,""):bv==null?"":bv}return}by=b.isFunction(bx);return this.each(function(bA){var bz=b(this),bB;if(this.nodeType!==1){return}if(by){bB=bx.call(this,bA,bz.val())}else{bB=bx}if(bB==null){bB=""}else{if(typeof bB==="number"){bB+=""}else{if(b.isArray(bB)){bB=b.map(bB,function(bC){return bC==null?"":bC+""})}}}e=b.valHooks[this.nodeName.toLowerCase()]||b.valHooks[this.type];if(!e||!("set" in e)||e.set(this,bB,"value")===L){this.value=bB}})}});b.extend({valHooks:{option:{get:function(e){var bv=e.attributes.value;return !bv||bv.specified?e.value:e.text}},select:{get:function(e){var bA,bv,bz,bx,by=e.selectedIndex,bB=[],bC=e.options,bw=e.type==="select-one";if(by<0){return null}bv=bw?by:0;bz=bw?by+1:bC.length;for(;bv<bz;bv++){bx=bC[bv];if(bx.selected&&(b.support.optDisabled?!bx.disabled:bx.getAttribute("disabled")===null)&&(!bx.parentNode.disabled||!b.nodeName(bx.parentNode,"optgroup"))){bA=b(bx).val();if(bw){return bA}bB.push(bA)}}if(bw&&!bB.length&&bC.length){return b(bC[by]).val()}return bB},set:function(bv,bw){var e=b.makeArray(bw);b(bv).find("option").each(function(){this.selected=b.inArray(b(this).val(),e)>=0});if(!e.length){bv.selectedIndex=-1}return e}}},attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(bA,bx,bB,bz){var bw,e,by,bv=bA.nodeType; +if(!bA||bv===3||bv===8||bv===2){return}if(bz&&bx in b.attrFn){return b(bA)[bx](bB)}if(typeof bA.getAttribute==="undefined"){return b.prop(bA,bx,bB)}by=bv!==1||!b.isXMLDoc(bA);if(by){bx=bx.toLowerCase();e=b.attrHooks[bx]||(ao.test(bx)?aY:be)}if(bB!==L){if(bB===null){b.removeAttr(bA,bx);return}else{if(e&&"set" in e&&by&&(bw=e.set(bA,bB,bx))!==L){return bw}else{bA.setAttribute(bx,""+bB);return bB}}}else{if(e&&"get" in e&&by&&(bw=e.get(bA,bx))!==null){return bw}else{bw=bA.getAttribute(bx);return bw===null?L:bw}}},removeAttr:function(bx,bz){var by,bA,bv,e,bw=0;if(bz&&bx.nodeType===1){bA=bz.toLowerCase().split(af);e=bA.length;for(;bw<e;bw++){bv=bA[bw];if(bv){by=b.propFix[bv]||bv;b.attr(bx,bv,"");bx.removeAttribute(F?bv:by);if(ao.test(bv)&&by in bx){bx[by]=false}}}}},attrHooks:{type:{set:function(e,bv){if(g.test(e.nodeName)&&e.parentNode){b.error("type property can't be changed")}else{if(!b.support.radioValue&&bv==="radio"&&b.nodeName(e,"input")){var bw=e.value;e.setAttribute("type",bv);if(bw){e.value=bw}return bv}}}},value:{get:function(bv,e){if(be&&b.nodeName(bv,"button")){return be.get(bv,e)}return e in bv?bv.value:null},set:function(bv,bw,e){if(be&&b.nodeName(bv,"button")){return be.set(bv,bw,e)}bv.value=bw}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(bz,bx,bA){var bw,e,by,bv=bz.nodeType;if(!bz||bv===3||bv===8||bv===2){return}by=bv!==1||!b.isXMLDoc(bz);if(by){bx=b.propFix[bx]||bx;e=b.propHooks[bx]}if(bA!==L){if(e&&"set" in e&&(bw=e.set(bz,bA,bx))!==L){return bw}else{return(bz[bx]=bA)}}else{if(e&&"get" in e&&(bw=e.get(bz,bx))!==null){return bw}else{return bz[bx]}}},propHooks:{tabIndex:{get:function(bv){var e=bv.getAttributeNode("tabindex");return e&&e.specified?parseInt(e.value,10):D.test(bv.nodeName)||l.test(bv.nodeName)&&bv.href?0:L}}}});b.attrHooks.tabindex=b.propHooks.tabIndex;aY={get:function(bv,e){var bx,bw=b.prop(bv,e);return bw===true||typeof bw!=="boolean"&&(bx=bv.getAttributeNode(e))&&bx.nodeValue!==false?e.toLowerCase():L},set:function(bv,bx,e){var bw;if(bx===false){b.removeAttr(bv,e)}else{bw=b.propFix[e]||e;if(bw in bv){bv[bw]=true}bv.setAttribute(e,e.toLowerCase())}return e}};if(!F){aF={name:true,id:true};be=b.valHooks.button={get:function(bw,bv){var e;e=bw.getAttributeNode(bv);return e&&(aF[bv]?e.nodeValue!=="":e.specified)?e.nodeValue:L},set:function(bw,bx,bv){var e=bw.getAttributeNode(bv);if(!e){e=av.createAttribute(bv);bw.setAttributeNode(e)}return(e.nodeValue=bx+"")}};b.attrHooks.tabindex.set=be.set;b.each(["width","height"],function(bv,e){b.attrHooks[e]=b.extend(b.attrHooks[e],{set:function(bw,bx){if(bx===""){bw.setAttribute(e,"auto");return bx}}})});b.attrHooks.contenteditable={get:be.get,set:function(bv,bw,e){if(bw===""){bw="false"}be.set(bv,bw,e)}}}if(!b.support.hrefNormalized){b.each(["href","src","width","height"],function(bv,e){b.attrHooks[e]=b.extend(b.attrHooks[e],{get:function(bx){var bw=bx.getAttribute(e,2);return bw===null?L:bw}})})}if(!b.support.style){b.attrHooks.style={get:function(e){return e.style.cssText.toLowerCase()||L},set:function(e,bv){return(e.style.cssText=""+bv)}}}if(!b.support.optSelected){b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(bv){var e=bv.parentNode;if(e){e.selectedIndex;if(e.parentNode){e.parentNode.selectedIndex}}return null}})}if(!b.support.enctype){b.propFix.enctype="encoding"}if(!b.support.checkOn){b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return e.getAttribute("value")===null?"on":e.value}}})}b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,bv){if(b.isArray(bv)){return(e.checked=b.inArray(b(e).val(),bv)>=0)}}})});var bd=/^(?:textarea|input|select)$/i,n=/^([^\.]*)?(?:\.(.+))?$/,J=/\bhover(\.\S+)?\b/,aO=/^key/,bf=/^(?:mouse|contextmenu)|click/,T=/^(?:focusinfocus|focusoutblur)$/,U=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,Y=function(e){var bv=U.exec(e);if(bv){bv[1]=(bv[1]||"").toLowerCase();bv[3]=bv[3]&&new RegExp("(?:^|\\s)"+bv[3]+"(?:\\s|$)")}return bv},j=function(bw,e){var bv=bw.attributes||{};return((!e[1]||bw.nodeName.toLowerCase()===e[1])&&(!e[2]||(bv.id||{}).value===e[2])&&(!e[3]||e[3].test((bv["class"]||{}).value)))},bt=function(e){return b.event.special.hover?e:e.replace(J,"mouseenter$1 mouseleave$1")};b.event={add:function(bx,bC,bJ,bA,by){var bD,bB,bK,bI,bH,bF,e,bG,bv,bz,bw,bE;if(bx.nodeType===3||bx.nodeType===8||!bC||!bJ||!(bD=b._data(bx))){return}if(bJ.handler){bv=bJ;bJ=bv.handler}if(!bJ.guid){bJ.guid=b.guid++}bK=bD.events;if(!bK){bD.events=bK={}}bB=bD.handle;if(!bB){bD.handle=bB=function(bL){return typeof b!=="undefined"&&(!bL||b.event.triggered!==bL.type)?b.event.dispatch.apply(bB.elem,arguments):L};bB.elem=bx}bC=b.trim(bt(bC)).split(" ");for(bI=0;bI<bC.length;bI++){bH=n.exec(bC[bI])||[];bF=bH[1];e=(bH[2]||"").split(".").sort();bE=b.event.special[bF]||{};bF=(by?bE.delegateType:bE.bindType)||bF;bE=b.event.special[bF]||{};bG=b.extend({type:bF,origType:bH[1],data:bA,handler:bJ,guid:bJ.guid,selector:by,quick:Y(by),namespace:e.join(".")},bv);bw=bK[bF];if(!bw){bw=bK[bF]=[];bw.delegateCount=0;if(!bE.setup||bE.setup.call(bx,bA,e,bB)===false){if(bx.addEventListener){bx.addEventListener(bF,bB,false)}else{if(bx.attachEvent){bx.attachEvent("on"+bF,bB)}}}}if(bE.add){bE.add.call(bx,bG);if(!bG.handler.guid){bG.handler.guid=bJ.guid}}if(by){bw.splice(bw.delegateCount++,0,bG)}else{bw.push(bG)}b.event.global[bF]=true}bx=null},global:{},remove:function(bJ,bE,bv,bH,bB){var bI=b.hasData(bJ)&&b._data(bJ),bF,bx,bz,bL,bC,bA,bG,bw,by,bK,bD,e;if(!bI||!(bw=bI.events)){return}bE=b.trim(bt(bE||"")).split(" ");for(bF=0;bF<bE.length;bF++){bx=n.exec(bE[bF])||[];bz=bL=bx[1];bC=bx[2];if(!bz){for(bz in bw){b.event.remove(bJ,bz+bE[bF],bv,bH,true)}continue}by=b.event.special[bz]||{};bz=(bH?by.delegateType:by.bindType)||bz;bD=bw[bz]||[];bA=bD.length;bC=bC?new RegExp("(^|\\.)"+bC.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(bG=0;bG<bD.length;bG++){e=bD[bG];if((bB||bL===e.origType)&&(!bv||bv.guid===e.guid)&&(!bC||bC.test(e.namespace))&&(!bH||bH===e.selector||bH==="**"&&e.selector)){bD.splice(bG--,1);if(e.selector){bD.delegateCount--}if(by.remove){by.remove.call(bJ,e)}}}if(bD.length===0&&bA!==bD.length){if(!by.teardown||by.teardown.call(bJ,bC)===false){b.removeEvent(bJ,bz,bI.handle)}delete bw[bz]}}if(b.isEmptyObject(bw)){bK=bI.handle;if(bK){bK.elem=null}b.removeData(bJ,["events","handle"],true)}},customEvent:{getData:true,setData:true,changeData:true},trigger:function(bv,bD,bA,bJ){if(bA&&(bA.nodeType===3||bA.nodeType===8)){return}var bG=bv.type||bv,bx=[],e,bw,bC,bH,bz,by,bF,bE,bB,bI;if(T.test(bG+b.event.triggered)){return}if(bG.indexOf("!")>=0){bG=bG.slice(0,-1);bw=true}if(bG.indexOf(".")>=0){bx=bG.split(".");bG=bx.shift();bx.sort()}if((!bA||b.event.customEvent[bG])&&!b.event.global[bG]){return}bv=typeof bv==="object"?bv[b.expando]?bv:new b.Event(bG,bv):new b.Event(bG);bv.type=bG;bv.isTrigger=true;bv.exclusive=bw;bv.namespace=bx.join(".");bv.namespace_re=bv.namespace?new RegExp("(^|\\.)"+bx.join("\\.(?:.*\\.)?")+"(\\.|$)"):null;by=bG.indexOf(":")<0?"on"+bG:"";if(!bA){e=b.cache;for(bC in e){if(e[bC].events&&e[bC].events[bG]){b.event.trigger(bv,bD,e[bC].handle.elem,true)}}return}bv.result=L;if(!bv.target){bv.target=bA}bD=bD!=null?b.makeArray(bD):[];bD.unshift(bv);bF=b.event.special[bG]||{};if(bF.trigger&&bF.trigger.apply(bA,bD)===false){return}bB=[[bA,bF.bindType||bG]];if(!bJ&&!bF.noBubble&&!b.isWindow(bA)){bI=bF.delegateType||bG;bH=T.test(bI+bG)?bA:bA.parentNode;bz=null;for(;bH;bH=bH.parentNode){bB.push([bH,bI]);bz=bH}if(bz&&bz===bA.ownerDocument){bB.push([bz.defaultView||bz.parentWindow||bb,bI])}}for(bC=0;bC<bB.length&&!bv.isPropagationStopped();bC++){bH=bB[bC][0];bv.type=bB[bC][1];bE=(b._data(bH,"events")||{})[bv.type]&&b._data(bH,"handle");if(bE){bE.apply(bH,bD)}bE=by&&bH[by];if(bE&&b.acceptData(bH)&&bE.apply(bH,bD)===false){bv.preventDefault()}}bv.type=bG;if(!bJ&&!bv.isDefaultPrevented()){if((!bF._default||bF._default.apply(bA.ownerDocument,bD)===false)&&!(bG==="click"&&b.nodeName(bA,"a"))&&b.acceptData(bA)){if(by&&bA[bG]&&((bG!=="focus"&&bG!=="blur")||bv.target.offsetWidth!==0)&&!b.isWindow(bA)){bz=bA[by];if(bz){bA[by]=null}b.event.triggered=bG;bA[bG]();b.event.triggered=L;if(bz){bA[by]=bz}}}}return bv.result},dispatch:function(e){e=b.event.fix(e||bb.event);var bz=((b._data(this,"events")||{})[e.type]||[]),bA=bz.delegateCount,bG=[].slice.call(arguments,0),by=!e.exclusive&&!e.namespace,bH=[],bC,bB,bK,bx,bF,bE,bv,bD,bI,bw,bJ;bG[0]=e;e.delegateTarget=this;if(bA&&!e.target.disabled&&!(e.button&&e.type==="click")){bx=b(this);bx.context=this.ownerDocument||this;for(bK=e.target;bK!=this;bK=bK.parentNode||this){bE={};bD=[];bx[0]=bK;for(bC=0;bC<bA;bC++){bI=bz[bC];bw=bI.selector;if(bE[bw]===L){bE[bw]=(bI.quick?j(bK,bI.quick):bx.is(bw))}if(bE[bw]){bD.push(bI)}}if(bD.length){bH.push({elem:bK,matches:bD})}}}if(bz.length>bA){bH.push({elem:this,matches:bz.slice(bA)})}for(bC=0;bC<bH.length&&!e.isPropagationStopped();bC++){bv=bH[bC];e.currentTarget=bv.elem;for(bB=0;bB<bv.matches.length&&!e.isImmediatePropagationStopped();bB++){bI=bv.matches[bB];if(by||(!e.namespace&&!bI.namespace)||e.namespace_re&&e.namespace_re.test(bI.namespace)){e.data=bI.data;e.handleObj=bI;bF=((b.event.special[bI.origType]||{}).handle||bI.handler).apply(bv.elem,bG);if(bF!==L){e.result=bF;if(bF===false){e.preventDefault();e.stopPropagation()}}}}}return e.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(bv,e){if(bv.which==null){bv.which=e.charCode!=null?e.charCode:e.keyCode}return bv}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(bx,bw){var by,bz,e,bv=bw.button,bA=bw.fromElement;if(bx.pageX==null&&bw.clientX!=null){by=bx.target.ownerDocument||av;bz=by.documentElement;e=by.body;bx.pageX=bw.clientX+(bz&&bz.scrollLeft||e&&e.scrollLeft||0)-(bz&&bz.clientLeft||e&&e.clientLeft||0);bx.pageY=bw.clientY+(bz&&bz.scrollTop||e&&e.scrollTop||0)-(bz&&bz.clientTop||e&&e.clientTop||0)}if(!bx.relatedTarget&&bA){bx.relatedTarget=bA===bx.target?bw.toElement:bA}if(!bx.which&&bv!==L){bx.which=(bv&1?1:(bv&2?3:(bv&4?2:0)))}return bx}},fix:function(bw){if(bw[b.expando]){return bw}var bv,bz,e=bw,bx=b.event.fixHooks[bw.type]||{},by=bx.props?this.props.concat(bx.props):this.props;bw=b.Event(e);for(bv=by.length;bv;){bz=by[--bv];bw[bz]=e[bz]}if(!bw.target){bw.target=e.srcElement||av}if(bw.target.nodeType===3){bw.target=bw.target.parentNode}if(bw.metaKey===L){bw.metaKey=bw.ctrlKey}return bx.filter?bx.filter(bw,e):bw},special:{ready:{setup:b.bindReady},load:{noBubble:true},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(bw,bv,e){if(b.isWindow(this)){this.onbeforeunload=e}},teardown:function(bv,e){if(this.onbeforeunload===e){this.onbeforeunload=null}}}},simulate:function(bw,by,bx,bv){var bz=b.extend(new b.Event(),bx,{type:bw,isSimulated:true,originalEvent:{}});if(bv){b.event.trigger(bz,null,by)}else{b.event.dispatch.call(by,bz)}if(bz.isDefaultPrevented()){bx.preventDefault()}}};b.event.handle=b.event.dispatch;b.removeEvent=av.removeEventListener?function(bv,e,bw){if(bv.removeEventListener){bv.removeEventListener(e,bw,false)}}:function(bv,e,bw){if(bv.detachEvent){bv.detachEvent("on"+e,bw)}};b.Event=function(bv,e){if(!(this instanceof b.Event)){return new b.Event(bv,e)}if(bv&&bv.type){this.originalEvent=bv;this.type=bv.type;this.isDefaultPrevented=(bv.defaultPrevented||bv.returnValue===false||bv.getPreventDefault&&bv.getPreventDefault())?i:bk}else{this.type=bv}if(e){b.extend(this,e)}this.timeStamp=bv&&bv.timeStamp||b.now();this[b.expando]=true};function bk(){return false}function i(){return true}b.Event.prototype={preventDefault:function(){this.isDefaultPrevented=i;var bv=this.originalEvent;if(!bv){return}if(bv.preventDefault){bv.preventDefault()}else{bv.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=i;var bv=this.originalEvent;if(!bv){return}if(bv.stopPropagation){bv.stopPropagation()}bv.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=i;this.stopPropagation()},isDefaultPrevented:bk,isPropagationStopped:bk,isImmediatePropagationStopped:bk};b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(bv,e){b.event.special[bv]={delegateType:e,bindType:e,handle:function(bz){var bB=this,bA=bz.relatedTarget,by=bz.handleObj,bw=by.selector,bx;if(!bA||(bA!==bB&&!b.contains(bB,bA))){bz.type=by.origType;bx=by.handler.apply(this,arguments);bz.type=e}return bx}}});if(!b.support.submitBubbles){b.event.special.submit={setup:function(){if(b.nodeName(this,"form")){return false +}b.event.add(this,"click._submit keypress._submit",function(bx){var bw=bx.target,bv=b.nodeName(bw,"input")||b.nodeName(bw,"button")?bw.form:L;if(bv&&!bv._submit_attached){b.event.add(bv,"submit._submit",function(e){if(this.parentNode&&!e.isTrigger){b.event.simulate("submit",this.parentNode,e,true)}});bv._submit_attached=true}})},teardown:function(){if(b.nodeName(this,"form")){return false}b.event.remove(this,"._submit")}}}if(!b.support.changeBubbles){b.event.special.change={setup:function(){if(bd.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio"){b.event.add(this,"propertychange._change",function(e){if(e.originalEvent.propertyName==="checked"){this._just_changed=true}});b.event.add(this,"click._change",function(e){if(this._just_changed&&!e.isTrigger){this._just_changed=false;b.event.simulate("change",this,e,true)}})}return false}b.event.add(this,"beforeactivate._change",function(bw){var bv=bw.target;if(bd.test(bv.nodeName)&&!bv._change_attached){b.event.add(bv,"change._change",function(e){if(this.parentNode&&!e.isSimulated&&!e.isTrigger){b.event.simulate("change",this.parentNode,e,true)}});bv._change_attached=true}})},handle:function(bv){var e=bv.target;if(this!==e||bv.isSimulated||bv.isTrigger||(e.type!=="radio"&&e.type!=="checkbox")){return bv.handleObj.handler.apply(this,arguments)}},teardown:function(){b.event.remove(this,"._change");return bd.test(this.nodeName)}}}if(!b.support.focusinBubbles){b.each({focus:"focusin",blur:"focusout"},function(bx,e){var bv=0,bw=function(by){b.event.simulate(e,by.target,b.event.fix(by),true)};b.event.special[e]={setup:function(){if(bv++===0){av.addEventListener(bx,bw,true)}},teardown:function(){if(--bv===0){av.removeEventListener(bx,bw,true)}}}})}b.fn.extend({on:function(bw,e,bz,by,bv){var bA,bx;if(typeof bw==="object"){if(typeof e!=="string"){bz=e;e=L}for(bx in bw){this.on(bx,e,bz,bw[bx],bv)}return this}if(bz==null&&by==null){by=e;bz=e=L}else{if(by==null){if(typeof e==="string"){by=bz;bz=L}else{by=bz;bz=e;e=L}}}if(by===false){by=bk}else{if(!by){return this}}if(bv===1){bA=by;by=function(bB){b().off(bB);return bA.apply(this,arguments)};by.guid=bA.guid||(bA.guid=b.guid++)}return this.each(function(){b.event.add(this,bw,by,bz,e)})},one:function(bv,e,bx,bw){return this.on.call(this,bv,e,bx,bw,1)},off:function(bw,e,by){if(bw&&bw.preventDefault&&bw.handleObj){var bv=bw.handleObj;b(bw.delegateTarget).off(bv.namespace?bv.type+"."+bv.namespace:bv.type,bv.selector,bv.handler);return this}if(typeof bw==="object"){for(var bx in bw){this.off(bx,e,bw[bx])}return this}if(e===false||typeof e==="function"){by=e;e=L}if(by===false){by=bk}return this.each(function(){b.event.remove(this,bw,by,e)})},bind:function(e,bw,bv){return this.on(e,null,bw,bv)},unbind:function(e,bv){return this.off(e,null,bv)},live:function(e,bw,bv){b(this.context).on(e,this.selector,bw,bv);return this},die:function(e,bv){b(this.context).off(e,this.selector||"**",bv);return this},delegate:function(e,bv,bx,bw){return this.on(bv,e,bx,bw)},undelegate:function(e,bv,bw){return arguments.length==1?this.off(e,"**"):this.off(bv,e,bw)},trigger:function(e,bv){return this.each(function(){b.event.trigger(e,bv,this)})},triggerHandler:function(e,bv){if(this[0]){return b.event.trigger(e,bv,this[0],true)}},toggle:function(bx){var bv=arguments,e=bx.guid||b.guid++,bw=0,by=function(bz){var bA=(b._data(this,"lastToggle"+bx.guid)||0)%bw;b._data(this,"lastToggle"+bx.guid,bA+1);bz.preventDefault();return bv[bA].apply(this,arguments)||false};by.guid=e;while(bw<bv.length){bv[bw++].guid=e}return this.click(by)},hover:function(e,bv){return this.mouseenter(e).mouseleave(bv||e)}});b.each(("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu").split(" "),function(bv,e){b.fn[e]=function(bx,bw){if(bw==null){bw=bx;bx=null}return arguments.length>0?this.on(e,null,bx,bw):this.trigger(e)};if(b.attrFn){b.attrFn[e]=true}if(aO.test(e)){b.event.fixHooks[e]=b.event.keyHooks}if(bf.test(e)){b.event.fixHooks[e]=b.event.mouseHooks}}); +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){var bH=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,bC="sizcache"+(Math.random()+"").replace(".",""),bI=0,bL=Object.prototype.toString,bB=false,bA=true,bK=/\\/g,bO=/\r\n/g,bQ=/\W/;[0,0].sort(function(){bA=false;return 0});var by=function(bV,e,bY,bZ){bY=bY||[];e=e||av;var b1=e;if(e.nodeType!==1&&e.nodeType!==9){return[]}if(!bV||typeof bV!=="string"){return bY}var bS,b3,b6,bR,b2,b5,b4,bX,bU=true,bT=by.isXML(e),bW=[],b0=bV;do{bH.exec("");bS=bH.exec(b0);if(bS){b0=bS[3];bW.push(bS[1]);if(bS[2]){bR=bS[3];break}}}while(bS);if(bW.length>1&&bD.exec(bV)){if(bW.length===2&&bE.relative[bW[0]]){b3=bM(bW[0]+bW[1],e,bZ)}else{b3=bE.relative[bW[0]]?[e]:by(bW.shift(),e);while(bW.length){bV=bW.shift();if(bE.relative[bV]){bV+=bW.shift()}b3=bM(bV,b3,bZ)}}}else{if(!bZ&&bW.length>1&&e.nodeType===9&&!bT&&bE.match.ID.test(bW[0])&&!bE.match.ID.test(bW[bW.length-1])){b2=by.find(bW.shift(),e,bT);e=b2.expr?by.filter(b2.expr,b2.set)[0]:b2.set[0]}if(e){b2=bZ?{expr:bW.pop(),set:bF(bZ)}:by.find(bW.pop(),bW.length===1&&(bW[0]==="~"||bW[0]==="+")&&e.parentNode?e.parentNode:e,bT);b3=b2.expr?by.filter(b2.expr,b2.set):b2.set;if(bW.length>0){b6=bF(b3)}else{bU=false}while(bW.length){b5=bW.pop();b4=b5;if(!bE.relative[b5]){b5=""}else{b4=bW.pop()}if(b4==null){b4=e}bE.relative[b5](b6,b4,bT)}}else{b6=bW=[]}}if(!b6){b6=b3}if(!b6){by.error(b5||bV)}if(bL.call(b6)==="[object Array]"){if(!bU){bY.push.apply(bY,b6)}else{if(e&&e.nodeType===1){for(bX=0;b6[bX]!=null;bX++){if(b6[bX]&&(b6[bX]===true||b6[bX].nodeType===1&&by.contains(e,b6[bX]))){bY.push(b3[bX])}}}else{for(bX=0;b6[bX]!=null;bX++){if(b6[bX]&&b6[bX].nodeType===1){bY.push(b3[bX])}}}}}else{bF(b6,bY)}if(bR){by(bR,b1,bY,bZ);by.uniqueSort(bY)}return bY};by.uniqueSort=function(bR){if(bJ){bB=bA;bR.sort(bJ);if(bB){for(var e=1;e<bR.length;e++){if(bR[e]===bR[e-1]){bR.splice(e--,1)}}}}return bR};by.matches=function(e,bR){return by(e,null,null,bR)};by.matchesSelector=function(e,bR){return by(bR,null,null,[e]).length>0};by.find=function(bX,e,bY){var bW,bS,bU,bT,bV,bR;if(!bX){return[]}for(bS=0,bU=bE.order.length;bS<bU;bS++){bV=bE.order[bS];if((bT=bE.leftMatch[bV].exec(bX))){bR=bT[1];bT.splice(1,1);if(bR.substr(bR.length-1)!=="\\"){bT[1]=(bT[1]||"").replace(bK,"");bW=bE.find[bV](bT,e,bY);if(bW!=null){bX=bX.replace(bE.match[bV],"");break}}}}if(!bW){bW=typeof e.getElementsByTagName!=="undefined"?e.getElementsByTagName("*"):[]}return{set:bW,expr:bX}};by.filter=function(b1,b0,b4,bU){var bW,e,bZ,b6,b3,bR,bT,bV,b2,bS=b1,b5=[],bY=b0,bX=b0&&b0[0]&&by.isXML(b0[0]);while(b1&&b0.length){for(bZ in bE.filter){if((bW=bE.leftMatch[bZ].exec(b1))!=null&&bW[2]){bR=bE.filter[bZ];bT=bW[1];e=false;bW.splice(1,1);if(bT.substr(bT.length-1)==="\\"){continue}if(bY===b5){b5=[]}if(bE.preFilter[bZ]){bW=bE.preFilter[bZ](bW,bY,b4,b5,bU,bX);if(!bW){e=b6=true}else{if(bW===true){continue}}}if(bW){for(bV=0;(b3=bY[bV])!=null;bV++){if(b3){b6=bR(b3,bW,bV,bY);b2=bU^b6;if(b4&&b6!=null){if(b2){e=true}else{bY[bV]=false}}else{if(b2){b5.push(b3);e=true}}}}}if(b6!==L){if(!b4){bY=b5}b1=b1.replace(bE.match[bZ],"");if(!e){return[]}break}}}if(b1===bS){if(e==null){by.error(b1)}else{break}}bS=b1}return bY};by.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)};var bw=by.getText=function(bU){var bS,bT,e=bU.nodeType,bR="";if(e){if(e===1||e===9){if(typeof bU.textContent==="string"){return bU.textContent}else{if(typeof bU.innerText==="string"){return bU.innerText.replace(bO,"")}else{for(bU=bU.firstChild;bU;bU=bU.nextSibling){bR+=bw(bU)}}}}else{if(e===3||e===4){return bU.nodeValue}}}else{for(bS=0;(bT=bU[bS]);bS++){if(bT.nodeType!==8){bR+=bw(bT)}}}return bR};var bE=by.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")},type:function(e){return e.getAttribute("type")}},relative:{"+":function(bW,bR){var bT=typeof bR==="string",bV=bT&&!bQ.test(bR),bX=bT&&!bV;if(bV){bR=bR.toLowerCase()}for(var bS=0,e=bW.length,bU;bS<e;bS++){if((bU=bW[bS])){while((bU=bU.previousSibling)&&bU.nodeType!==1){}bW[bS]=bX||bU&&bU.nodeName.toLowerCase()===bR?bU||false:bU===bR}}if(bX){by.filter(bR,bW,true)}},">":function(bW,bR){var bV,bU=typeof bR==="string",bS=0,e=bW.length;if(bU&&!bQ.test(bR)){bR=bR.toLowerCase();for(;bS<e;bS++){bV=bW[bS];if(bV){var bT=bV.parentNode;bW[bS]=bT.nodeName.toLowerCase()===bR?bT:false}}}else{for(;bS<e;bS++){bV=bW[bS];if(bV){bW[bS]=bU?bV.parentNode:bV.parentNode===bR}}if(bU){by.filter(bR,bW,true)}}},"":function(bT,bR,bV){var bU,bS=bI++,e=bN;if(typeof bR==="string"&&!bQ.test(bR)){bR=bR.toLowerCase();bU=bR;e=bv}e("parentNode",bR,bS,bT,bU,bV)},"~":function(bT,bR,bV){var bU,bS=bI++,e=bN;if(typeof bR==="string"&&!bQ.test(bR)){bR=bR.toLowerCase();bU=bR;e=bv}e("previousSibling",bR,bS,bT,bU,bV)}},find:{ID:function(bR,bS,bT){if(typeof bS.getElementById!=="undefined"&&!bT){var e=bS.getElementById(bR[1]);return e&&e.parentNode?[e]:[]}},NAME:function(bS,bV){if(typeof bV.getElementsByName!=="undefined"){var bR=[],bU=bV.getElementsByName(bS[1]);for(var bT=0,e=bU.length;bT<e;bT++){if(bU[bT].getAttribute("name")===bS[1]){bR.push(bU[bT])}}return bR.length===0?null:bR}},TAG:function(e,bR){if(typeof bR.getElementsByTagName!=="undefined"){return bR.getElementsByTagName(e[1])}}},preFilter:{CLASS:function(bT,bR,bS,e,bW,bX){bT=" "+bT[1].replace(bK,"")+" ";if(bX){return bT}for(var bU=0,bV;(bV=bR[bU])!=null;bU++){if(bV){if(bW^(bV.className&&(" "+bV.className+" ").replace(/[\t\n\r]/g," ").indexOf(bT)>=0)){if(!bS){e.push(bV)}}else{if(bS){bR[bU]=false}}}}return false},ID:function(e){return e[1].replace(bK,"")},TAG:function(bR,e){return bR[1].replace(bK,"").toLowerCase()},CHILD:function(e){if(e[1]==="nth"){if(!e[2]){by.error(e[0])}e[2]=e[2].replace(/^\+|\s*/g,"");var bR=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(e[2]==="even"&&"2n"||e[2]==="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(bR[1]+(bR[2]||1))-0;e[3]=bR[3]-0}else{if(e[2]){by.error(e[0])}}e[0]=bI++;return e},ATTR:function(bU,bR,bS,e,bV,bW){var bT=bU[1]=bU[1].replace(bK,"");if(!bW&&bE.attrMap[bT]){bU[1]=bE.attrMap[bT]}bU[4]=(bU[4]||bU[5]||"").replace(bK,"");if(bU[2]==="~="){bU[4]=" "+bU[4]+" "}return bU},PSEUDO:function(bU,bR,bS,e,bV){if(bU[1]==="not"){if((bH.exec(bU[3])||"").length>1||/^\w/.test(bU[3])){bU[3]=by(bU[3],null,null,bR)}else{var bT=by.filter(bU[3],bR,bS,true^bV);if(!bS){e.push.apply(e,bT)}return false}}else{if(bE.match.POS.test(bU[0])||bE.match.CHILD.test(bU[0])){return true}}return bU},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){if(e.parentNode){e.parentNode.selectedIndex}return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(bS,bR,e){return !!by(e[3],bS).length},header:function(e){return(/h\d/i).test(e.nodeName)},text:function(bS){var e=bS.getAttribute("type"),bR=bS.type;return bS.nodeName.toLowerCase()==="input"&&"text"===bR&&(e===bR||e===null)},radio:function(e){return e.nodeName.toLowerCase()==="input"&&"radio"===e.type},checkbox:function(e){return e.nodeName.toLowerCase()==="input"&&"checkbox"===e.type},file:function(e){return e.nodeName.toLowerCase()==="input"&&"file"===e.type},password:function(e){return e.nodeName.toLowerCase()==="input"&&"password"===e.type},submit:function(bR){var e=bR.nodeName.toLowerCase();return(e==="input"||e==="button")&&"submit"===bR.type},image:function(e){return e.nodeName.toLowerCase()==="input"&&"image"===e.type},reset:function(bR){var e=bR.nodeName.toLowerCase();return(e==="input"||e==="button")&&"reset"===bR.type},button:function(bR){var e=bR.nodeName.toLowerCase();return e==="input"&&"button"===bR.type||e==="button"},input:function(e){return(/input|select|textarea|button/i).test(e.nodeName)},focus:function(e){return e===e.ownerDocument.activeElement}},setFilters:{first:function(bR,e){return e===0},last:function(bS,bR,e,bT){return bR===bT.length-1},even:function(bR,e){return e%2===0},odd:function(bR,e){return e%2===1 +},lt:function(bS,bR,e){return bR<e[3]-0},gt:function(bS,bR,e){return bR>e[3]-0},nth:function(bS,bR,e){return e[3]-0===bR},eq:function(bS,bR,e){return e[3]-0===bR}},filter:{PSEUDO:function(bS,bX,bW,bY){var e=bX[1],bR=bE.filters[e];if(bR){return bR(bS,bW,bX,bY)}else{if(e==="contains"){return(bS.textContent||bS.innerText||bw([bS])||"").indexOf(bX[3])>=0}else{if(e==="not"){var bT=bX[3];for(var bV=0,bU=bT.length;bV<bU;bV++){if(bT[bV]===bS){return false}}return true}else{by.error(e)}}}},CHILD:function(bS,bU){var bT,b0,bW,bZ,e,bV,bY,bX=bU[1],bR=bS;switch(bX){case"only":case"first":while((bR=bR.previousSibling)){if(bR.nodeType===1){return false}}if(bX==="first"){return true}bR=bS;case"last":while((bR=bR.nextSibling)){if(bR.nodeType===1){return false}}return true;case"nth":bT=bU[2];b0=bU[3];if(bT===1&&b0===0){return true}bW=bU[0];bZ=bS.parentNode;if(bZ&&(bZ[bC]!==bW||!bS.nodeIndex)){bV=0;for(bR=bZ.firstChild;bR;bR=bR.nextSibling){if(bR.nodeType===1){bR.nodeIndex=++bV}}bZ[bC]=bW}bY=bS.nodeIndex-b0;if(bT===0){return bY===0}else{return(bY%bT===0&&bY/bT>=0)}}},ID:function(bR,e){return bR.nodeType===1&&bR.getAttribute("id")===e},TAG:function(bR,e){return(e==="*"&&bR.nodeType===1)||!!bR.nodeName&&bR.nodeName.toLowerCase()===e},CLASS:function(bR,e){return(" "+(bR.className||bR.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(bV,bT){var bS=bT[1],e=by.attr?by.attr(bV,bS):bE.attrHandle[bS]?bE.attrHandle[bS](bV):bV[bS]!=null?bV[bS]:bV.getAttribute(bS),bW=e+"",bU=bT[2],bR=bT[4];return e==null?bU==="!=":!bU&&by.attr?e!=null:bU==="="?bW===bR:bU==="*="?bW.indexOf(bR)>=0:bU==="~="?(" "+bW+" ").indexOf(bR)>=0:!bR?bW&&e!==false:bU==="!="?bW!==bR:bU==="^="?bW.indexOf(bR)===0:bU==="$="?bW.substr(bW.length-bR.length)===bR:bU==="|="?bW===bR||bW.substr(0,bR.length+1)===bR+"-":false},POS:function(bU,bR,bS,bV){var e=bR[2],bT=bE.setFilters[e];if(bT){return bT(bU,bS,bR,bV)}}}};var bD=bE.match.POS,bx=function(bR,e){return"\\"+(e-0+1)};for(var bz in bE.match){bE.match[bz]=new RegExp(bE.match[bz].source+(/(?![^\[]*\])(?![^\(]*\))/.source));bE.leftMatch[bz]=new RegExp(/(^(?:.|\r|\n)*?)/.source+bE.match[bz].source.replace(/\\(\d+)/g,bx))}var bF=function(bR,e){bR=Array.prototype.slice.call(bR,0);if(e){e.push.apply(e,bR);return e}return bR};try{Array.prototype.slice.call(av.documentElement.childNodes,0)[0].nodeType}catch(bP){bF=function(bU,bT){var bS=0,bR=bT||[];if(bL.call(bU)==="[object Array]"){Array.prototype.push.apply(bR,bU)}else{if(typeof bU.length==="number"){for(var e=bU.length;bS<e;bS++){bR.push(bU[bS])}}else{for(;bU[bS];bS++){bR.push(bU[bS])}}}return bR}}var bJ,bG;if(av.documentElement.compareDocumentPosition){bJ=function(bR,e){if(bR===e){bB=true;return 0}if(!bR.compareDocumentPosition||!e.compareDocumentPosition){return bR.compareDocumentPosition?-1:1}return bR.compareDocumentPosition(e)&4?-1:1}}else{bJ=function(bY,bX){if(bY===bX){bB=true;return 0}else{if(bY.sourceIndex&&bX.sourceIndex){return bY.sourceIndex-bX.sourceIndex}}var bV,bR,bS=[],e=[],bU=bY.parentNode,bW=bX.parentNode,bZ=bU;if(bU===bW){return bG(bY,bX)}else{if(!bU){return -1}else{if(!bW){return 1}}}while(bZ){bS.unshift(bZ);bZ=bZ.parentNode}bZ=bW;while(bZ){e.unshift(bZ);bZ=bZ.parentNode}bV=bS.length;bR=e.length;for(var bT=0;bT<bV&&bT<bR;bT++){if(bS[bT]!==e[bT]){return bG(bS[bT],e[bT])}}return bT===bV?bG(bY,e[bT],-1):bG(bS[bT],bX,1)};bG=function(bR,e,bS){if(bR===e){return bS}var bT=bR.nextSibling;while(bT){if(bT===e){return -1}bT=bT.nextSibling}return 1}}(function(){var bR=av.createElement("div"),bS="script"+(new Date()).getTime(),e=av.documentElement;bR.innerHTML="<a name='"+bS+"'/>";e.insertBefore(bR,e.firstChild);if(av.getElementById(bS)){bE.find.ID=function(bU,bV,bW){if(typeof bV.getElementById!=="undefined"&&!bW){var bT=bV.getElementById(bU[1]);return bT?bT.id===bU[1]||typeof bT.getAttributeNode!=="undefined"&&bT.getAttributeNode("id").nodeValue===bU[1]?[bT]:L:[]}};bE.filter.ID=function(bV,bT){var bU=typeof bV.getAttributeNode!=="undefined"&&bV.getAttributeNode("id");return bV.nodeType===1&&bU&&bU.nodeValue===bT}}e.removeChild(bR);e=bR=null})();(function(){var e=av.createElement("div");e.appendChild(av.createComment(""));if(e.getElementsByTagName("*").length>0){bE.find.TAG=function(bR,bV){var bU=bV.getElementsByTagName(bR[1]);if(bR[1]==="*"){var bT=[];for(var bS=0;bU[bS];bS++){if(bU[bS].nodeType===1){bT.push(bU[bS])}}bU=bT}return bU}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){bE.attrHandle.href=function(bR){return bR.getAttribute("href",2)}}e=null})();if(av.querySelectorAll){(function(){var e=by,bT=av.createElement("div"),bS="__sizzle__";bT.innerHTML="<p class='TEST'></p>";if(bT.querySelectorAll&&bT.querySelectorAll(".TEST").length===0){return}by=function(b4,bV,bZ,b3){bV=bV||av;if(!b3&&!by.isXML(bV)){var b2=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b4);if(b2&&(bV.nodeType===1||bV.nodeType===9)){if(b2[1]){return bF(bV.getElementsByTagName(b4),bZ)}else{if(b2[2]&&bE.find.CLASS&&bV.getElementsByClassName){return bF(bV.getElementsByClassName(b2[2]),bZ)}}}if(bV.nodeType===9){if(b4==="body"&&bV.body){return bF([bV.body],bZ)}else{if(b2&&b2[3]){var bY=bV.getElementById(b2[3]);if(bY&&bY.parentNode){if(bY.id===b2[3]){return bF([bY],bZ)}}else{return bF([],bZ)}}}try{return bF(bV.querySelectorAll(b4),bZ)}catch(b0){}}else{if(bV.nodeType===1&&bV.nodeName.toLowerCase()!=="object"){var bW=bV,bX=bV.getAttribute("id"),bU=bX||bS,b6=bV.parentNode,b5=/^\s*[+~]/.test(b4);if(!bX){bV.setAttribute("id",bU)}else{bU=bU.replace(/'/g,"\\$&")}if(b5&&b6){bV=bV.parentNode}try{if(!b5||b6){return bF(bV.querySelectorAll("[id='"+bU+"'] "+b4),bZ)}}catch(b1){}finally{if(!bX){bW.removeAttribute("id")}}}}}return e(b4,bV,bZ,b3)};for(var bR in e){by[bR]=e[bR]}bT=null})()}(function(){var e=av.documentElement,bS=e.matchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.msMatchesSelector;if(bS){var bU=!bS.call(av.createElement("div"),"div"),bR=false;try{bS.call(av.documentElement,"[test!='']:sizzle")}catch(bT){bR=true}by.matchesSelector=function(bW,bY){bY=bY.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!by.isXML(bW)){try{if(bR||!bE.match.PSEUDO.test(bY)&&!/!=/.test(bY)){var bV=bS.call(bW,bY);if(bV||!bU||bW.document&&bW.document.nodeType!==11){return bV}}}catch(bX){}}return by(bY,null,null,[bW]).length>0}}})();(function(){var e=av.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(!e.getElementsByClassName||e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}bE.order.splice(1,0,"CLASS");bE.find.CLASS=function(bR,bS,bT){if(typeof bS.getElementsByClassName!=="undefined"&&!bT){return bS.getElementsByClassName(bR[1])}};e=null})();function bv(bR,bW,bV,bZ,bX,bY){for(var bT=0,bS=bZ.length;bT<bS;bT++){var e=bZ[bT];if(e){var bU=false;e=e[bR];while(e){if(e[bC]===bV){bU=bZ[e.sizset];break}if(e.nodeType===1&&!bY){e[bC]=bV;e.sizset=bT}if(e.nodeName.toLowerCase()===bW){bU=e;break}e=e[bR]}bZ[bT]=bU}}}function bN(bR,bW,bV,bZ,bX,bY){for(var bT=0,bS=bZ.length;bT<bS;bT++){var e=bZ[bT];if(e){var bU=false;e=e[bR];while(e){if(e[bC]===bV){bU=bZ[e.sizset];break}if(e.nodeType===1){if(!bY){e[bC]=bV;e.sizset=bT}if(typeof bW!=="string"){if(e===bW){bU=true;break}}else{if(by.filter(bW,[e]).length>0){bU=e;break}}}e=e[bR]}bZ[bT]=bU}}}if(av.documentElement.contains){by.contains=function(bR,e){return bR!==e&&(bR.contains?bR.contains(e):true)}}else{if(av.documentElement.compareDocumentPosition){by.contains=function(bR,e){return !!(bR.compareDocumentPosition(e)&16)}}else{by.contains=function(){return false}}}by.isXML=function(e){var bR=(e?e.ownerDocument||e:0).documentElement;return bR?bR.nodeName!=="HTML":false};var bM=function(bS,e,bW){var bV,bX=[],bU="",bY=e.nodeType?[e]:e;while((bV=bE.match.PSEUDO.exec(bS))){bU+=bV[0];bS=bS.replace(bE.match.PSEUDO,"")}bS=bE.relative[bS]?bS+"*":bS;for(var bT=0,bR=bY.length;bT<bR;bT++){by(bS,bY[bT],bX,bW)}return by.filter(bU,bX)};by.attr=b.attr;by.selectors.attrMap={};b.find=by;b.expr=by.selectors;b.expr[":"]=b.expr.filters;b.unique=by.uniqueSort;b.text=by.getText;b.isXMLDoc=by.isXML;b.contains=by.contains})();var ab=/Until$/,aq=/^(?:parents|prevUntil|prevAll)/,a9=/,/,bp=/^.[^:#\[\.,]*$/,P=Array.prototype.slice,H=b.expr.match.POS,ay={children:true,contents:true,next:true,prev:true};b.fn.extend({find:function(e){var bw=this,by,bv;if(typeof e!=="string"){return b(e).filter(function(){for(by=0,bv=bw.length;by<bv;by++){if(b.contains(bw[by],this)){return true}}})}var bx=this.pushStack("","find",e),bA,bB,bz;for(by=0,bv=this.length;by<bv;by++){bA=bx.length;b.find(e,this[by],bx);if(by>0){for(bB=bA;bB<bx.length;bB++){for(bz=0;bz<bA;bz++){if(bx[bz]===bx[bB]){bx.splice(bB--,1);break}}}}}return bx},has:function(bv){var e=b(bv);return this.filter(function(){for(var bx=0,bw=e.length;bx<bw;bx++){if(b.contains(this,e[bx])){return true}}})},not:function(e){return this.pushStack(aG(this,e,false),"not",e)},filter:function(e){return this.pushStack(aG(this,e,true),"filter",e)},is:function(e){return !!e&&(typeof e==="string"?H.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(by,bx){var bv=[],bw,e,bz=this[0];if(b.isArray(by)){var bB=1;while(bz&&bz.ownerDocument&&bz!==bx){for(bw=0;bw<by.length;bw++){if(b(bz).is(by[bw])){bv.push({selector:by[bw],elem:bz,level:bB})}}bz=bz.parentNode;bB++}return bv}var bA=H.test(by)||typeof by!=="string"?b(by,bx||this.context):0;for(bw=0,e=this.length;bw<e;bw++){bz=this[bw];while(bz){if(bA?bA.index(bz)>-1:b.find.matchesSelector(bz,by)){bv.push(bz);break}else{bz=bz.parentNode;if(!bz||!bz.ownerDocument||bz===bx||bz.nodeType===11){break}}}}bv=bv.length>1?b.unique(bv):bv;return this.pushStack(bv,"closest",by)},index:function(e){if(!e){return(this[0]&&this[0].parentNode)?this.prevAll().length:-1}if(typeof e==="string"){return b.inArray(this[0],b(e))}return b.inArray(e.jquery?e[0]:e,this)},add:function(e,bv){var bx=typeof e==="string"?b(e,bv):b.makeArray(e&&e.nodeType?[e]:e),bw=b.merge(this.get(),bx);return this.pushStack(C(bx[0])||C(bw[0])?bw:b.unique(bw))},andSelf:function(){return this.add(this.prevObject)}});function C(e){return !e||!e.parentNode||e.parentNode.nodeType===11}b.each({parent:function(bv){var e=bv.parentNode;return e&&e.nodeType!==11?e:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(bv,e,bw){return b.dir(bv,"parentNode",bw)},next:function(e){return b.nth(e,2,"nextSibling")},prev:function(e){return b.nth(e,2,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(bv,e,bw){return b.dir(bv,"nextSibling",bw)},prevUntil:function(bv,e,bw){return b.dir(bv,"previousSibling",bw)},siblings:function(e){return b.sibling(e.parentNode.firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.makeArray(e.childNodes)}},function(e,bv){b.fn[e]=function(by,bw){var bx=b.map(this,bv,by);if(!ab.test(e)){bw=by}if(bw&&typeof bw==="string"){bx=b.filter(bw,bx)}bx=this.length>1&&!ay[e]?b.unique(bx):bx;if((this.length>1||a9.test(bw))&&aq.test(e)){bx=bx.reverse()}return this.pushStack(bx,e,P.call(arguments).join(","))}});b.extend({filter:function(bw,e,bv){if(bv){bw=":not("+bw+")"}return e.length===1?b.find.matchesSelector(e[0],bw)?[e[0]]:[]:b.find.matches(bw,e)},dir:function(bw,bv,by){var e=[],bx=bw[bv];while(bx&&bx.nodeType!==9&&(by===L||bx.nodeType!==1||!b(bx).is(by))){if(bx.nodeType===1){e.push(bx)}bx=bx[bv]}return e},nth:function(by,e,bw,bx){e=e||1;var bv=0;for(;by;by=by[bw]){if(by.nodeType===1&&++bv===e){break}}return by},sibling:function(bw,bv){var e=[];for(;bw;bw=bw.nextSibling){if(bw.nodeType===1&&bw!==bv){e.push(bw)}}return e}});function aG(bx,bw,e){bw=bw||0;if(b.isFunction(bw)){return b.grep(bx,function(bz,by){var bA=!!bw.call(bz,by,bz);return bA===e})}else{if(bw.nodeType){return b.grep(bx,function(bz,by){return(bz===bw)===e})}else{if(typeof bw==="string"){var bv=b.grep(bx,function(by){return by.nodeType===1});if(bp.test(bw)){return b.filter(bw,bv,!e)}else{bw=b.filter(bw,bv)}}}}return b.grep(bx,function(bz,by){return(b.inArray(bz,bw)>=0)===e})}function a(e){var bw=aR.split("|"),bv=e.createDocumentFragment();if(bv.createElement){while(bw.length){bv.createElement(bw.pop())}}return bv}var aR="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ag=/ jQuery\d+="(?:\d+|null)"/g,ar=/^\s+/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,d=/<([\w:]+)/,w=/<tbody/i,W=/<|&#?\w+;/,ae=/<(?:script|style)/i,O=/<(?:script|object|embed|option|style)/i,ah=new RegExp("<(?:"+aR+")","i"),o=/checked\s*(?:[^=]|=\s*.checked.)/i,bm=/\/(java|ecma)script/i,aN=/^\s*<!(?:\[CDATA\[|\-\-)/,ax={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},ac=a(av); +ax.optgroup=ax.option;ax.tbody=ax.tfoot=ax.colgroup=ax.caption=ax.thead;ax.th=ax.td;if(!b.support.htmlSerialize){ax._default=[1,"div<div>","</div>"]}b.fn.extend({text:function(e){if(b.isFunction(e)){return this.each(function(bw){var bv=b(this);bv.text(e.call(this,bw,bv.text()))})}if(typeof e!=="object"&&e!==L){return this.empty().append((this[0]&&this[0].ownerDocument||av).createTextNode(e))}return b.text(this)},wrapAll:function(e){if(b.isFunction(e)){return this.each(function(bw){b(this).wrapAll(e.call(this,bw))})}if(this[0]){var bv=b(e,this[0].ownerDocument).eq(0).clone(true);if(this[0].parentNode){bv.insertBefore(this[0])}bv.map(function(){var bw=this;while(bw.firstChild&&bw.firstChild.nodeType===1){bw=bw.firstChild}return bw}).append(this)}return this},wrapInner:function(e){if(b.isFunction(e)){return this.each(function(bv){b(this).wrapInner(e.call(this,bv))})}return this.each(function(){var bv=b(this),bw=bv.contents();if(bw.length){bw.wrapAll(e)}else{bv.append(e)}})},wrap:function(e){var bv=b.isFunction(e);return this.each(function(bw){b(this).wrapAll(bv?e.call(this,bw):e)})},unwrap:function(){return this.parent().each(function(){if(!b.nodeName(this,"body")){b(this).replaceWith(this.childNodes)}}).end()},append:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.appendChild(e)}})},prepend:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.insertBefore(e,this.firstChild)}})},before:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bv){this.parentNode.insertBefore(bv,this)})}else{if(arguments.length){var e=b.clean(arguments);e.push.apply(e,this.toArray());return this.pushStack(e,"before",arguments)}}},after:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bv){this.parentNode.insertBefore(bv,this.nextSibling)})}else{if(arguments.length){var e=this.pushStack(this,"after",arguments);e.push.apply(e,b.clean(arguments));return e}}},remove:function(e,bx){for(var bv=0,bw;(bw=this[bv])!=null;bv++){if(!e||b.filter(e,[bw]).length){if(!bx&&bw.nodeType===1){b.cleanData(bw.getElementsByTagName("*"));b.cleanData([bw])}if(bw.parentNode){bw.parentNode.removeChild(bw)}}}return this},empty:function(){for(var e=0,bv;(bv=this[e])!=null;e++){if(bv.nodeType===1){b.cleanData(bv.getElementsByTagName("*"))}while(bv.firstChild){bv.removeChild(bv.firstChild)}}return this},clone:function(bv,e){bv=bv==null?false:bv;e=e==null?bv:e;return this.map(function(){return b.clone(this,bv,e)})},html:function(bx){if(bx===L){return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(ag,""):null}else{if(typeof bx==="string"&&!ae.test(bx)&&(b.support.leadingWhitespace||!ar.test(bx))&&!ax[(d.exec(bx)||["",""])[1].toLowerCase()]){bx=bx.replace(R,"<$1></$2>");try{for(var bw=0,bv=this.length;bw<bv;bw++){if(this[bw].nodeType===1){b.cleanData(this[bw].getElementsByTagName("*"));this[bw].innerHTML=bx}}}catch(by){this.empty().append(bx)}}else{if(b.isFunction(bx)){this.each(function(bz){var e=b(this);e.html(bx.call(this,bz,e.html()))})}else{this.empty().append(bx)}}}return this},replaceWith:function(e){if(this[0]&&this[0].parentNode){if(b.isFunction(e)){return this.each(function(bx){var bw=b(this),bv=bw.html();bw.replaceWith(e.call(this,bx,bv))})}if(typeof e!=="string"){e=b(e).detach()}return this.each(function(){var bw=this.nextSibling,bv=this.parentNode;b(this).remove();if(bw){b(bw).before(e)}else{b(bv).append(e)}})}else{return this.length?this.pushStack(b(b.isFunction(e)?e():e),"replaceWith",e):this}},detach:function(e){return this.remove(e,true)},domManip:function(bB,bF,bE){var bx,by,bA,bD,bC=bB[0],bv=[];if(!b.support.checkClone&&arguments.length===3&&typeof bC==="string"&&o.test(bC)){return this.each(function(){b(this).domManip(bB,bF,bE,true)})}if(b.isFunction(bC)){return this.each(function(bH){var bG=b(this);bB[0]=bC.call(this,bH,bF?bG.html():L);bG.domManip(bB,bF,bE)})}if(this[0]){bD=bC&&bC.parentNode;if(b.support.parentNode&&bD&&bD.nodeType===11&&bD.childNodes.length===this.length){bx={fragment:bD}}else{bx=b.buildFragment(bB,this,bv)}bA=bx.fragment;if(bA.childNodes.length===1){by=bA=bA.firstChild}else{by=bA.firstChild}if(by){bF=bF&&b.nodeName(by,"tr");for(var bw=0,e=this.length,bz=e-1;bw<e;bw++){bE.call(bF?ba(this[bw],by):this[bw],bx.cacheable||(e>1&&bw<bz)?b.clone(bA,true,true):bA)}}if(bv.length){b.each(bv,bo)}}return this}});function ba(e,bv){return b.nodeName(e,"table")?(e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody"))):e}function t(bB,bv){if(bv.nodeType!==1||!b.hasData(bB)){return}var by,bx,e,bA=b._data(bB),bz=b._data(bv,bA),bw=bA.events;if(bw){delete bz.handle;bz.events={};for(by in bw){for(bx=0,e=bw[by].length;bx<e;bx++){b.event.add(bv,by+(bw[by][bx].namespace?".":"")+bw[by][bx].namespace,bw[by][bx],bw[by][bx].data)}}}if(bz.data){bz.data=b.extend({},bz.data)}}function ai(bv,e){var bw;if(e.nodeType!==1){return}if(e.clearAttributes){e.clearAttributes()}if(e.mergeAttributes){e.mergeAttributes(bv)}bw=e.nodeName.toLowerCase();if(bw==="object"){e.outerHTML=bv.outerHTML}else{if(bw==="input"&&(bv.type==="checkbox"||bv.type==="radio")){if(bv.checked){e.defaultChecked=e.checked=bv.checked}if(e.value!==bv.value){e.value=bv.value}}else{if(bw==="option"){e.selected=bv.defaultSelected}else{if(bw==="input"||bw==="textarea"){e.defaultValue=bv.defaultValue}}}}e.removeAttribute(b.expando)}b.buildFragment=function(bz,bx,bv){var by,e,bw,bA,bB=bz[0];if(bx&&bx[0]){bA=bx[0].ownerDocument||bx[0]}if(!bA.createDocumentFragment){bA=av}if(bz.length===1&&typeof bB==="string"&&bB.length<512&&bA===av&&bB.charAt(0)==="<"&&!O.test(bB)&&(b.support.checkClone||!o.test(bB))&&(b.support.html5Clone||!ah.test(bB))){e=true;bw=b.fragments[bB];if(bw&&bw!==1){by=bw}}if(!by){by=bA.createDocumentFragment();b.clean(bz,bA,by,bv)}if(e){b.fragments[bB]=bw?by:1}return{fragment:by,cacheable:e}};b.fragments={};b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,bv){b.fn[e]=function(bw){var bz=[],bC=b(bw),bB=this.length===1&&this[0].parentNode;if(bB&&bB.nodeType===11&&bB.childNodes.length===1&&bC.length===1){bC[bv](this[0]);return this}else{for(var bA=0,bx=bC.length;bA<bx;bA++){var by=(bA>0?this.clone(true):this).get();b(bC[bA])[bv](by);bz=bz.concat(by)}return this.pushStack(bz,e,bC.selector)}}});function bg(e){if(typeof e.getElementsByTagName!=="undefined"){return e.getElementsByTagName("*")}else{if(typeof e.querySelectorAll!=="undefined"){return e.querySelectorAll("*")}else{return[]}}}function az(e){if(e.type==="checkbox"||e.type==="radio"){e.defaultChecked=e.checked}}function E(e){var bv=(e.nodeName||"").toLowerCase();if(bv==="input"){az(e)}else{if(bv!=="script"&&typeof e.getElementsByTagName!=="undefined"){b.grep(e.getElementsByTagName("input"),az)}}}function al(e){var bv=av.createElement("div");ac.appendChild(bv);bv.innerHTML=e.outerHTML;return bv.firstChild}b.extend({clone:function(by,bA,bw){var e,bv,bx,bz=b.support.html5Clone||!ah.test("<"+by.nodeName)?by.cloneNode(true):al(by);if((!b.support.noCloneEvent||!b.support.noCloneChecked)&&(by.nodeType===1||by.nodeType===11)&&!b.isXMLDoc(by)){ai(by,bz);e=bg(by);bv=bg(bz);for(bx=0;e[bx];++bx){if(bv[bx]){ai(e[bx],bv[bx])}}}if(bA){t(by,bz);if(bw){e=bg(by);bv=bg(bz);for(bx=0;e[bx];++bx){t(e[bx],bv[bx])}}}e=bv=null;return bz},clean:function(bw,by,bH,bA){var bF;by=by||av;if(typeof by.createElement==="undefined"){by=by.ownerDocument||by[0]&&by[0].ownerDocument||av}var bI=[],bB;for(var bE=0,bz;(bz=bw[bE])!=null;bE++){if(typeof bz==="number"){bz+=""}if(!bz){continue}if(typeof bz==="string"){if(!W.test(bz)){bz=by.createTextNode(bz)}else{bz=bz.replace(R,"<$1></$2>");var bK=(d.exec(bz)||["",""])[1].toLowerCase(),bx=ax[bK]||ax._default,bD=bx[0],bv=by.createElement("div");if(by===av){ac.appendChild(bv)}else{a(by).appendChild(bv)}bv.innerHTML=bx[1]+bz+bx[2];while(bD--){bv=bv.lastChild}if(!b.support.tbody){var e=w.test(bz),bC=bK==="table"&&!e?bv.firstChild&&bv.firstChild.childNodes:bx[1]==="<table>"&&!e?bv.childNodes:[];for(bB=bC.length-1;bB>=0;--bB){if(b.nodeName(bC[bB],"tbody")&&!bC[bB].childNodes.length){bC[bB].parentNode.removeChild(bC[bB])}}}if(!b.support.leadingWhitespace&&ar.test(bz)){bv.insertBefore(by.createTextNode(ar.exec(bz)[0]),bv.firstChild)}bz=bv.childNodes}}var bG;if(!b.support.appendChecked){if(bz[0]&&typeof(bG=bz.length)==="number"){for(bB=0;bB<bG;bB++){E(bz[bB])}}else{E(bz)}}if(bz.nodeType){bI.push(bz)}else{bI=b.merge(bI,bz)}}if(bH){bF=function(bL){return !bL.type||bm.test(bL.type)};for(bE=0;bI[bE];bE++){if(bA&&b.nodeName(bI[bE],"script")&&(!bI[bE].type||bI[bE].type.toLowerCase()==="text/javascript")){bA.push(bI[bE].parentNode?bI[bE].parentNode.removeChild(bI[bE]):bI[bE])}else{if(bI[bE].nodeType===1){var bJ=b.grep(bI[bE].getElementsByTagName("script"),bF);bI.splice.apply(bI,[bE+1,0].concat(bJ))}bH.appendChild(bI[bE])}}}return bI},cleanData:function(bv){var by,bw,e=b.cache,bB=b.event.special,bA=b.support.deleteExpando;for(var bz=0,bx;(bx=bv[bz])!=null;bz++){if(bx.nodeName&&b.noData[bx.nodeName.toLowerCase()]){continue}bw=bx[b.expando];if(bw){by=e[bw];if(by&&by.events){for(var bC in by.events){if(bB[bC]){b.event.remove(bx,bC)}else{b.removeEvent(bx,bC,by.handle)}}if(by.handle){by.handle.elem=null}}if(bA){delete bx[b.expando]}else{if(bx.removeAttribute){bx.removeAttribute(b.expando)}}delete e[bw]}}}});function bo(e,bv){if(bv.src){b.ajax({url:bv.src,async:false,dataType:"script"})}else{b.globalEval((bv.text||bv.textContent||bv.innerHTML||"").replace(aN,"/*$0*/"))}if(bv.parentNode){bv.parentNode.removeChild(bv)}}var ak=/alpha\([^)]*\)/i,au=/opacity=([^)]*)/,z=/([A-Z]|^ms)/g,bc=/^-?\d+(?:px)?$/i,bn=/^-?\d/,I=/^([\-+])=([\-+.\de]+)/,a7={position:"absolute",visibility:"hidden",display:"block"},an=["Left","Right"],a1=["Top","Bottom"],Z,aI,aX;b.fn.css=function(e,bv){if(arguments.length===2&&bv===L){return this}return b.access(this,e,bv,true,function(bx,bw,by){return by!==L?b.style(bx,bw,by):b.css(bx,bw)})};b.extend({cssHooks:{opacity:{get:function(bw,bv){if(bv){var e=Z(bw,"opacity","opacity");return e===""?"1":e}else{return bw.style.opacity}}}},cssNumber:{fillOpacity:true,fontWeight:true,lineHeight:true,opacity:true,orphans:true,widows:true,zIndex:true,zoom:true},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(bx,bw,bD,by){if(!bx||bx.nodeType===3||bx.nodeType===8||!bx.style){return}var bB,bC,bz=b.camelCase(bw),bv=bx.style,bE=b.cssHooks[bz];bw=b.cssProps[bz]||bz;if(bD!==L){bC=typeof bD;if(bC==="string"&&(bB=I.exec(bD))){bD=(+(bB[1]+1)*+bB[2])+parseFloat(b.css(bx,bw));bC="number"}if(bD==null||bC==="number"&&isNaN(bD)){return}if(bC==="number"&&!b.cssNumber[bz]){bD+="px"}if(!bE||!("set" in bE)||(bD=bE.set(bx,bD))!==L){try{bv[bw]=bD}catch(bA){}}}else{if(bE&&"get" in bE&&(bB=bE.get(bx,false,by))!==L){return bB}return bv[bw]}},css:function(by,bx,bv){var bw,e;bx=b.camelCase(bx);e=b.cssHooks[bx];bx=b.cssProps[bx]||bx;if(bx==="cssFloat"){bx="float"}if(e&&"get" in e&&(bw=e.get(by,true,bv))!==L){return bw}else{if(Z){return Z(by,bx)}}},swap:function(bx,bw,by){var e={};for(var bv in bw){e[bv]=bx.style[bv];bx.style[bv]=bw[bv]}by.call(bx);for(bv in bw){bx.style[bv]=e[bv]}}});b.curCSS=b.css;b.each(["height","width"],function(bv,e){b.cssHooks[e]={get:function(by,bx,bw){var bz;if(bx){if(by.offsetWidth!==0){return p(by,e,bw)}else{b.swap(by,a7,function(){bz=p(by,e,bw)})}return bz}},set:function(bw,bx){if(bc.test(bx)){bx=parseFloat(bx);if(bx>=0){return bx+"px"}}else{return bx}}}});if(!b.support.opacity){b.cssHooks.opacity={get:function(bv,e){return au.test((e&&bv.currentStyle?bv.currentStyle.filter:bv.style.filter)||"")?(parseFloat(RegExp.$1)/100)+"":e?"1":""},set:function(by,bz){var bx=by.style,bv=by.currentStyle,e=b.isNumeric(bz)?"alpha(opacity="+bz*100+")":"",bw=bv&&bv.filter||bx.filter||"";bx.zoom=1;if(bz>=1&&b.trim(bw.replace(ak,""))===""){bx.removeAttribute("filter");if(bv&&!bv.filter){return}}bx.filter=ak.test(bw)?bw.replace(ak,e):bw+" "+e}}}b(function(){if(!b.support.reliableMarginRight){b.cssHooks.marginRight={get:function(bw,bv){var e;b.swap(bw,{display:"inline-block"},function(){if(bv){e=Z(bw,"margin-right","marginRight")}else{e=bw.style.marginRight}});return e}}}});if(av.defaultView&&av.defaultView.getComputedStyle){aI=function(by,bw){var bv,bx,e;bw=bw.replace(z,"-$1").toLowerCase();if((bx=by.ownerDocument.defaultView)&&(e=bx.getComputedStyle(by,null))){bv=e.getPropertyValue(bw);if(bv===""&&!b.contains(by.ownerDocument.documentElement,by)){bv=b.style(by,bw)}}return bv}}if(av.documentElement.currentStyle){aX=function(bz,bw){var bA,e,by,bv=bz.currentStyle&&bz.currentStyle[bw],bx=bz.style;if(bv===null&&bx&&(by=bx[bw])){bv=by}if(!bc.test(bv)&&bn.test(bv)){bA=bx.left;e=bz.runtimeStyle&&bz.runtimeStyle.left;if(e){bz.runtimeStyle.left=bz.currentStyle.left}bx.left=bw==="fontSize"?"1em":(bv||0);bv=bx.pixelLeft+"px";bx.left=bA;if(e){bz.runtimeStyle.left=e}}return bv===""?"auto":bv}}Z=aI||aX;function p(by,bw,bv){var bA=bw==="width"?by.offsetWidth:by.offsetHeight,bz=bw==="width"?an:a1,bx=0,e=bz.length; +if(bA>0){if(bv!=="border"){for(;bx<e;bx++){if(!bv){bA-=parseFloat(b.css(by,"padding"+bz[bx]))||0}if(bv==="margin"){bA+=parseFloat(b.css(by,bv+bz[bx]))||0}else{bA-=parseFloat(b.css(by,"border"+bz[bx]+"Width"))||0}}}return bA+"px"}bA=Z(by,bw,bw);if(bA<0||bA==null){bA=by.style[bw]||0}bA=parseFloat(bA)||0;if(bv){for(;bx<e;bx++){bA+=parseFloat(b.css(by,"padding"+bz[bx]))||0;if(bv!=="padding"){bA+=parseFloat(b.css(by,"border"+bz[bx]+"Width"))||0}if(bv==="margin"){bA+=parseFloat(b.css(by,bv+bz[bx]))||0}}}return bA+"px"}if(b.expr&&b.expr.filters){b.expr.filters.hidden=function(bw){var bv=bw.offsetWidth,e=bw.offsetHeight;return(bv===0&&e===0)||(!b.support.reliableHiddenOffsets&&((bw.style&&bw.style.display)||b.css(bw,"display"))==="none")};b.expr.filters.visible=function(e){return !b.expr.filters.hidden(e)}}var k=/%20/g,ap=/\[\]$/,bs=/\r?\n/g,bq=/#.*$/,aD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,aZ=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,aM=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,aQ=/^(?:GET|HEAD)$/,c=/^\/\//,M=/\?/,a6=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,q=/^(?:select|textarea)/i,h=/\s+/,br=/([?&])_=[^&]*/,K=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,A=b.fn.load,aa={},r={},aE,s,aV=["*/"]+["*"];try{aE=bl.href}catch(aw){aE=av.createElement("a");aE.href="";aE=aE.href}s=K.exec(aE.toLowerCase())||[];function f(e){return function(by,bA){if(typeof by!=="string"){bA=by;by="*"}if(b.isFunction(bA)){var bx=by.toLowerCase().split(h),bw=0,bz=bx.length,bv,bB,bC;for(;bw<bz;bw++){bv=bx[bw];bC=/^\+/.test(bv);if(bC){bv=bv.substr(1)||"*"}bB=e[bv]=e[bv]||[];bB[bC?"unshift":"push"](bA)}}}}function aW(bv,bE,bz,bD,bB,bx){bB=bB||bE.dataTypes[0];bx=bx||{};bx[bB]=true;var bA=bv[bB],bw=0,e=bA?bA.length:0,by=(bv===aa),bC;for(;bw<e&&(by||!bC);bw++){bC=bA[bw](bE,bz,bD);if(typeof bC==="string"){if(!by||bx[bC]){bC=L}else{bE.dataTypes.unshift(bC);bC=aW(bv,bE,bz,bD,bC,bx)}}}if((by||!bC)&&!bx["*"]){bC=aW(bv,bE,bz,bD,"*",bx)}return bC}function am(bw,bx){var bv,e,by=b.ajaxSettings.flatOptions||{};for(bv in bx){if(bx[bv]!==L){(by[bv]?bw:(e||(e={})))[bv]=bx[bv]}}if(e){b.extend(true,bw,e)}}b.fn.extend({load:function(bw,bz,bA){if(typeof bw!=="string"&&A){return A.apply(this,arguments)}else{if(!this.length){return this}}var by=bw.indexOf(" ");if(by>=0){var e=bw.slice(by,bw.length);bw=bw.slice(0,by)}var bx="GET";if(bz){if(b.isFunction(bz)){bA=bz;bz=L}else{if(typeof bz==="object"){bz=b.param(bz,b.ajaxSettings.traditional);bx="POST"}}}var bv=this;b.ajax({url:bw,type:bx,dataType:"html",data:bz,complete:function(bC,bB,bD){bD=bC.responseText;if(bC.isResolved()){bC.done(function(bE){bD=bE});bv.html(e?b("<div>").append(bD.replace(a6,"")).find(e):bD)}if(bA){bv.each(bA,[bD,bB,bC])}}});return this},serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?b.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||q.test(this.nodeName)||aZ.test(this.type))}).map(function(e,bv){var bw=b(this).val();return bw==null?null:b.isArray(bw)?b.map(bw,function(by,bx){return{name:bv.name,value:by.replace(bs,"\r\n")}}):{name:bv.name,value:bw.replace(bs,"\r\n")}}).get()}});b.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,bv){b.fn[bv]=function(bw){return this.on(bv,bw)}});b.each(["get","post"],function(e,bv){b[bv]=function(bw,by,bz,bx){if(b.isFunction(by)){bx=bx||bz;bz=by;by=L}return b.ajax({type:bv,url:bw,data:by,success:bz,dataType:bx})}});b.extend({getScript:function(e,bv){return b.get(e,L,bv,"script")},getJSON:function(e,bv,bw){return b.get(e,bv,bw,"json")},ajaxSetup:function(bv,e){if(e){am(bv,b.ajaxSettings)}else{e=bv;bv=b.ajaxSettings}am(bv,e);return bv},ajaxSettings:{url:aE,isLocal:aM.test(s[1]),global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":aV},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":bb.String,"text html":true,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{context:true,url:true}},ajaxPrefilter:f(aa),ajaxTransport:f(r),ajax:function(bz,bx){if(typeof bz==="object"){bx=bz;bz=L}bx=bx||{};var bD=b.ajaxSetup({},bx),bS=bD.context||bD,bG=bS!==bD&&(bS.nodeType||bS instanceof b)?b(bS):b.event,bR=b.Deferred(),bN=b.Callbacks("once memory"),bB=bD.statusCode||{},bC,bH={},bO={},bQ,by,bL,bE,bI,bA=0,bw,bK,bJ={readyState:0,setRequestHeader:function(bT,bU){if(!bA){var e=bT.toLowerCase();bT=bO[e]=bO[e]||bT;bH[bT]=bU}return this},getAllResponseHeaders:function(){return bA===2?bQ:null},getResponseHeader:function(bT){var e;if(bA===2){if(!by){by={};while((e=aD.exec(bQ))){by[e[1].toLowerCase()]=e[2]}}e=by[bT.toLowerCase()]}return e===L?null:e},overrideMimeType:function(e){if(!bA){bD.mimeType=e}return this},abort:function(e){e=e||"abort";if(bL){bL.abort(e)}bF(0,e);return this}};function bF(bZ,bU,b0,bW){if(bA===2){return}bA=2;if(bE){clearTimeout(bE)}bL=L;bQ=bW||"";bJ.readyState=bZ>0?4:0;var bT,b4,b3,bX=bU,bY=b0?bj(bD,bJ,b0):L,bV,b2;if(bZ>=200&&bZ<300||bZ===304){if(bD.ifModified){if((bV=bJ.getResponseHeader("Last-Modified"))){b.lastModified[bC]=bV}if((b2=bJ.getResponseHeader("Etag"))){b.etag[bC]=b2}}if(bZ===304){bX="notmodified";bT=true}else{try{b4=G(bD,bY);bX="success";bT=true}catch(b1){bX="parsererror";b3=b1}}}else{b3=bX;if(!bX||bZ){bX="error";if(bZ<0){bZ=0}}}bJ.status=bZ;bJ.statusText=""+(bU||bX);if(bT){bR.resolveWith(bS,[b4,bX,bJ])}else{bR.rejectWith(bS,[bJ,bX,b3])}bJ.statusCode(bB);bB=L;if(bw){bG.trigger("ajax"+(bT?"Success":"Error"),[bJ,bD,bT?b4:b3])}bN.fireWith(bS,[bJ,bX]);if(bw){bG.trigger("ajaxComplete",[bJ,bD]);if(!(--b.active)){b.event.trigger("ajaxStop")}}}bR.promise(bJ);bJ.success=bJ.done;bJ.error=bJ.fail;bJ.complete=bN.add;bJ.statusCode=function(bT){if(bT){var e;if(bA<2){for(e in bT){bB[e]=[bB[e],bT[e]]}}else{e=bT[bJ.status];bJ.then(e,e)}}return this};bD.url=((bz||bD.url)+"").replace(bq,"").replace(c,s[1]+"//");bD.dataTypes=b.trim(bD.dataType||"*").toLowerCase().split(h);if(bD.crossDomain==null){bI=K.exec(bD.url.toLowerCase());bD.crossDomain=!!(bI&&(bI[1]!=s[1]||bI[2]!=s[2]||(bI[3]||(bI[1]==="http:"?80:443))!=(s[3]||(s[1]==="http:"?80:443))))}if(bD.data&&bD.processData&&typeof bD.data!=="string"){bD.data=b.param(bD.data,bD.traditional)}aW(aa,bD,bx,bJ);if(bA===2){return false}bw=bD.global;bD.type=bD.type.toUpperCase();bD.hasContent=!aQ.test(bD.type);if(bw&&b.active++===0){b.event.trigger("ajaxStart")}if(!bD.hasContent){if(bD.data){bD.url+=(M.test(bD.url)?"&":"?")+bD.data;delete bD.data}bC=bD.url;if(bD.cache===false){var bv=b.now(),bP=bD.url.replace(br,"$1_="+bv);bD.url=bP+((bP===bD.url)?(M.test(bD.url)?"&":"?")+"_="+bv:"")}}if(bD.data&&bD.hasContent&&bD.contentType!==false||bx.contentType){bJ.setRequestHeader("Content-Type",bD.contentType)}if(bD.ifModified){bC=bC||bD.url;if(b.lastModified[bC]){bJ.setRequestHeader("If-Modified-Since",b.lastModified[bC])}if(b.etag[bC]){bJ.setRequestHeader("If-None-Match",b.etag[bC])}}bJ.setRequestHeader("Accept",bD.dataTypes[0]&&bD.accepts[bD.dataTypes[0]]?bD.accepts[bD.dataTypes[0]]+(bD.dataTypes[0]!=="*"?", "+aV+"; q=0.01":""):bD.accepts["*"]);for(bK in bD.headers){bJ.setRequestHeader(bK,bD.headers[bK])}if(bD.beforeSend&&(bD.beforeSend.call(bS,bJ,bD)===false||bA===2)){bJ.abort();return false}for(bK in {success:1,error:1,complete:1}){bJ[bK](bD[bK])}bL=aW(r,bD,bx,bJ);if(!bL){bF(-1,"No Transport")}else{bJ.readyState=1;if(bw){bG.trigger("ajaxSend",[bJ,bD])}if(bD.async&&bD.timeout>0){bE=setTimeout(function(){bJ.abort("timeout")},bD.timeout)}try{bA=1;bL.send(bH,bF)}catch(bM){if(bA<2){bF(-1,bM)}else{throw bM}}}return bJ},param:function(e,bw){var bv=[],by=function(bz,bA){bA=b.isFunction(bA)?bA():bA;bv[bv.length]=encodeURIComponent(bz)+"="+encodeURIComponent(bA)};if(bw===L){bw=b.ajaxSettings.traditional}if(b.isArray(e)||(e.jquery&&!b.isPlainObject(e))){b.each(e,function(){by(this.name,this.value)})}else{for(var bx in e){v(bx,e[bx],bw,by)}}return bv.join("&").replace(k,"+")}});function v(bw,by,bv,bx){if(b.isArray(by)){b.each(by,function(bA,bz){if(bv||ap.test(bw)){bx(bw,bz)}else{v(bw+"["+(typeof bz==="object"||b.isArray(bz)?bA:"")+"]",bz,bv,bx)}})}else{if(!bv&&by!=null&&typeof by==="object"){for(var e in by){v(bw+"["+e+"]",by[e],bv,bx)}}else{bx(bw,by)}}}b.extend({active:0,lastModified:{},etag:{}});function bj(bD,bC,bz){var bv=bD.contents,bB=bD.dataTypes,bw=bD.responseFields,by,bA,bx,e;for(bA in bw){if(bA in bz){bC[bw[bA]]=bz[bA]}}while(bB[0]==="*"){bB.shift();if(by===L){by=bD.mimeType||bC.getResponseHeader("content-type")}}if(by){for(bA in bv){if(bv[bA]&&bv[bA].test(by)){bB.unshift(bA);break}}}if(bB[0] in bz){bx=bB[0]}else{for(bA in bz){if(!bB[0]||bD.converters[bA+" "+bB[0]]){bx=bA;break}if(!e){e=bA}}bx=bx||e}if(bx){if(bx!==bB[0]){bB.unshift(bx)}return bz[bx]}}function G(bH,bz){if(bH.dataFilter){bz=bH.dataFilter(bz,bH.dataType)}var bD=bH.dataTypes,bG={},bA,bE,bw=bD.length,bB,bC=bD[0],bx,by,bF,bv,e;for(bA=1;bA<bw;bA++){if(bA===1){for(bE in bH.converters){if(typeof bE==="string"){bG[bE.toLowerCase()]=bH.converters[bE]}}}bx=bC;bC=bD[bA];if(bC==="*"){bC=bx}else{if(bx!=="*"&&bx!==bC){by=bx+" "+bC;bF=bG[by]||bG["* "+bC];if(!bF){e=L;for(bv in bG){bB=bv.split(" ");if(bB[0]===bx||bB[0]==="*"){e=bG[bB[1]+" "+bC];if(e){bv=bG[bv];if(bv===true){bF=e}else{if(e===true){bF=bv}}break}}}}if(!(bF||e)){b.error("No conversion from "+by.replace(" "," to "))}if(bF!==true){bz=bF?bF(bz):e(bv(bz))}}}}return bz}var aC=b.now(),u=/(\=)\?(&|$)|\?\?/i;b.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return b.expando+"_"+(aC++)}});b.ajaxPrefilter("json jsonp",function(bD,bA,bC){var bx=bD.contentType==="application/x-www-form-urlencoded"&&(typeof bD.data==="string");if(bD.dataTypes[0]==="jsonp"||bD.jsonp!==false&&(u.test(bD.url)||bx&&u.test(bD.data))){var bB,bw=bD.jsonpCallback=b.isFunction(bD.jsonpCallback)?bD.jsonpCallback():bD.jsonpCallback,bz=bb[bw],e=bD.url,by=bD.data,bv="$1"+bw+"$2";if(bD.jsonp!==false){e=e.replace(u,bv);if(bD.url===e){if(bx){by=by.replace(u,bv)}if(bD.data===by){e+=(/\?/.test(e)?"&":"?")+bD.jsonp+"="+bw}}}bD.url=e;bD.data=by;bb[bw]=function(bE){bB=[bE]};bC.always(function(){bb[bw]=bz;if(bB&&b.isFunction(bz)){bb[bw](bB[0])}});bD.converters["script json"]=function(){if(!bB){b.error(bw+" was not called")}return bB[0]};bD.dataTypes[0]="json";return"script"}});b.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){b.globalEval(e);return e}}});b.ajaxPrefilter("script",function(e){if(e.cache===L){e.cache=false}if(e.crossDomain){e.type="GET";e.global=false}});b.ajaxTransport("script",function(bw){if(bw.crossDomain){var e,bv=av.head||av.getElementsByTagName("head")[0]||av.documentElement;return{send:function(bx,by){e=av.createElement("script");e.async="async";if(bw.scriptCharset){e.charset=bw.scriptCharset}e.src=bw.url;e.onload=e.onreadystatechange=function(bA,bz){if(bz||!e.readyState||/loaded|complete/.test(e.readyState)){e.onload=e.onreadystatechange=null;if(bv&&e.parentNode){bv.removeChild(e)}e=L;if(!bz){by(200,"success")}}};bv.insertBefore(e,bv.firstChild)},abort:function(){if(e){e.onload(0,1)}}}}});var B=bb.ActiveXObject?function(){for(var e in N){N[e](0,1)}}:false,y=0,N;function aL(){try{return new bb.XMLHttpRequest()}catch(bv){}}function aj(){try{return new bb.ActiveXObject("Microsoft.XMLHTTP")}catch(bv){}}b.ajaxSettings.xhr=bb.ActiveXObject?function(){return !this.isLocal&&aL()||aj()}:aL;(function(e){b.extend(b.support,{ajax:!!e,cors:!!e&&("withCredentials" in e)})})(b.ajaxSettings.xhr());if(b.support.ajax){b.ajaxTransport(function(e){if(!e.crossDomain||b.support.cors){var bv;return{send:function(bB,bw){var bA=e.xhr(),bz,by;if(e.username){bA.open(e.type,e.url,e.async,e.username,e.password)}else{bA.open(e.type,e.url,e.async)}if(e.xhrFields){for(by in e.xhrFields){bA[by]=e.xhrFields[by]}}if(e.mimeType&&bA.overrideMimeType){bA.overrideMimeType(e.mimeType)}if(!e.crossDomain&&!bB["X-Requested-With"]){bB["X-Requested-With"]="XMLHttpRequest"}try{for(by in bB){bA.setRequestHeader(by,bB[by])}}catch(bx){}bA.send((e.hasContent&&e.data)||null);bv=function(bK,bE){var bF,bD,bC,bI,bH;try{if(bv&&(bE||bA.readyState===4)){bv=L;if(bz){bA.onreadystatechange=b.noop;if(B){delete N[bz]}}if(bE){if(bA.readyState!==4){bA.abort()}}else{bF=bA.status;bC=bA.getAllResponseHeaders();bI={};bH=bA.responseXML;if(bH&&bH.documentElement){bI.xml=bH}bI.text=bA.responseText;try{bD=bA.statusText}catch(bJ){bD=""}if(!bF&&e.isLocal&&!e.crossDomain){bF=bI.text?200:404}else{if(bF===1223){bF=204}}}}}catch(bG){if(!bE){bw(-1,bG)}}if(bI){bw(bF,bD,bI,bC)}};if(!e.async||bA.readyState===4){bv()}else{bz=++y;if(B){if(!N){N={};b(bb).unload(B)}N[bz]=bv}bA.onreadystatechange=bv}},abort:function(){if(bv){bv(0,1) +}}}}})}var Q={},a8,m,aB=/^(?:toggle|show|hide)$/,aT=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,a3,aH=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],a4;b.fn.extend({show:function(bx,bA,bz){var bw,by;if(bx||bx===0){return this.animate(a0("show",3),bx,bA,bz)}else{for(var bv=0,e=this.length;bv<e;bv++){bw=this[bv];if(bw.style){by=bw.style.display;if(!b._data(bw,"olddisplay")&&by==="none"){by=bw.style.display=""}if(by===""&&b.css(bw,"display")==="none"){b._data(bw,"olddisplay",x(bw.nodeName))}}}for(bv=0;bv<e;bv++){bw=this[bv];if(bw.style){by=bw.style.display;if(by===""||by==="none"){bw.style.display=b._data(bw,"olddisplay")||""}}}return this}},hide:function(bx,bA,bz){if(bx||bx===0){return this.animate(a0("hide",3),bx,bA,bz)}else{var bw,by,bv=0,e=this.length;for(;bv<e;bv++){bw=this[bv];if(bw.style){by=b.css(bw,"display");if(by!=="none"&&!b._data(bw,"olddisplay")){b._data(bw,"olddisplay",by)}}}for(bv=0;bv<e;bv++){if(this[bv].style){this[bv].style.display="none"}}return this}},_toggle:b.fn.toggle,toggle:function(bw,bv,bx){var e=typeof bw==="boolean";if(b.isFunction(bw)&&b.isFunction(bv)){this._toggle.apply(this,arguments)}else{if(bw==null||e){this.each(function(){var by=e?bw:b(this).is(":hidden");b(this)[by?"show":"hide"]()})}else{this.animate(a0("toggle",3),bw,bv,bx)}}return this},fadeTo:function(e,bx,bw,bv){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:bx},e,bw,bv)},animate:function(bz,bw,by,bx){var e=b.speed(bw,by,bx);if(b.isEmptyObject(bz)){return this.each(e.complete,[false])}bz=b.extend({},bz);function bv(){if(e.queue===false){b._mark(this)}var bE=b.extend({},e),bK=this.nodeType===1,bI=bK&&b(this).is(":hidden"),bB,bF,bD,bJ,bH,bC,bG,bL,bA;bE.animatedProperties={};for(bD in bz){bB=b.camelCase(bD);if(bD!==bB){bz[bB]=bz[bD];delete bz[bD]}bF=bz[bB];if(b.isArray(bF)){bE.animatedProperties[bB]=bF[1];bF=bz[bB]=bF[0]}else{bE.animatedProperties[bB]=bE.specialEasing&&bE.specialEasing[bB]||bE.easing||"swing"}if(bF==="hide"&&bI||bF==="show"&&!bI){return bE.complete.call(this)}if(bK&&(bB==="height"||bB==="width")){bE.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY];if(b.css(this,"display")==="inline"&&b.css(this,"float")==="none"){if(!b.support.inlineBlockNeedsLayout||x(this.nodeName)==="inline"){this.style.display="inline-block"}else{this.style.zoom=1}}}}if(bE.overflow!=null){this.style.overflow="hidden"}for(bD in bz){bJ=new b.fx(this,bE,bD);bF=bz[bD];if(aB.test(bF)){bA=b._data(this,"toggle"+bD)||(bF==="toggle"?bI?"show":"hide":0);if(bA){b._data(this,"toggle"+bD,bA==="show"?"hide":"show");bJ[bA]()}else{bJ[bF]()}}else{bH=aT.exec(bF);bC=bJ.cur();if(bH){bG=parseFloat(bH[2]);bL=bH[3]||(b.cssNumber[bD]?"":"px");if(bL!=="px"){b.style(this,bD,(bG||1)+bL);bC=((bG||1)/bJ.cur())*bC;b.style(this,bD,bC+bL)}if(bH[1]){bG=((bH[1]==="-="?-1:1)*bG)+bC}bJ.custom(bC,bG,bL)}else{bJ.custom(bC,bF,"")}}}return true}return e.queue===false?this.each(bv):this.queue(e.queue,bv)},stop:function(bw,bv,e){if(typeof bw!=="string"){e=bv;bv=bw;bw=L}if(bv&&bw!==false){this.queue(bw||"fx",[])}return this.each(function(){var bx,by=false,bA=b.timers,bz=b._data(this);if(!e){b._unmark(true,this)}function bB(bE,bF,bD){var bC=bF[bD];b.removeData(bE,bD,true);bC.stop(e)}if(bw==null){for(bx in bz){if(bz[bx]&&bz[bx].stop&&bx.indexOf(".run")===bx.length-4){bB(this,bz,bx)}}}else{if(bz[bx=bw+".run"]&&bz[bx].stop){bB(this,bz,bx)}}for(bx=bA.length;bx--;){if(bA[bx].elem===this&&(bw==null||bA[bx].queue===bw)){if(e){bA[bx](true)}else{bA[bx].saveState()}by=true;bA.splice(bx,1)}}if(!(e&&by)){b.dequeue(this,bw)}})}});function bh(){setTimeout(at,0);return(a4=b.now())}function at(){a4=L}function a0(bv,e){var bw={};b.each(aH.concat.apply([],aH.slice(0,e)),function(){bw[this]=bv});return bw}b.each({slideDown:a0("show",1),slideUp:a0("hide",1),slideToggle:a0("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,bv){b.fn[e]=function(bw,by,bx){return this.animate(bv,bw,by,bx)}});b.extend({speed:function(bw,bx,bv){var e=bw&&typeof bw==="object"?b.extend({},bw):{complete:bv||!bv&&bx||b.isFunction(bw)&&bw,duration:bw,easing:bv&&bx||bx&&!b.isFunction(bx)&&bx};e.duration=b.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in b.fx.speeds?b.fx.speeds[e.duration]:b.fx.speeds._default;if(e.queue==null||e.queue===true){e.queue="fx"}e.old=e.complete;e.complete=function(by){if(b.isFunction(e.old)){e.old.call(this)}if(e.queue){b.dequeue(this,e.queue)}else{if(by!==false){b._unmark(this)}}};return e},easing:{linear:function(bw,bx,e,bv){return e+bv*bw},swing:function(bw,bx,e,bv){return((-Math.cos(bw*Math.PI)/2)+0.5)*bv+e}},timers:[],fx:function(bv,e,bw){this.options=e;this.elem=bv;this.prop=bw;e.orig=e.orig||{}}});b.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(b.fx.step[this.prop]||b.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var e,bv=b.css(this.elem,this.prop);return isNaN(e=parseFloat(bv))?!bv||bv==="auto"?0:bv:e},custom:function(bz,by,bx){var e=this,bw=b.fx;this.startTime=a4||bh();this.end=by;this.now=this.start=bz;this.pos=this.state=0;this.unit=bx||this.unit||(b.cssNumber[this.prop]?"":"px");function bv(bA){return e.step(bA)}bv.queue=this.options.queue;bv.elem=this.elem;bv.saveState=function(){if(e.options.hide&&b._data(e.elem,"fxshow"+e.prop)===L){b._data(e.elem,"fxshow"+e.prop,e.start)}};if(bv()&&b.timers.push(bv)&&!a3){a3=setInterval(bw.tick,bw.interval)}},show:function(){var e=b._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=e||b.style(this.elem,this.prop);this.options.show=true;if(e!==L){this.custom(this.cur(),e)}else{this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur())}b(this.elem).show()},hide:function(){this.options.orig[this.prop]=b._data(this.elem,"fxshow"+this.prop)||b.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(by){var bA,bB,bv,bx=a4||bh(),e=true,bz=this.elem,bw=this.options;if(by||bx>=bw.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();bw.animatedProperties[this.prop]=true;for(bA in bw.animatedProperties){if(bw.animatedProperties[bA]!==true){e=false}}if(e){if(bw.overflow!=null&&!b.support.shrinkWrapBlocks){b.each(["","X","Y"],function(bC,bD){bz.style["overflow"+bD]=bw.overflow[bC]})}if(bw.hide){b(bz).hide()}if(bw.hide||bw.show){for(bA in bw.animatedProperties){b.style(bz,bA,bw.orig[bA]);b.removeData(bz,"fxshow"+bA,true);b.removeData(bz,"toggle"+bA,true)}}bv=bw.complete;if(bv){bw.complete=false;bv.call(bz)}}return false}else{if(bw.duration==Infinity){this.now=bx}else{bB=bx-this.startTime;this.state=bB/bw.duration;this.pos=b.easing[bw.animatedProperties[this.prop]](this.state,bB,0,1,bw.duration);this.now=this.start+((this.end-this.start)*this.pos)}this.update()}return true}};b.extend(b.fx,{tick:function(){var bw,bv=b.timers,e=0;for(;e<bv.length;e++){bw=bv[e];if(!bw()&&bv[e]===bw){bv.splice(e--,1)}}if(!bv.length){b.fx.stop()}},interval:13,stop:function(){clearInterval(a3);a3=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(e){b.style(e.elem,"opacity",e.now)},_default:function(e){if(e.elem.style&&e.elem.style[e.prop]!=null){e.elem.style[e.prop]=e.now+e.unit}else{e.elem[e.prop]=e.now}}}});b.each(["width","height"],function(e,bv){b.fx.step[bv]=function(bw){b.style(bw.elem,bv,Math.max(0,bw.now)+bw.unit)}});if(b.expr&&b.expr.filters){b.expr.filters.animated=function(e){return b.grep(b.timers,function(bv){return e===bv.elem}).length}}function x(bx){if(!Q[bx]){var e=av.body,bv=b("<"+bx+">").appendTo(e),bw=bv.css("display");bv.remove();if(bw==="none"||bw===""){if(!a8){a8=av.createElement("iframe");a8.frameBorder=a8.width=a8.height=0}e.appendChild(a8);if(!m||!a8.createElement){m=(a8.contentWindow||a8.contentDocument).document;m.write((av.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>");m.close()}bv=m.createElement(bx);m.body.appendChild(bv);bw=b.css(bv,"display");e.removeChild(a8)}Q[bx]=bw}return Q[bx]}var V=/^t(?:able|d|h)$/i,ad=/^(?:body|html)$/i;if("getBoundingClientRect" in av.documentElement){b.fn.offset=function(bI){var by=this[0],bB;if(bI){return this.each(function(e){b.offset.setOffset(this,bI,e)})}if(!by||!by.ownerDocument){return null}if(by===by.ownerDocument.body){return b.offset.bodyOffset(by)}try{bB=by.getBoundingClientRect()}catch(bF){}var bH=by.ownerDocument,bw=bH.documentElement;if(!bB||!b.contains(bw,by)){return bB?{top:bB.top,left:bB.left}:{top:0,left:0}}var bC=bH.body,bD=aK(bH),bA=bw.clientTop||bC.clientTop||0,bE=bw.clientLeft||bC.clientLeft||0,bv=bD.pageYOffset||b.support.boxModel&&bw.scrollTop||bC.scrollTop,bz=bD.pageXOffset||b.support.boxModel&&bw.scrollLeft||bC.scrollLeft,bG=bB.top+bv-bA,bx=bB.left+bz-bE;return{top:bG,left:bx}}}else{b.fn.offset=function(bF){var bz=this[0];if(bF){return this.each(function(bG){b.offset.setOffset(this,bF,bG)})}if(!bz||!bz.ownerDocument){return null}if(bz===bz.ownerDocument.body){return b.offset.bodyOffset(bz)}var bC,bw=bz.offsetParent,bv=bz,bE=bz.ownerDocument,bx=bE.documentElement,bA=bE.body,bB=bE.defaultView,e=bB?bB.getComputedStyle(bz,null):bz.currentStyle,bD=bz.offsetTop,by=bz.offsetLeft;while((bz=bz.parentNode)&&bz!==bA&&bz!==bx){if(b.support.fixedPosition&&e.position==="fixed"){break}bC=bB?bB.getComputedStyle(bz,null):bz.currentStyle;bD-=bz.scrollTop;by-=bz.scrollLeft;if(bz===bw){bD+=bz.offsetTop;by+=bz.offsetLeft;if(b.support.doesNotAddBorder&&!(b.support.doesAddBorderForTableAndCells&&V.test(bz.nodeName))){bD+=parseFloat(bC.borderTopWidth)||0;by+=parseFloat(bC.borderLeftWidth)||0}bv=bw;bw=bz.offsetParent}if(b.support.subtractsBorderForOverflowNotVisible&&bC.overflow!=="visible"){bD+=parseFloat(bC.borderTopWidth)||0;by+=parseFloat(bC.borderLeftWidth)||0}e=bC}if(e.position==="relative"||e.position==="static"){bD+=bA.offsetTop;by+=bA.offsetLeft}if(b.support.fixedPosition&&e.position==="fixed"){bD+=Math.max(bx.scrollTop,bA.scrollTop);by+=Math.max(bx.scrollLeft,bA.scrollLeft)}return{top:bD,left:by}}}b.offset={bodyOffset:function(e){var bw=e.offsetTop,bv=e.offsetLeft;if(b.support.doesNotIncludeMarginInBodyOffset){bw+=parseFloat(b.css(e,"marginTop"))||0;bv+=parseFloat(b.css(e,"marginLeft"))||0}return{top:bw,left:bv}},setOffset:function(bx,bG,bA){var bB=b.css(bx,"position");if(bB==="static"){bx.style.position="relative"}var bz=b(bx),bv=bz.offset(),e=b.css(bx,"top"),bE=b.css(bx,"left"),bF=(bB==="absolute"||bB==="fixed")&&b.inArray("auto",[e,bE])>-1,bD={},bC={},bw,by;if(bF){bC=bz.position();bw=bC.top;by=bC.left}else{bw=parseFloat(e)||0;by=parseFloat(bE)||0}if(b.isFunction(bG)){bG=bG.call(bx,bA,bv)}if(bG.top!=null){bD.top=(bG.top-bv.top)+bw}if(bG.left!=null){bD.left=(bG.left-bv.left)+by}if("using" in bG){bG.using.call(bx,bD)}else{bz.css(bD)}}};b.fn.extend({position:function(){if(!this[0]){return null}var bw=this[0],bv=this.offsetParent(),bx=this.offset(),e=ad.test(bv[0].nodeName)?{top:0,left:0}:bv.offset();bx.top-=parseFloat(b.css(bw,"marginTop"))||0;bx.left-=parseFloat(b.css(bw,"marginLeft"))||0;e.top+=parseFloat(b.css(bv[0],"borderTopWidth"))||0;e.left+=parseFloat(b.css(bv[0],"borderLeftWidth"))||0;return{top:bx.top-e.top,left:bx.left-e.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||av.body;while(e&&(!ad.test(e.nodeName)&&b.css(e,"position")==="static")){e=e.offsetParent}return e})}});b.each(["Left","Top"],function(bv,e){var bw="scroll"+e;b.fn[bw]=function(bz){var bx,by;if(bz===L){bx=this[0];if(!bx){return null}by=aK(bx);return by?("pageXOffset" in by)?by[bv?"pageYOffset":"pageXOffset"]:b.support.boxModel&&by.document.documentElement[bw]||by.document.body[bw]:bx[bw]}return this.each(function(){by=aK(this);if(by){by.scrollTo(!bv?bz:b(by).scrollLeft(),bv?bz:b(by).scrollTop())}else{this[bw]=bz}})}});function aK(e){return b.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:false}b.each(["Height","Width"],function(bv,e){var bw=e.toLowerCase();b.fn["inner"+e]=function(){var bx=this[0];return bx?bx.style?parseFloat(b.css(bx,bw,"padding")):this[bw]():null};b.fn["outer"+e]=function(by){var bx=this[0];return bx?bx.style?parseFloat(b.css(bx,bw,by?"margin":"border")):this[bw]():null};b.fn[bw]=function(bz){var bA=this[0];if(!bA){return bz==null?null:this}if(b.isFunction(bz)){return this.each(function(bE){var bD=b(this);bD[bw](bz.call(this,bE,bD[bw]()))})}if(b.isWindow(bA)){var bB=bA.document.documentElement["client"+e],bx=bA.document.body;return bA.document.compatMode==="CSS1Compat"&&bB||bx&&bx["client"+e]||bB}else{if(bA.nodeType===9){return Math.max(bA.documentElement["client"+e],bA.body["scroll"+e],bA.documentElement["scroll"+e],bA.body["offset"+e],bA.documentElement["offset"+e])}else{if(bz===L){var bC=b.css(bA,bw),by=parseFloat(bC);return b.isNumeric(by)?by:bC}else{return this.css(bw,typeof bz==="string"?bz:bz+"px")}}}}});bb.jQuery=bb.$=b;if(typeof define==="function"&&define.amd&&define.amd.jQuery){define("jquery",[],function(){return b +})}})(window); +/*! + * jQuery UI 1.8.18 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI + */ +(function(a,d){a.ui=a.ui||{};if(a.ui.version){return}a.extend(a.ui,{version:"1.8.18",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(e,f){return typeof e==="number"?this.each(function(){var g=this;setTimeout(function(){a(g).focus();if(f){f.call(g)}},e)}):this._focus.apply(this,arguments)},scrollParent:function(){var e;if((a.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){e=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(a.curCSS(this,"position",1))&&(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}else{e=this.parents().filter(function(){return(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!e.length?a(document):e},zIndex:function(h){if(h!==d){return this.css("zIndex",h)}if(this.length){var f=a(this[0]),e,g;while(f.length&&f[0]!==document){e=f.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){g=parseInt(f.css("zIndex"),10);if(!isNaN(g)&&g!==0){return g}}f=f.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});a.each(["Width","Height"],function(g,e){var f=e==="Width"?["Left","Right"]:["Top","Bottom"],h=e.toLowerCase(),k={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};function j(m,l,i,n){a.each(f,function(){l-=parseFloat(a.curCSS(m,"padding"+this,true))||0;if(i){l-=parseFloat(a.curCSS(m,"border"+this+"Width",true))||0}if(n){l-=parseFloat(a.curCSS(m,"margin"+this,true))||0}});return l}a.fn["inner"+e]=function(i){if(i===d){return k["inner"+e].call(this)}return this.each(function(){a(this).css(h,j(this,i)+"px")})};a.fn["outer"+e]=function(i,l){if(typeof i!=="number"){return k["outer"+e].call(this,i)}return this.each(function(){a(this).css(h,j(this,i,true,l)+"px")})}});function c(g,e){var j=g.nodeName.toLowerCase();if("area"===j){var i=g.parentNode,h=i.name,f;if(!g.href||!h||i.nodeName.toLowerCase()!=="map"){return false}f=a("img[usemap=#"+h+"]")[0];return !!f&&b(f)}return(/input|select|textarea|button|object/.test(j)?!g.disabled:"a"==j?g.href||e:e)&&b(g)}function b(e){return !a(e).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.extend(a.expr[":"],{data:function(g,f,e){return !!a.data(g,e[3])},focusable:function(e){return c(e,!isNaN(a.attr(e,"tabindex")))},tabbable:function(g){var e=a.attr(g,"tabindex"),f=isNaN(e);return(f||e>=0)&&c(g,!f)}});a(function(){var e=document.body,f=e.appendChild(f=document.createElement("div"));f.offsetHeight;a.extend(f.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=f.offsetHeight===100;a.support.selectstart="onselectstart" in f;e.removeChild(f).style.display="none"});a.extend(a.ui,{plugin:{add:function(f,g,j){var h=a.ui[f].prototype;for(var e in j){h.plugins[e]=h.plugins[e]||[];h.plugins[e].push([g,j[e]])}},call:function(e,g,f){var j=e.plugins[g];if(!j||!e.element[0].parentNode){return}for(var h=0;h<j.length;h++){if(e.options[j[h][0]]){j[h][1].apply(e.element,f)}}}},contains:function(f,e){return document.compareDocumentPosition?f.compareDocumentPosition(e)&16:f!==e&&f.contains(e)},hasScroll:function(h,f){if(a(h).css("overflow")==="hidden"){return false}var e=(f&&f==="left")?"scrollLeft":"scrollTop",g=false;if(h[e]>0){return true}h[e]=1;g=(h[e]>0);h[e]=0;return g},isOverAxis:function(f,e,g){return(f>e)&&(f<(e+g))},isOver:function(j,f,i,h,e,g){return a.ui.isOverAxis(j,i,e)&&a.ui.isOverAxis(f,h,g)}})})(jQuery);/*! + * jQuery UI Widget 1.8.18 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Widget + */ +(function(b,d){if(b.cleanData){var c=b.cleanData;b.cleanData=function(f){for(var g=0,h;(h=f[g])!=null;g++){try{b(h).triggerHandler("remove")}catch(j){}}c(f)}}else{var a=b.fn.remove;b.fn.remove=function(e,f){return this.each(function(){if(!f){if(!e||b.filter(e,[this]).length){b("*",this).add([this]).each(function(){try{b(this).triggerHandler("remove")}catch(g){}})}}return a.call(b(this),e,f)})}}b.widget=function(f,h,e){var g=f.split(".")[0],j;f=f.split(".")[1];j=g+"-"+f;if(!e){e=h;h=b.Widget}b.expr[":"][j]=function(k){return !!b.data(k,f)};b[g]=b[g]||{};b[g][f]=function(k,l){if(arguments.length){this._createWidget(k,l)}};var i=new h();i.options=b.extend(true,{},i.options);b[g][f].prototype=b.extend(true,i,{namespace:g,widgetName:f,widgetEventPrefix:b[g][f].prototype.widgetEventPrefix||f,widgetBaseClass:j},e);b.widget.bridge(f,b[g][f])};b.widget.bridge=function(f,e){b.fn[f]=function(i){var g=typeof i==="string",h=Array.prototype.slice.call(arguments,1),j=this;i=!g&&h.length?b.extend.apply(null,[true,i].concat(h)):i;if(g&&i.charAt(0)==="_"){return j}if(g){this.each(function(){var k=b.data(this,f),l=k&&b.isFunction(k[i])?k[i].apply(k,h):k;if(l!==k&&l!==d){j=l;return false}})}else{this.each(function(){var k=b.data(this,f);if(k){k.option(i||{})._init()}else{b.data(this,f,new e(i,this))}})}return j}};b.Widget=function(e,f){if(arguments.length){this._createWidget(e,f)}};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(f,g){b.data(g,this.widgetName,this);this.element=b(g);this.options=b.extend(true,{},this.options,this._getCreateOptions(),f);var e=this;this.element.bind("remove."+this.widgetName,function(){e.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(f,g){var e=f;if(arguments.length===0){return b.extend({},this.options)}if(typeof f==="string"){if(g===d){return this.options[f]}e={};e[f]=g}this._setOptions(e);return this},_setOptions:function(f){var e=this;b.each(f,function(g,h){e._setOption(g,h)});return this},_setOption:function(e,f){this.options[e]=f;if(e==="disabled"){this.widget()[f?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",f)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(e,f,g){var j,i,h=this.options[e];g=g||{};f=b.Event(f);f.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase();f.target=this.element[0];i=f.originalEvent;if(i){for(j in i){if(!(j in f)){f[j]=i[j]}}}this.element.trigger(f,g);return !(b.isFunction(h)&&h.call(this.element[0],f,g)===false||f.isDefaultPrevented())}}})(jQuery);/*! + * jQuery UI Mouse 1.8.18 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Mouse + * + * Depends: + * jquery.ui.widget.js + */ +(function(b,c){var a=false;b(document).mouseup(function(d){a=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var d=this;this.element.bind("mousedown."+this.widgetName,function(e){return d._mouseDown(e)}).bind("click."+this.widgetName,function(e){if(true===b.data(e.target,d.widgetName+".preventClickEvent")){b.removeData(e.target,d.widgetName+".preventClickEvent");e.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(f){if(a){return}(this._mouseStarted&&this._mouseUp(f));this._mouseDownEvent=f;var e=this,g=(f.which==1),d=(typeof this.options.cancel=="string"&&f.target.nodeName?b(f.target).closest(this.options.cancel).length:false);if(!g||d||!this._mouseCapture(f)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){e.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(f)&&this._mouseDelayMet(f)){this._mouseStarted=(this._mouseStart(f)!==false);if(!this._mouseStarted){f.preventDefault();return true}}if(true===b.data(f.target,this.widgetName+".preventClickEvent")){b.removeData(f.target,this.widgetName+".preventClickEvent")}this._mouseMoveDelegate=function(h){return e._mouseMove(h)};this._mouseUpDelegate=function(h){return e._mouseUp(h)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);f.preventDefault();a=true;return true},_mouseMove:function(d){if(b.browser.msie&&!(document.documentMode>=9)&&!d.button){return this._mouseUp(d)}if(this._mouseStarted){this._mouseDrag(d);return d.preventDefault()}if(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,d)!==false);(this._mouseStarted?this._mouseDrag(d):this._mouseUp(d))}return !this._mouseStarted},_mouseUp:function(d){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;if(d.target==this._mouseDownEvent.target){b.data(d.target,this.widgetName+".preventClickEvent",true)}this._mouseStop(d)}return false},_mouseDistanceMet:function(d){return(Math.max(Math.abs(this._mouseDownEvent.pageX-d.pageX),Math.abs(this._mouseDownEvent.pageY-d.pageY))>=this.options.distance)},_mouseDelayMet:function(d){return this.mouseDelayMet},_mouseStart:function(d){},_mouseDrag:function(d){},_mouseStop:function(d){},_mouseCapture:function(d){return true}})})(jQuery);(function(c,d){c.widget("ui.resizable",c.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000},_create:function(){var f=this,k=this.options;this.element.addClass("ui-resizable");c.extend(this,{_aspectRatio:!!(k.aspectRatio),aspectRatio:k.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:k.helper||k.ghost||k.animate?k.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){this.element.wrap(c('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=k.handles||(!c(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all"){this.handles="n,e,s,w,se,sw,ne,nw"}var l=this.handles.split(",");this.handles={};for(var g=0;g<l.length;g++){var j=c.trim(l[g]),e="ui-resizable-"+j;var h=c('<div class="ui-resizable-handle '+e+'"></div>');if(/sw|se|ne|nw/.test(j)){h.css({zIndex:++k.zIndex})}if("se"==j){h.addClass("ui-icon ui-icon-gripsmall-diagonal-se")}this.handles[j]=".ui-resizable-"+j;this.element.append(h)}}this._renderAxis=function(q){q=q||this.element;for(var n in this.handles){if(this.handles[n].constructor==String){this.handles[n]=c(this.handles[n],this.element).show()}if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var o=c(this.handles[n],this.element),p=0;p=/sw|ne|nw|se|n|s/.test(n)?o.outerHeight():o.outerWidth();var m=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");q.css(m,p);this._proportionallyResize()}if(!c(this.handles[n]).length){continue}}};this._renderAxis(this.element);this._handles=c(".ui-resizable-handle",this.element).disableSelection();this._handles.mouseover(function(){if(!f.resizing){if(this.className){var i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}f.axis=i&&i[1]?i[1]:"se"}});if(k.autoHide){this._handles.hide();c(this.element).addClass("ui-resizable-autohide").hover(function(){if(k.disabled){return}c(this).removeClass("ui-resizable-autohide");f._handles.show()},function(){if(k.disabled){return}if(!f.resizing){c(this).addClass("ui-resizable-autohide");f._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var e=function(g){c(g).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){e(this.element);var f=this.element;f.after(this.originalElement.css({position:f.css("position"),width:f.outerWidth(),height:f.outerHeight(),top:f.css("top"),left:f.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);e(this.originalElement);return this},_mouseCapture:function(f){var g=false;for(var e in this.handles){if(c(this.handles[e])[0]==f.target){g=true}}return !this.options.disabled&&g},_mouseStart:function(g){var j=this.options,f=this.element.position(),e=this.element;this.resizing=true;this.documentScroll={top:c(document).scrollTop(),left:c(document).scrollLeft()};if(e.is(".ui-draggable")||(/absolute/).test(e.css("position"))){e.css({position:"absolute",top:f.top,left:f.left})}this._renderProxy();var k=b(this.helper.css("left")),h=b(this.helper.css("top"));if(j.containment){k+=c(j.containment).scrollLeft()||0;h+=c(j.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:k,top:h};this.size=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalSize=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalPosition={left:k,top:h};this.sizeDiff={width:e.outerWidth()-e.width(),height:e.outerHeight()-e.height()};this.originalMousePosition={left:g.pageX,top:g.pageY};this.aspectRatio=(typeof j.aspectRatio=="number")?j.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var i=c(".ui-resizable-"+this.axis).css("cursor");c("body").css("cursor",i=="auto"?this.axis+"-resize":i);e.addClass("ui-resizable-resizing");this._propagate("start",g);return true},_mouseDrag:function(e){var h=this.helper,g=this.options,m={},q=this,j=this.originalMousePosition,n=this.axis;var r=(e.pageX-j.left)||0,p=(e.pageY-j.top)||0;var i=this._change[n];if(!i){return false}var l=i.apply(this,[e,r,p]),k=c.browser.msie&&c.browser.version<7,f=this.sizeDiff;this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey){l=this._updateRatio(l,e)}l=this._respectSize(l,e);this._propagate("resize",e);h.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length){this._proportionallyResize()}this._updateCache(l);this._trigger("resize",e,this.ui());return false},_mouseStop:function(h){this.resizing=false;var i=this.options,m=this;if(this._helper){var g=this._proportionallyResizeElements,e=g.length&&(/textarea/i).test(g[0].nodeName),f=e&&c.ui.hasScroll(g[0],"left")?0:m.sizeDiff.height,k=e?0:m.sizeDiff.width;var n={width:(m.helper.width()-k),height:(m.helper.height()-f)},j=(parseInt(m.element.css("left"),10)+(m.position.left-m.originalPosition.left))||null,l=(parseInt(m.element.css("top"),10)+(m.position.top-m.originalPosition.top))||null;if(!i.animate){this.element.css(c.extend(n,{top:l,left:j}))}m.helper.height(m.size.height);m.helper.width(m.size.width);if(this._helper&&!i.animate){this._proportionallyResize()}}c("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",h);if(this._helper){this.helper.remove()}return false},_updateVirtualBoundaries:function(g){var j=this.options,i,h,f,k,e;e={minWidth:a(j.minWidth)?j.minWidth:0,maxWidth:a(j.maxWidth)?j.maxWidth:Infinity,minHeight:a(j.minHeight)?j.minHeight:0,maxHeight:a(j.maxHeight)?j.maxHeight:Infinity};if(this._aspectRatio||g){i=e.minHeight*this.aspectRatio;f=e.minWidth/this.aspectRatio;h=e.maxHeight*this.aspectRatio;k=e.maxWidth/this.aspectRatio;if(i>e.minWidth){e.minWidth=i}if(f>e.minHeight){e.minHeight=f}if(h<e.maxWidth){e.maxWidth=h}if(k<e.maxHeight){e.maxHeight=k}}this._vBoundaries=e},_updateCache:function(e){var f=this.options;this.offset=this.helper.offset();if(a(e.left)){this.position.left=e.left}if(a(e.top)){this.position.top=e.top}if(a(e.height)){this.size.height=e.height}if(a(e.width)){this.size.width=e.width}},_updateRatio:function(h,g){var i=this.options,j=this.position,f=this.size,e=this.axis;if(a(h.height)){h.width=(h.height*this.aspectRatio)}else{if(a(h.width)){h.height=(h.width/this.aspectRatio)}}if(e=="sw"){h.left=j.left+(f.width-h.width);h.top=null}if(e=="nw"){h.top=j.top+(f.height-h.height);h.left=j.left+(f.width-h.width)}return h},_respectSize:function(l,g){var j=this.helper,i=this._vBoundaries,r=this._aspectRatio||g.shiftKey,q=this.axis,t=a(l.width)&&i.maxWidth&&(i.maxWidth<l.width),m=a(l.height)&&i.maxHeight&&(i.maxHeight<l.height),h=a(l.width)&&i.minWidth&&(i.minWidth>l.width),s=a(l.height)&&i.minHeight&&(i.minHeight>l.height);if(h){l.width=i.minWidth}if(s){l.height=i.minHeight}if(t){l.width=i.maxWidth}if(m){l.height=i.maxHeight}var f=this.originalPosition.left+this.originalSize.width,p=this.position.top+this.size.height;var k=/sw|nw|w/.test(q),e=/nw|ne|n/.test(q);if(h&&k){l.left=f-i.minWidth}if(t&&k){l.left=f-i.maxWidth}if(s&&e){l.top=p-i.minHeight}if(m&&e){l.top=p-i.maxHeight}var n=!l.width&&!l.height;if(n&&!l.left&&l.top){l.top=null}else{if(n&&!l.top&&l.left){l.left=null}}return l},_proportionallyResize:function(){var k=this.options;if(!this._proportionallyResizeElements.length){return}var g=this.helper||this.element;for(var f=0;f<this._proportionallyResizeElements.length;f++){var h=this._proportionallyResizeElements[f];if(!this.borderDif){var e=[h.css("borderTopWidth"),h.css("borderRightWidth"),h.css("borderBottomWidth"),h.css("borderLeftWidth")],j=[h.css("paddingTop"),h.css("paddingRight"),h.css("paddingBottom"),h.css("paddingLeft")];this.borderDif=c.map(e,function(l,n){var m=parseInt(l,10)||0,o=parseInt(j[n],10)||0;return m+o})}if(c.browser.msie&&!(!(c(g).is(":hidden")||c(g).parents(":hidden").length))){continue}h.css({height:(g.height()-this.borderDif[0]-this.borderDif[2])||0,width:(g.width()-this.borderDif[1]-this.borderDif[3])||0})}},_renderProxy:function(){var f=this.element,i=this.options;this.elementOffset=f.offset();if(this._helper){this.helper=this.helper||c('<div style="overflow:hidden;"></div>');var e=c.browser.msie&&c.browser.version<7,g=(e?1:0),h=(e?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+h,height:this.element.outerHeight()+h,position:"absolute",left:this.elementOffset.left-g+"px",top:this.elementOffset.top-g+"px",zIndex:++i.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(g,f,e){return{width:this.originalSize.width+f}},w:function(h,f,e){var j=this.options,g=this.originalSize,i=this.originalPosition;return{left:i.left+f,width:g.width-f}},n:function(h,f,e){var j=this.options,g=this.originalSize,i=this.originalPosition;return{top:i.top+e,height:g.height-e}},s:function(g,f,e){return{height:this.originalSize.height+e}},se:function(g,f,e){return c.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[g,f,e]))},sw:function(g,f,e){return c.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[g,f,e]))},ne:function(g,f,e){return c.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[g,f,e]))},nw:function(g,f,e){return c.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[g,f,e]))}},_propagate:function(f,e){c.ui.plugin.call(this,f,[e,this.ui()]);(f!="resize"&&this._trigger(f,e,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});c.extend(c.ui.resizable,{version:"1.8.18"});c.ui.plugin.add("resizable","alsoResize",{start:function(f,g){var e=c(this).data("resizable"),i=e.options;var h=function(j){c(j).each(function(){var k=c(this);k.data("resizable-alsoresize",{width:parseInt(k.width(),10),height:parseInt(k.height(),10),left:parseInt(k.css("left"),10),top:parseInt(k.css("top"),10)})})};if(typeof(i.alsoResize)=="object"&&!i.alsoResize.parentNode){if(i.alsoResize.length){i.alsoResize=i.alsoResize[0];h(i.alsoResize)}else{c.each(i.alsoResize,function(j){h(j)})}}else{h(i.alsoResize)}},resize:function(g,i){var f=c(this).data("resizable"),j=f.options,h=f.originalSize,l=f.originalPosition;var k={height:(f.size.height-h.height)||0,width:(f.size.width-h.width)||0,top:(f.position.top-l.top)||0,left:(f.position.left-l.left)||0},e=function(m,n){c(m).each(function(){var q=c(this),r=c(this).data("resizable-alsoresize"),p={},o=n&&n.length?n:q.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];c.each(o,function(s,u){var t=(r[u]||0)+(k[u]||0);if(t&&t>=0){p[u]=t||null}});q.css(p)})};if(typeof(j.alsoResize)=="object"&&!j.alsoResize.nodeType){c.each(j.alsoResize,function(m,n){e(m,n)})}else{e(j.alsoResize)}},stop:function(e,f){c(this).removeData("resizable-alsoresize")}});c.ui.plugin.add("resizable","animate",{stop:function(i,n){var p=c(this).data("resizable"),j=p.options;var h=p._proportionallyResizeElements,e=h.length&&(/textarea/i).test(h[0].nodeName),f=e&&c.ui.hasScroll(h[0],"left")?0:p.sizeDiff.height,l=e?0:p.sizeDiff.width;var g={width:(p.size.width-l),height:(p.size.height-f)},k=(parseInt(p.element.css("left"),10)+(p.position.left-p.originalPosition.left))||null,m=(parseInt(p.element.css("top"),10)+(p.position.top-p.originalPosition.top))||null; +p.element.animate(c.extend(g,m&&k?{top:m,left:k}:{}),{duration:j.animateDuration,easing:j.animateEasing,step:function(){var o={width:parseInt(p.element.css("width"),10),height:parseInt(p.element.css("height"),10),top:parseInt(p.element.css("top"),10),left:parseInt(p.element.css("left"),10)};if(h&&h.length){c(h[0]).css({width:o.width,height:o.height})}p._updateCache(o);p._propagate("resize",i)}})}});c.ui.plugin.add("resizable","containment",{start:function(f,r){var t=c(this).data("resizable"),j=t.options,l=t.element;var g=j.containment,k=(g instanceof c)?g.get(0):(/parent/.test(g))?l.parent().get(0):g;if(!k){return}t.containerElement=c(k);if(/document/.test(g)||g==document){t.containerOffset={left:0,top:0};t.containerPosition={left:0,top:0};t.parentData={element:c(document),left:0,top:0,width:c(document).width(),height:c(document).height()||document.body.parentNode.scrollHeight}}else{var n=c(k),i=[];c(["Top","Right","Left","Bottom"]).each(function(p,o){i[p]=b(n.css("padding"+o))});t.containerOffset=n.offset();t.containerPosition=n.position();t.containerSize={height:(n.innerHeight()-i[3]),width:(n.innerWidth()-i[1])};var q=t.containerOffset,e=t.containerSize.height,m=t.containerSize.width,h=(c.ui.hasScroll(k,"left")?k.scrollWidth:m),s=(c.ui.hasScroll(k)?k.scrollHeight:e);t.parentData={element:k,left:q.left,top:q.top,width:h,height:s}}},resize:function(g,q){var t=c(this).data("resizable"),i=t.options,f=t.containerSize,p=t.containerOffset,m=t.size,n=t.position,r=t._aspectRatio||g.shiftKey,e={top:0,left:0},h=t.containerElement;if(h[0]!=document&&(/static/).test(h.css("position"))){e=p}if(n.left<(t._helper?p.left:0)){t.size.width=t.size.width+(t._helper?(t.position.left-p.left):(t.position.left-e.left));if(r){t.size.height=t.size.width/i.aspectRatio}t.position.left=i.helper?p.left:0}if(n.top<(t._helper?p.top:0)){t.size.height=t.size.height+(t._helper?(t.position.top-p.top):t.position.top);if(r){t.size.width=t.size.height*i.aspectRatio}t.position.top=t._helper?p.top:0}t.offset.left=t.parentData.left+t.position.left;t.offset.top=t.parentData.top+t.position.top;var l=Math.abs((t._helper?t.offset.left-e.left:(t.offset.left-e.left))+t.sizeDiff.width),s=Math.abs((t._helper?t.offset.top-e.top:(t.offset.top-p.top))+t.sizeDiff.height);var k=t.containerElement.get(0)==t.element.parent().get(0),j=/relative|absolute/.test(t.containerElement.css("position"));if(k&&j){l-=t.parentData.left}if(l+t.size.width>=t.parentData.width){t.size.width=t.parentData.width-l;if(r){t.size.height=t.size.width/t.aspectRatio}}if(s+t.size.height>=t.parentData.height){t.size.height=t.parentData.height-s;if(r){t.size.width=t.size.height*t.aspectRatio}}},stop:function(f,n){var q=c(this).data("resizable"),g=q.options,l=q.position,m=q.containerOffset,e=q.containerPosition,i=q.containerElement;var j=c(q.helper),r=j.offset(),p=j.outerWidth()-q.sizeDiff.width,k=j.outerHeight()-q.sizeDiff.height;if(q._helper&&!g.animate&&(/relative/).test(i.css("position"))){c(this).css({left:r.left-e.left-m.left,width:p,height:k})}if(q._helper&&!g.animate&&(/static/).test(i.css("position"))){c(this).css({left:r.left-e.left-m.left,width:p,height:k})}}});c.ui.plugin.add("resizable","ghost",{start:function(g,h){var e=c(this).data("resizable"),i=e.options,f=e.size;e.ghost=e.originalElement.clone();e.ghost.css({opacity:0.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof i.ghost=="string"?i.ghost:"");e.ghost.appendTo(e.helper)},resize:function(f,g){var e=c(this).data("resizable"),h=e.options;if(e.ghost){e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})}},stop:function(f,g){var e=c(this).data("resizable"),h=e.options;if(e.ghost&&e.helper){e.helper.get(0).removeChild(e.ghost.get(0))}}});c.ui.plugin.add("resizable","grid",{resize:function(e,m){var p=c(this).data("resizable"),h=p.options,k=p.size,i=p.originalSize,j=p.originalPosition,n=p.axis,l=h._aspectRatio||e.shiftKey;h.grid=typeof h.grid=="number"?[h.grid,h.grid]:h.grid;var g=Math.round((k.width-i.width)/(h.grid[0]||1))*(h.grid[0]||1),f=Math.round((k.height-i.height)/(h.grid[1]||1))*(h.grid[1]||1);if(/^(se|s|e)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f}else{if(/^(ne)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f;p.position.top=j.top-f}else{if(/^(sw)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f;p.position.left=j.left-g}else{p.size.width=i.width+g;p.size.height=i.height+f;p.position.top=j.top-f;p.position.left=j.left-g}}}}});var b=function(e){return parseInt(e,10)||0};var a=function(e){return !isNaN(parseInt(e,10))}})(jQuery);/*! + * jQuery hashchange event - v1.3 - 7/21/2010 + * http://benalman.com/projects/jquery-hashchange-plugin/ + * + * Copyright (c) 2010 "Cowboy" Ben Alman + * Dual licensed under the MIT and GPL licenses. + * http://benalman.com/about/license/ + */ +(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this); +(function(c){var a=c.scrollTo=function(f,e,d){c(window).scrollTo(f,e,d)};a.defaults={axis:"xy",duration:parseFloat(c.fn.jquery)>=1.3?0:1};a.window=function(d){return c(window)._scrollable()};c.fn._scrollable=function(){return this.map(function(){var e=this,d=!e.nodeName||c.inArray(e.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!d){return e}var f=(e.contentWindow||e).document||e.ownerDocument||e;return c.browser.safari||f.compatMode=="BackCompat"?f.body:f.documentElement})};c.fn.scrollTo=function(f,e,d){if(typeof e=="object"){d=e;e=0}if(typeof d=="function"){d={onAfter:d}}if(f=="max"){f=9000000000}d=c.extend({},a.defaults,d);e=e||d.speed||d.duration;d.queue=d.queue&&d.axis.length>1;if(d.queue){e/=2}d.offset=b(d.offset);d.over=b(d.over);return this._scrollable().each(function(){var l=this,j=c(l),k=f,i,g={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}k=c(k,this);case"object":if(k.is||k.style){i=(k=c(k)).offset()}}c.each(d.axis.split(""),function(q,r){var s=r=="x"?"Left":"Top",u=s.toLowerCase(),p="scroll"+s,o=l[p],n=a.max(l,r);if(i){g[p]=i[u]+(m?0:o-j.offset()[u]);if(d.margin){g[p]-=parseInt(k.css("margin"+s))||0;g[p]-=parseInt(k.css("border"+s+"Width"))||0}g[p]+=d.offset[u]||0;if(d.over[u]){g[p]+=k[r=="x"?"width":"height"]()*d.over[u]}}else{var t=k[u];g[p]=t.slice&&t.slice(-1)=="%"?parseFloat(t)/100*n:t}if(/^\d+$/.test(g[p])){g[p]=g[p]<=0?0:Math.min(g[p],n)}if(!q&&d.queue){if(o!=g[p]){h(d.onAfterFirst)}delete g[p]}});h(d.onAfter);function h(n){j.animate(g,e,d.easing,n&&function(){n.call(this,f,d)})}}).end()};a.max=function(j,i){var h=i=="x"?"Width":"Height",e="scroll"+h;if(!c(j).is("html,body")){return j[e]-c(j)[h.toLowerCase()]()}var g="client"+h,f=j.ownerDocument.documentElement,d=j.ownerDocument.body;return Math.max(f[e],d[e])-Math.min(f[g],d[g])};function b(d){return typeof d=="object"?d:{top:d,left:d}}})(jQuery); diff --git a/docs/html/md__benchmarks.html b/docs/html/md__benchmarks.html new file mode 100644 index 00000000..9ce81bbf --- /dev/null +++ b/docs/html/md__benchmarks.html @@ -0,0 +1,103 @@ +<!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.5"/> +<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.5 --> +</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), and Rapid JSON, one of the fastest C++ JSON parsers around.</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></tr> +<tr> +<td>Decode + Traverse + Dealloc (1 million times, seconds) </td><td>0.08 </td><td>305 </td><td>583 </td><td>105 </td></tr> +<tr> +<td>Decode / Traverse / Dealloc (breakdown) </td><td>0 / 0.08 / 0 </td><td>220 / 3.6 / 81 </td><td>294 / 0.9 / 287 </td><td>70 / 0.08 / 35 </td></tr> +<tr> +<td>Encode (1 million times, seconds) </td><td>3.2 </td><td>185 </td><td>650 </td><td>169 </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></tr> +<tr> +<td>Memory needed to store decoded wire (bytes / blocks) </td><td>0 / 0 </td><td>760 / 20 </td><td>65689 / 40 </td><td>328 / 1 </td></tr> +<tr> +<td>Transient memory allocated during decode (KB) </td><td>0 </td><td>1 </td><td>131 </td><td>4 </td></tr> +<tr> +<td>Generated source code size (KB) </td><td>4 </td><td>61 </td><td>0 </td><td>4 </td></tr> +<tr> +<td>Field access in handwritten traversal code </td><td>accessors </td><td>accessors </td><td>manual error checking </td><td>accessors </td></tr> +<tr> +<td>Library source code (KB) </td><td>15 </td><td>some subset of 3800 </td><td>87 </td><td>43 </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>XML: typically even slower than JSON, but has the advantage that it can be parsed with a schema to reduce error-checking boilerplate code.</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> diff --git a/docs/html/md__building.html b/docs/html/md__building.html new file mode 100644 index 00000000..15b26d53 --- /dev/null +++ b/docs/html/md__building.html @@ -0,0 +1,78 @@ +<!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.5"/> +<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.5 --> +</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>The system comes with a <code>cmake</code> file that should allow you to build the compiler <code>flatc</code> and the tests (optionally). 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>The cmake file will also build 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> diff --git a/docs/html/md__compiler.html b/docs/html/md__compiler.html new file mode 100644 index 00000000..fab13cd7 --- /dev/null +++ b/docs/html/md__compiler.html @@ -0,0 +1,77 @@ +<!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.5"/> +<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.5 --> +</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 ] file1 file2 .. +</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. 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>). Skips data.</li> +<li><code>-j</code> : Generate Java classes.</li> +<li><code>-b</code> : If data is contained in this file, generate a <code>filename_wire.bin</code> containing the binary flatbuffer.</li> +<li><code>-t</code> : If data is contained in this file, generate a <code>filename_wire.txt</code> (for debugging). </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> diff --git a/docs/html/md__cpp_usage.html b/docs/html/md__cpp_usage.html new file mode 100644 index 00000000..4023544f --- /dev/null +++ b/docs/html/md__cpp_usage.html @@ -0,0 +1,142 @@ +<!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.5"/> +<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.5 --> +</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, Offset<void>(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.</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">fbb.Finish(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> +<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>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> diff --git a/docs/html/md__grammar.html b/docs/html/md__grammar.html new file mode 100644 index 00000000..96ffe576 --- /dev/null +++ b/docs/html/md__grammar.html @@ -0,0 +1,81 @@ +<!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.5"/> +<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.5 --> +</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> diff --git a/docs/html/md__internals.html b/docs/html/md__internals.html new file mode 100644 index 00000000..e90e6f40 --- /dev/null +++ b/docs/html/md__internals.html @@ -0,0 +1,179 @@ +<!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.5"/> +<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.5 --> +</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.</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>offset_t</code>, which is currently always a <code>uint32_t</code>, and is used to refer to all tables/unions/strings/vectors. 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>offset_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>offset_t</code>, since vtables may be stored anywhere), followed by all the fields as aligned scalars. 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 currently 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 N the offsets, where N is the amount of field 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 count.</p> +<h3>Construction</h3> +<p>The current implementation constructs these buffers backwards, 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> diff --git a/docs/html/md__java_usage.html b/docs/html/md__java_usage.html new file mode 100644 index 00000000..7a90aeaf --- /dev/null +++ b/docs/html/md__java_usage.html @@ -0,0 +1,102 @@ +<!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.5"/> +<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.5 --> +</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>There's experimental support for reading 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>getRootAsMonster</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>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.inventory_length(); 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 (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 even have arguments for nested structs.</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> +<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> diff --git a/docs/html/md__schemas.html b/docs/html/md__schemas.html new file mode 100644 index 00000000..d1faa73c --- /dev/null +++ b/docs/html/md__schemas.html @@ -0,0 +1,144 @@ +<!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.5"/> +<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.5 --> +</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.</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 require you wrap the inner vector in a struct/table rather than writing <code>[[type]]</code>.</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. If you omit the underlying type, it will be <code>short</code>.</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.</p> +<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>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> +</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.</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. </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> diff --git a/docs/html/md__white_paper.html b/docs/html/md__white_paper.html new file mode 100644 index 00000000..b2ea6103 --- /dev/null +++ b/docs/html/md__white_paper.html @@ -0,0 +1,101 @@ +<!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.5"/> +<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.5 --> +</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> diff --git a/docs/html/nav_f.png b/docs/html/nav_f.png Binary files differnew file mode 100644 index 00000000..72a58a52 --- /dev/null +++ b/docs/html/nav_f.png diff --git a/docs/html/nav_g.png b/docs/html/nav_g.png Binary files differnew file mode 100644 index 00000000..2093a237 --- /dev/null +++ b/docs/html/nav_g.png diff --git a/docs/html/nav_h.png b/docs/html/nav_h.png Binary files differnew file mode 100644 index 00000000..33389b10 --- /dev/null +++ b/docs/html/nav_h.png diff --git a/docs/html/navtree.css b/docs/html/navtree.css new file mode 100644 index 00000000..41a9cb96 --- /dev/null +++ b/docs/html/navtree.css @@ -0,0 +1,143 @@ +#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; } +} + diff --git a/docs/html/navtree.js b/docs/html/navtree.js new file mode 100644 index 00000000..30cc01d3 --- /dev/null +++ b/docs/html/navtree.js @@ -0,0 +1,537 @@ +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 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 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 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'); + if (anchor.parent().attr('class')=='memItemLeft' || + anchor.parent().attr('class')=='fieldtype' || + anchor.parent().is(':header')) + { + pos = anchor.parent().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($(location).attr('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 = $(location).attr('hash'); + var anchor = $(aname); + if (anchor.parent().attr('class')=='memItemLeft'){ + var rows = $('.memberdecls tr[class$="'+ + window.location.hash.substring(1)+'"]'); + glowEffect(rows.children(),300); // member without details + } else if (anchor.parents().slice(2).prop('tagName')=='TR') { + glowEffect(anchor.parents('div.memitem'),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($(location).attr('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]; + 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 + //root=root.replace(/_source\./,'.'); // source link to doc link + } + 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($(location).attr('pathname'))+$(location).attr('hash')); + } 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,window.location.hash,relpath); + showRoot(); + }); + + $(window).bind('hashchange', function(){ + if (window.location.hash && window.location.hash.length>1){ + var a; + if ($(location).attr('hash')){ + var clslink=stripPath($(location).attr('pathname'))+':'+ + $(location).attr('hash').substring(1); + a=$('.item a[class$="'+clslink+'"]'); + } + if (a==null || !$(a).parent().parent().hasClass('selected')){ + $('.item').removeClass('selected'); + $('.item').removeAttr('id'); + } + var link=stripPath2($(location).attr('pathname')); + navTo(o,link,$(location).attr('hash'),relpath); + } else if (!animationInProgress) { + $('#doc-content').scrollTop(0); + $('.item').removeClass('selected'); + $('.item').removeAttr('id'); + navTo(o,toroot,window.location.hash,relpath); + } + }) +} + diff --git a/docs/html/navtreeindex0.js b/docs/html/navtreeindex0.js new file mode 100644 index 00000000..45204501 --- /dev/null +++ b/docs/html/navtreeindex0.js @@ -0,0 +1,14 @@ +var NAVTREEINDEX0 = +{ +"index.html":[], +"md__benchmarks.html":[5], +"md__building.html":[0], +"md__compiler.html":[1], +"md__cpp_usage.html":[3], +"md__grammar.html":[8], +"md__internals.html":[7], +"md__java_usage.html":[4], +"md__schemas.html":[2], +"md__white_paper.html":[6], +"pages.html":[] +}; diff --git a/docs/html/open.png b/docs/html/open.png Binary files differnew file mode 100644 index 00000000..30f75c7e --- /dev/null +++ b/docs/html/open.png diff --git a/docs/html/pages.html b/docs/html/pages.html new file mode 100644 index 00000000..d6a1a0b8 --- /dev/null +++ b/docs/html/pages.html @@ -0,0 +1,81 @@ +<!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.5"/> +<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.5 --> +</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"><img src="ftv2node.png" alt="o" width="16" height="22" /><a class="el" href="md__building.html" target="_self">Building</a></td><td class="desc"></td></tr> +<tr id="row_1_"><td class="entry"><img src="ftv2node.png" alt="o" width="16" height="22" /><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"><img src="ftv2node.png" alt="o" width="16" height="22" /><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"><img src="ftv2node.png" alt="o" width="16" height="22" /><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"><img src="ftv2node.png" alt="o" width="16" height="22" /><a class="el" href="md__java_usage.html" target="_self">Use in Java</a></td><td class="desc"></td></tr> +<tr id="row_5_"><td class="entry"><img src="ftv2node.png" alt="o" width="16" height="22" /><a class="el" href="md__benchmarks.html" target="_self">Benchmarks</a></td><td class="desc"></td></tr> +<tr id="row_6_" class="even"><td class="entry"><img src="ftv2node.png" alt="o" width="16" height="22" /><a class="el" href="md__white_paper.html" target="_self">FlatBuffers white paper</a></td><td class="desc"></td></tr> +<tr id="row_7_"><td class="entry"><img src="ftv2node.png" alt="o" width="16" height="22" /><a class="el" href="md__internals.html" target="_self">FlatBuffer Internals</a></td><td class="desc"></td></tr> +<tr id="row_8_" class="even"><td class="entry"><img src="ftv2lastnode.png" alt="\" width="16" height="22" /><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> diff --git a/docs/html/resize.js b/docs/html/resize.js new file mode 100644 index 00000000..a80decef --- /dev/null +++ b/docs/html/resize.js @@ -0,0 +1,93 @@ +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){ + try { + var target = e.target; + while (target) { + if ($(target).css('-webkit-overflow-scrolling')=='touch') return; + target = target.parentNode; + } + e.preventDefault(); + } catch(err) { + e.preventDefault(); + } + }); +} + + diff --git a/docs/html/sync_off.png b/docs/html/sync_off.png Binary files differnew file mode 100644 index 00000000..3b443fc6 --- /dev/null +++ b/docs/html/sync_off.png diff --git a/docs/html/sync_on.png b/docs/html/sync_on.png Binary files differnew file mode 100644 index 00000000..e08320fb --- /dev/null +++ b/docs/html/sync_on.png diff --git a/docs/html/tab_a.png b/docs/html/tab_a.png Binary files differnew file mode 100644 index 00000000..3b725c41 --- /dev/null +++ b/docs/html/tab_a.png diff --git a/docs/html/tab_b.png b/docs/html/tab_b.png Binary files differnew file mode 100644 index 00000000..e2b4a863 --- /dev/null +++ b/docs/html/tab_b.png diff --git a/docs/html/tab_h.png b/docs/html/tab_h.png Binary files differnew file mode 100644 index 00000000..fd5cb705 --- /dev/null +++ b/docs/html/tab_h.png diff --git a/docs/html/tab_s.png b/docs/html/tab_s.png Binary files differnew file mode 100644 index 00000000..ab478c95 --- /dev/null +++ b/docs/html/tab_s.png diff --git a/docs/html/tabs.css b/docs/html/tabs.css new file mode 100644 index 00000000..9cf578f2 --- /dev/null +++ b/docs/html/tabs.css @@ -0,0 +1,60 @@ +.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); +} diff --git a/docs/source/Benchmarks.md b/docs/source/Benchmarks.md new file mode 100755 index 00000000..c57e6ff8 --- /dev/null +++ b/docs/source/Benchmarks.md @@ -0,0 +1,49 @@ +# Benchmarks + +Comparing against other serialization solutions, running on Windows 7 +64bit. We use the LITE runtime for Protocol Buffers (less code / lower +overhead), and Rapid JSON, one of the fastest C++ JSON parsers around. + +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). + +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) | +|--------------------------------------------------------|-----------------------|-----------------------|-----------------------|-----------------------| +| Decode + Traverse + Dealloc (1 million times, seconds) | 0.08 | 305 | 583 | 105 | +| Decode / Traverse / Dealloc (breakdown) | 0 / 0.08 / 0 | 220 / 3.6 / 81 | 294 / 0.9 / 287 | 70 / 0.08 / 35 | +| Encode (1 million times, seconds) | 3.2 | 185 | 650 | 169 | +| Wire format size (normal / zlib, bytes) | 344 / 220 | 228 / 174 | 1475 / 322 | 1029 / 298 | +| Memory needed to store decoded wire (bytes / blocks) | 0 / 0 | 760 / 20 | 65689 / 40 | 328 / 1 | +| Transient memory allocated during decode (KB) | 0 | 1 | 131 | 4 | +| Generated source code size (KB) | 4 | 61 | 0 | 4 | +| Field access in handwritten traversal code | accessors | accessors | manual error checking | accessors | +| Library source code (KB) | 15 | some subset of 3800 | 87 | 43 | + +### Some other serialization systems we compared against but did not benchmark (yet), in rough order of applicability: + +- 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). +- msgpack: has very minimal forwards/backwards compatability 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. +- XML: typically even slower than JSON, but has the advantage that it can be + parsed with a schema to reduce error-checking boilerplate code. +- YAML: a superset of JSON and otherwise very similar. Used by e.g. Unity. +- 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. +- 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). + diff --git a/docs/source/Building.md b/docs/source/Building.md new file mode 100755 index 00000000..7df54da9 --- /dev/null +++ b/docs/source/Building.md @@ -0,0 +1,45 @@ +# Building + +The system comes with a `cmake` file that should allow you to build the +compiler `flatc` and the tests (optionally). For details on `cmake`, see +<http://www.cmake.org>. In brief, depending on your platform, use one of +e.g.: + + cmake -G "Unix Makefiles" + cmake -G "Visual Studio 10" + cmake -G "Xcode" + +Then, build as normal for your platform. This should result in a `flatc` +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. +`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! + +The cmake file will also build two sample executables, `sample_binary` and +`sample_text`, see the corresponding `.cpp` file in the samples directory. + +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 +`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 +`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). + +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. diff --git a/docs/source/Compiler.md b/docs/source/Compiler.md new file mode 100755 index 00000000..f3f76eba --- /dev/null +++ b/docs/source/Compiler.md @@ -0,0 +1,22 @@ +# Using the schema compiler + +Usage: + + flatc [ -c ] [ -j ] [ -b ] [ -t ] file1 file2 .. + +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. 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`). Skips data. + +- `-j` : Generate Java classes. + +- `-b` : If data is contained in this file, generate a + `filename_wire.bin` containing the binary flatbuffer. + +- `-t` : If data is contained in this file, generate a + `filename_wire.txt` (for debugging). + diff --git a/docs/source/CppUsage.md b/docs/source/CppUsage.md new file mode 100755 index 00000000..f55dd95c --- /dev/null +++ b/docs/source/CppUsage.md @@ -0,0 +1,226 @@ +# Use in C++ + +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 +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++ + +To start creating a buffer, create an instance of `FlatBufferBuilder` +which will contain the buffer as it grows: + + FlatBufferBuilder fbb; + +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: + + auto name = fbb.CreateString("MyMonster"); + + unsigned char inv[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + auto inventory = fbb.CreateVector(inv, 10); + +`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. + +`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. + +`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. + + Vec3 vec(1, 2, 3); + +`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. + +We have now serialized the non-scalar components of of the monster +example, so we could create the monster something like this: + + auto mloc = CreateMonster(fbb, &vec, 150, 80, name, inventory, Color_Red, Offset<void>(0), Any_NONE); + +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. + +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. + +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: + + MonsterBuilder mb(fbb); + mb.add_pos(&vec); + mb.add_hp(80); + mb.add_name(name); + mb.add_inventory(inventory); + auto mloc = mb.Finish(); + +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). + +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: + + fbb.Finish(mloc); + +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()`. + +`samples/sample_binary.cpp` is a complete code sample similar to +the code above, that also includes the reading code below. + +### Reading in C++ + +If you've received a buffer from somewhere (disk, network, etc.) you can +directly start traversing it using: + + auto monster = GetMonster(buffer_pointer); + +`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. + + 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 + +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. + +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 `sizeof()` and +`memcpy` on the pointer to a struct, or even an array of structs. + +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 `glVertexAttribPointer` +in OpenGL or similar APIs. + +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 `assert(FLATBUFFERS_LITTLEENDIAN)` +would be wise). + +## Text & schema parsing + +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. + +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. + +There are two ways to use text formats: + +### 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 +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. + + flatc -b myschema.fbs mydata.json + +This will generate the binary file `mydata_wire.bin` which can be loaded +as before. + +### 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 +required, otherwise just load the binary. + +This option is currently only available for C++, or Java through JNI. + +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 +`flatbuffers/idl.h`. + +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: + + flatbuffers::Parser parser; + +Now you can parse any number of text files in sequence: + + 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 +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. + +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. + +After each JSON file, the `Parser::fbb` member variable is the +`FlatBufferBuilder` that contains the binary buffer version of that +file, that you can access as described above. + +`samples/sample_text.cpp` is a code sample showing the above operations. + +### 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. + diff --git a/docs/source/FlatBuffers.md b/docs/source/FlatBuffers.md new file mode 100644 index 00000000..8f0401e4 --- /dev/null +++ b/docs/source/FlatBuffers.md @@ -0,0 +1,126 @@ +# FlatBuffers + +FlatBuffers is an efficient cross platform serialization library in for C++ and +Java. It was created at Google specifically for game development and other +performance-critical applications. + +It is available as open source under the Apache license, v2 (see LICENSE.txt). + +## Why use FlatBuffers? + +- **Access to serialized data without parsing/unpacking** - 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). + +- **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 + 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 + [benchmarks](md__benchmarks.html) for details. + +- **Flexible** - 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. + +- **Tiny code footprint** - 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. + +- **Strongly typed** - 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. + +- **Convenient to use** - 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). + + Java code supports object-reuse. + +- **Cross platform C++11/Java code with no dependencies** - 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 .. ? + +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. + +### But all the cool kids use JSON! + +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 *more* 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. + +Read more about the "why" of FlatBuffers in the +[white paper](md__white_paper.html). + +## Usage in brief + +This section is a quick rundown of how to use this system. Subsequent +sections provide a more in-depth usage guide. + +- 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. + +- Use `flatc` (the FlatBuffer compiler) to generate a C++ header (or Java + 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 + buffer recursively, often as simply as making a single function call. + +- Store or send your buffer somewhere! + +- 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 `object->field()`. + +## 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. +- Some [benchmarks](md__benchmarks.html) showing the advantage of using + 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. + +## Online resources + +- [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) diff --git a/docs/source/Grammar.md b/docs/source/Grammar.md new file mode 100755 index 00000000..6242bfa6 --- /dev/null +++ b/docs/source/Grammar.md @@ -0,0 +1,30 @@ +# Formal Grammar of the schema language + +schema = namespace\_decl | type\_decl | enum\_decl | root\_decl | object + +namespace\_decl = `namespace` ident ( `.` ident )* `;` + +type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}` + +enum\_decl = ( `enum` | `union` ) ident [ `:` type ] metadata `{` commasep( +enumval\_decl ) `}` + +root\_decl = `root_type` ident `;` + +field\_decl = type `:` ident [ `=` scalar ] metadata `;` + +type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` | +`float` | `long` | `ulong` | `double` + | `string` | `[` type `]` | ident + +enumval\_decl = ident [ `=` integer\_constant ] + +metadata = [ `(` commasep( ident [ `:` scalar ] ) `)` ] + +scalar = integer\_constant | float\_constant | `true` | `false` + +object = { commasep( ident `:` value ) } + +value = scalar | object | string\_constant | `[` commasep( value ) `]` + +commasep(x) = [ x ( `,` x )\* ] diff --git a/docs/source/Internals.md b/docs/source/Internals.md new file mode 100755 index 00000000..b744c784 --- /dev/null +++ b/docs/source/Internals.md @@ -0,0 +1,244 @@ +# FlatBuffer 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 +interested however, it should give you more of an appreciation of why +FlatBuffers is both efficient and convenient. + +### Format components + +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. + +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. + +### Format identification + +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. + +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. + +### Offsets + +The most important and generic offset type (see `flatbuffers.h`) is +`offset_t`, which is currently always a `uint32_t`, and is used to +refer to all tables/unions/strings/vectors. 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. + +The format starts with an `offset_t` to the root object in the buffer. + +We have two kinds of objects, structs and tables. + +### Structs + +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. + +### Tables + +These start with an `soffset_t` to a vtable (signed version of +`offset_t`, since vtables may be stored anywhere), followed by all the +fields as aligned scalars. Unlike structs, not all fields need to be +present. There is no set order and layout. + +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. + +The elements of a vtable are all of type `voffset_t`, which is currently +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. +The remaining elements are N the offsets, where N is the amount of field +declared in the schema when the code that constructed this buffer was +compiled (thus, the size of the table is N + 2). + +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. + +### Strings and Vectors + +Strings are simply a vector of bytes, and are always +null-terminated. Vectors are stored as contiguous aligned scalar +elements prefixed by a count. + +### Construction + +The current implementation constructs these buffers backwards, since +that significantly reduces the amount of bookkeeping and simplifies the +construction API. + +### Code example + +Here's an example of the code that gets generated for the `samples/monster.fbs`. +What follows is the entire file, broken up by comments: + + // automatically generated, do not modify + + #include "flatbuffers/flatbuffers.h" + + namespace MyGame { + namespace Sample { + +Nested namespace support. + + 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]; } + +Enums and convenient reverse lookup. + + 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]; } + +Unions share a lot with enums. + + struct Vec3; + struct Monster; + +Predeclare all datatypes since there may be circular references. + + 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); + +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). +`EndianScalar` 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. + + 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); } + }; + +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 `Table`, which contains the `GetField` 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. + + 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)); } + }; + +`MonsterBuilder` is the base helper struct to construct a table using a +`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) { + 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(); + } + +`CreateMonster` is a convenience function that calls all functions in +`MonsterBuilder` 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. + + inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot<Monster>(buf); } + +This function is only generated for the root table type, to be able to +start traversing a FlatBuffer from a raw buffer pointer. + + }; // namespace MyGame + }; // namespace Sample + + diff --git a/docs/source/JavaUsage.md b/docs/source/JavaUsage.md new file mode 100755 index 00000000..10828b7c --- /dev/null +++ b/docs/source/JavaUsage.md @@ -0,0 +1,79 @@ +# Use in Java + +There's experimental support for reading 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 `getRootAsMonster` 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. + +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.inventory_length(); 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 (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 even have arguments for nested structs. + +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. + +## 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. diff --git a/docs/source/Schemas.md b/docs/source/Schemas.md new file mode 100755 index 00000000..7bb3a732 --- /dev/null +++ b/docs/source/Schemas.md @@ -0,0 +1,198 @@ +# Writing a 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 +languages, and also to users of other IDLs. Let's look at an example +first: + + // 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; + +(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). + +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: + +- 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. + +- 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 `deprecated` 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!). + +- You may change field names and table names, if you're ok with your + code breaking until you've renamed them there too. + + + +### Structs + +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 `Vec3`). 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). + +### Types + +Builtin scalar types are: + +- 8 bit: `byte ubyte bool` + +- 16 bit: `short ushort` + +- 32 bit: `int uint float` + +- 64 bit: `long ulong double` + +- Vector of any other type (denoted with `[type]`). Nesting vectors + require you wrap the inner vector in a struct/table rather than + writing `[[type]]`. + +- `string`, which may only hold UTF-8 or 7-bit ASCII. For other text encodings + or general binary data use vectors (`[byte]` or `[ubyte]`) instead. + +- References to other tables or structs, enums or unions (see + below). + +You can't change types of fields once they're used, with the exception +of same-size data where a `reinterpret_cast` would give you a desirable result, +e.g. you could change a `uint` to an `int` if no values in current data use the +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). + +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. + +### Enums + +Define a sequence of named constants, each with a given value, or +increasing by one from the previous one. The default first value +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. If you omit the underlying +type, it will be `short`. + +### 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 +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. + +### 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. + +### Root type + +This declares what you consider to be the root table (or struct) of the +serialized data. + +### Comments & documentation + +May be written as in most C-based languages. Additionally, a triple +comment (`///`) 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. + +### Attributes + +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. +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). + +Current understood attributes: + +- `deprecated` (on a field): do not generate accessors for this field + anymore, code should stop using this data. +- `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. +- `force_align: size` (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 `FlatBufferBuilder`). + +## Gotchas + +### Schemas and version control + +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. + +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. + +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. + diff --git a/docs/source/WhitePaper.md b/docs/source/WhitePaper.md new file mode 100755 index 00000000..71b2b240 --- /dev/null +++ b/docs/source/WhitePaper.md @@ -0,0 +1,127 @@ +# FlatBuffers white paper + +This document tries to shed some light on to the "why" of FlatBuffers, a +new serialization library. + +## Motivation + +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. + +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. + +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. + +FlatBuffers is what you get if you try anyway. + +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. + +## FlatBuffers + +*This is a summary of FlatBuffers functionality, with some rationale. +A more detailed description can be found in the FlatBuffers +documentation.* + +### Summary + +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. + +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. + +### Tables + +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. + +Tables get around this by using an extra indirection to access fields, +through a *vtable*. 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. + +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. + +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). + +### Schemas + +While schemas reduce some generality (you can't just read any data +without having its schema), they have a lot of upsides: + +- Most information about the format can be factored into the generated + code, reducing memory needed to store data, and time to access it. + +- The strong typing of the data definitions means less error + checking/handling at runtime (less can go wrong). + +- A schema enables us to access a buffer without parsing. + +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: + +- 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. + +- Differentiating between tables and structs (see above). Effectively + all table fields are `optional`, and all struct fields are + `required`. + +- Having a native vector type instead of `repeated`. 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. + +- Having a native `union` type instead of using a series of `optional` + fields, all of which must be checked individually. + +- Being able to define defaults for all scalars, instead of having to + deal with their optionality at each access. + +- A parser that can deal with both schemas and data definitions (JSON + compatible) uniformly. + + diff --git a/docs/source/doxyfile b/docs/source/doxyfile new file mode 100755 index 00000000..f1e1981b --- /dev/null +++ b/docs/source/doxyfile @@ -0,0 +1,2359 @@ +# Doxyfile 1.8.5 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "FlatBuffers" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is included in +# the documentation. The maximum height of the logo should not exceed 55 pixels +# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo +# to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = ".." + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese- +# Traditional, Croatian, Czech, Danish, Dutch, English, Esperanto, Farsi, +# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en, +# Korean, Korean-en, Latvian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, +# Turkish, Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = NO + +# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = NO + +# 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 +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = NO + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# 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 +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = NO + +# 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 +# part of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 1 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. +# +# Note For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by by putting a % sign in front of the word +# or globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# 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 +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = NO + +# 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) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# 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 +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = NO + +# This flag is only useful for Objective-C code. When set to YES local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO these classes will be included in the various overviews. This option has +# no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = NO + +# 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. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = NO + +# 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 + +# 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 + +# 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 +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the +# todo list. This list is created by putting \todo commands in the +# documentation. +# The default value is: YES. + +GENERATE_TODOLIST = NO + +# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the +# test list. This list is created by putting \test commands in the +# documentation. +# The default value is: YES. + +GENERATE_TESTLIST = NO + +# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = NO + +# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= NO + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if <section_label> ... \endif and \cond <section_label> +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES the list +# will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = NO + +# 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 + +# 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 + +# 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 +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# 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 +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. Do not use file names with spaces, bibtex cannot handle them. See +# also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = NO + +# 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 + +# 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 +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = NO + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO doxygen will only warn about wrong or incomplete parameter +# documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. +# Note: If this tag is empty the current directory is searched. + +INPUT = "FlatBuffers.md" \ + "Building.md" \ + "Compiler.md" \ + "Schemas.md" \ + "CppUsage.md" \ + "JavaUsage.md" \ + "Benchmarks.md" \ + "WhitePaper.md" \ + "Internals.md" \ + "Grammar.md" + +# 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 +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank the +# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, +# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, +# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, +# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, +# *.qsf, *.as and *.js. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.as \ + *.js + +# 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 + +# 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 +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# 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 = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# 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 +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# <filter> <input-file> +# +# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# 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 = + +# 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 +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = FlatBuffers.md + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES, then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = NO + +# 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, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# 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 = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = NO + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# 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 +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = ../footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user- +# defined cascading style sheet that is included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefor more robust against future updates. +# Doxygen will copy the style sheet file to the output directory. For an example +# see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# 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 +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# 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 = + +# 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 +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler ( hhc.exe). If non-empty +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated ( +# YES) or that it should be included in the master .chm file ( NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated ( +# YES) or a normal table of contents ( NO) in the .chm file. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = YES + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using prerendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use <access key> + S +# (what the <access key> is depends on the OS and browser, but it is typically +# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down +# key> to jump into the search results window, the results can be navigated +# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel +# the search. The filter options can be selected when the cursor is inside the +# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys> +# to select a filter and <Enter> or <escape> to activate or cancel the filter +# option. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +SEARCHENGINE = NO + +# 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 +# are two flavours of web server based searching depending on the +# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for +# searching and an index file used by the script. When EXTERNAL_SEARCH is +# enabled the indexing and searching needs to be provided by external tools. See +# the section "External Indexing and Searching" for details. +# The default value is: NO. +# This tag requires that the tag SEARCHENGINE is set to YES. + +SERVER_BASED_SEARCH = NO + +# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain the +# search results. +# +# Doxygen ships with an example indexer ( doxyindexer) and search engine +# (doxysearch.cgi) which are based on the open source search engine library +# Xapian (see: http://xapian.org/). +# +# See the section "External Indexing and Searching" for details. +# The default value is: NO. +# This tag requires that the tag SEARCHENGINE is set to YES. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will return the search results when EXTERNAL_SEARCH is enabled. +# +# Doxygen ships with an example indexer ( doxyindexer) and search engine +# (doxysearch.cgi) which are based on the open source search engine library +# Xapian (see: http://xapian.org/). See the section "External Indexing and +# Searching" for details. +# This tag requires that the tag SEARCHENGINE is set to YES. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. +# The default file is: searchdata.xml. +# This tag requires that the tag SEARCHENGINE is set to YES. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. +# This tag requires that the tag SEARCHENGINE is set to YES. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of +# to a relative location where the documentation can be found. The format is: +# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... +# This tag requires that the tag SEARCHENGINE is set to YES. + +EXTRA_SEARCH_MAPPINGS = + +#--------------------------------------------------------------------------- +# Configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output. +# The default value is: YES. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: latex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. +# +# Note that when enabling USE_PDFLATEX this option is only used for generating +# bitmaps for formulas in the HTML output, but not in the Makefile that is +# written to the output directory. +# The default file is: latex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate +# index for LaTeX. +# The default file is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX +# documents. This may be useful for small projects and may help to save some +# trees in general. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used by the +# printer. +# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x +# 14 inches) and executive (7.25 x 10.5 inches). +# The default value is: a4. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names +# that should be included in the LaTeX output. To get the times font for +# instance you can specify +# EXTRA_PACKAGES=times +# If left blank no extra packages will be included. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the +# generated LaTeX document. The header should contain everything until the first +# chapter. If it is left blank doxygen will generate a standard header. See +# section "Doxygen usage" for information on how to let doxygen write the +# default header to a separate file. +# +# Note: Only use a user-defined header if you know what you are doing! The +# following commands have a special meaning inside the header: $title, +# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will +# replace them by respectively the title of the page, the current date and time, +# only the current date, the version number of doxygen, the project name (see +# PROJECT_NAME), or the project number (see PROJECT_NUMBER). +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the +# generated LaTeX document. The footer should contain everything after the last +# chapter. If it is left blank doxygen will generate a standard footer. +# +# Note: Only use a user-defined footer if you know what you are doing! +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_FOOTER = + +# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the LATEX_OUTPUT output +# directory. Note that the files will be copied as-is; there are no commands or +# markers available. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EXTRA_FILES = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is +# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will +# contain links (just like the HTML output) instead of page references. This +# makes the output suitable for online browsing using a PDF viewer. +# The default value is: YES. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +PDF_HYPERLINKS = YES + +# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate +# the PDF file directly from the LaTeX files. Set this option to YES to get a +# higher quality PDF documentation. +# The default value is: YES. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode +# command to the generated LaTeX files. This will instruct LaTeX to keep running +# if errors occur, instead of asking the user for help. This option is also used +# when generating formulas in HTML. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_BATCHMODE = NO + +# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the +# index chapters (such as File Index, Compound Index, etc.) in the output. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_HIDE_INDICES = NO + +# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source +# code with syntax highlighting in the LaTeX output. +# +# Note that which sources are shown also depends on other settings such as +# SOURCE_BROWSER. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. See +# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# The default value is: plain. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# Configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The +# RTF output is optimized for Word 97 and may not look too pretty with other RTF +# readers/editors. +# The default value is: NO. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: rtf. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF +# documents. This may be useful for small projects and may help to save some +# trees in general. +# The default value is: NO. +# This tag requires that the tag GENERATE_RTF is set to YES. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will +# contain hyperlink fields. The RTF file will contain links (just like the HTML +# output) instead of page references. This makes the output suitable for online +# browsing using Word or some other Word compatible readers that support those +# fields. +# +# Note: WordPad (write) and others do not support links. +# The default value is: NO. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's config +# file, i.e. a series of assignments. You only have to provide replacements, +# missing definitions are set to their default value. +# +# See also section "Doxygen usage" for information on how to generate the +# default style sheet that doxygen normally uses. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an RTF document. Syntax is +# similar to doxygen's config file. A template extensions file can be generated +# using doxygen -e rtf extensionFile. +# This tag requires that the tag GENERATE_RTF is set to YES. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for +# classes and files. +# The default value is: NO. + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. A directory man3 will be created inside the directory specified by +# MAN_OUTPUT. +# The default directory is: man. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to the generated +# man pages. In case the manual section does not start with a number, the number +# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is +# optional. +# The default value is: .3. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it +# will generate one additional man file for each entity documented in the real +# man page(s). These additional files only source the real man page, but without +# them the man command would be unable to find the correct page. +# The default value is: NO. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that +# captures the structure of the code including all documentation. +# The default value is: NO. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: xml. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a +# validating XML parser to check the syntax of the XML files. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify a XML DTD, which can be used by a +# validating XML parser to check the syntax of the XML files. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program +# listings (including syntax highlighting and cross-referencing information) to +# the XML output. Note that enabling this will significantly increase the size +# of the XML output. +# The default value is: YES. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- + +# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files +# that can be used to generate PDF. +# The default value is: NO. + +GENERATE_DOCBOOK = NO + +# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in +# front of it. +# The default directory is: docbook. +# This tag requires that the tag GENERATE_DOCBOOK is set to YES. + +DOCBOOK_OUTPUT = docbook + +#--------------------------------------------------------------------------- +# Configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen +# Definitions (see http://autogen.sf.net) file that captures the structure of +# the code including all documentation. Note that this feature is still +# experimental and incomplete at the moment. +# The default value is: NO. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module +# file that captures the structure of the code including all documentation. +# +# Note that this feature is still experimental and incomplete at the moment. +# The default value is: NO. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary +# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI +# output from the Perl module output. +# The default value is: NO. +# This tag requires that the tag GENERATE_PERLMOD is set to YES. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely +# formatted so it can be parsed by a human reader. This is useful if you want to +# understand what is going on. On the other hand, if this tag is set to NO the +# size of the Perl module output will be much smaller and Perl will parse it +# just the same. +# The default value is: YES. +# This tag requires that the tag GENERATE_PERLMOD is set to YES. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file are +# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful +# so different doxyrules.make files included by the same Makefile don't +# overwrite each other's variables. +# This tag requires that the tag GENERATE_PERLMOD is set to YES. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all +# C-preprocessor directives found in the sources and include files. +# The default value is: YES. + +ENABLE_PREPROCESSING = NO + +# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names +# in the source code. If set to NO only conditional compilation will be +# performed. Macro expansion can be done in a controlled way by setting +# EXPAND_ONLY_PREDEF to YES. +# The default value is: NO. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then +# the macro expansion is limited to the macros specified with the PREDEFINED and +# EXPAND_AS_DEFINED tags. +# The default value is: NO. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES the includes files in the +# INCLUDE_PATH will be searched if a #include is found. +# The default value is: YES. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by the +# preprocessor. +# This tag requires that the tag SEARCH_INCLUDES is set to YES. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will be +# used. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that are +# defined before the preprocessor is started (similar to the -D option of e.g. +# gcc). The argument of the tag is a list of macros of the form: name or +# name=definition (no spaces). If the definition and the "=" are omitted, "=1" +# is assumed. To prevent a macro definition from being undefined via #undef or +# recursively expanded use the := operator instead of the = operator. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this +# tag can be used to specify a list of macro names that should be expanded. The +# macro definition that is found in the sources will be used. Use the PREDEFINED +# tag if you want to use a different macro definition that overrules the +# definition found in the source code. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will +# remove all refrences to function-like macros that are alone on a line, have an +# all uppercase name, and do not end with a semicolon. Such function macros are +# typically used for boiler-plate code, and will confuse the parser if not +# removed. +# The default value is: YES. +# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES tag can be used to specify one or more tag files. For each tag +# file the location of the external documentation should be added. The format of +# a tag file without this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where loc1 and loc2 can be relative or absolute paths or URLs. See the +# section "Linking to external documentation" for more information about the use +# of tag files. +# Note: Each tag file must have an unique name (where the name does NOT include +# the path). If a tag file is not located in the directory in which doxygen is +# run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create a +# tag file that is based on the input files it reads. See section "Linking to +# external documentation" for more information about the usage of tag files. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external class will be listed in the +# class index. If set to NO only the inherited external classes will be listed. +# The default value is: NO. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in +# the modules index. If set to NO, only the current project's groups will be +# listed. +# The default value is: YES. + +EXTERNAL_GROUPS = NO + +# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in +# the related pages index. If set to NO, only the current project's pages will +# be listed. +# The default value is: YES. + +EXTERNAL_PAGES = NO + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of 'which perl'). +# The default file (with absolute path) is: /usr/bin/perl. + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram +# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to +# NO turns the diagrams off. Note that this option also works with HAVE_DOT +# disabled, but it is recommended to install and use dot, since it yields more +# powerful graphs. +# The default value is: YES. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see: +# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide inheritance +# and usage relations if the target is undocumented or is not a class. +# The default value is: YES. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz (see: +# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent +# Bell Labs. The other options in this section have no effect if this option is +# set to NO +# The default value is: NO. + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed +# to run in parallel. When set to 0 doxygen will base this on the number of +# processors available in the system. You can set it explicitly to a value +# larger than 0 to get control over the balance between CPU load and processing +# speed. +# Minimum value: 0, maximum value: 32, default value: 0. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_NUM_THREADS = 0 + +# When you want a differently looking font n the dot files that doxygen +# generates you can specify the font name using DOT_FONTNAME. You need to make +# sure dot is able to find the font, which can be done by putting it in a +# standard location or by setting the DOTFONTPATH environment variable or by +# setting DOT_FONTPATH to the directory containing the font. +# The default value is: Helvetica. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of +# dot graphs. +# Minimum value: 4, maximum value: 24, default value: 10. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the default font as specified with +# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set +# the path where dot can find it using this tag. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_FONTPATH = + +# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for +# each documented class showing the direct and indirect inheritance relations. +# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a +# graph for each documented class showing the direct and indirect implementation +# dependencies (inheritance, containment, and class references variables) of the +# class with other documented classes. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for +# groups, showing the direct groups dependencies. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside the +# class node. If there are many fields or methods and many nodes the graph may +# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the +# number of items for each type to make the size more manageable. Set this to 0 +# for no limit. Note that the threshold may be exceeded by 50% before the limit +# is enforced. So when you set the threshold to 10, up to 15 fields may appear, +# but if the number exceeds 15, the total amount of fields shown is limited to +# 10. +# Minimum value: 0, maximum value: 100, default value: 10. +# This tag requires that the tag HAVE_DOT is set to YES. + +UML_LIMIT_NUM_FIELDS = 10 + +# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and +# collaboration graphs will show the relations between templates and their +# instances. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +TEMPLATE_RELATIONS = NO + +# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to +# YES then doxygen will generate a graph for each documented file showing the +# direct and indirect include dependencies of the file with other documented +# files. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +INCLUDE_GRAPH = YES + +# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are +# set to YES then doxygen will generate a graph for each documented file showing +# the direct and indirect include dependencies of the file with other documented +# files. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH tag is set to YES then doxygen will generate a call +# dependency graph for every global function or class method. +# +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller +# dependency graph for every global function or class method. +# +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical +# hierarchy of all classes instead of a textual one. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the +# dependencies a directory has on other directories in a graphical way. The +# dependency relations are determined by the #include relations between the +# files in the directories. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. +# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order +# to make the SVG files visible in IE 9+ (other browsers do not have this +# requirement). +# Possible values are: png, jpg, gif and svg. +# The default value is: png. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# +# Note that this requires a modern browser other than Internet Explorer. Tested +# and working are Firefox, Chrome, Safari, and Opera. +# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make +# the SVG files visible. Older versions of IE do not have SVG support. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +INTERACTIVE_SVG = NO + +# The DOT_PATH tag can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the \dotfile +# command). +# This tag requires that the tag HAVE_DOT is set to YES. + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the \mscfile +# command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes +# that will be shown in the graph. If the number of nodes in a graph becomes +# larger than this value, doxygen will truncate the graph, which is visualized +# by representing a node as a red box. Note that doxygen if the number of direct +# children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that +# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. +# Minimum value: 0, maximum value: 10000, default value: 50. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs +# generated by dot. A depth value of 3 means that only nodes reachable from the +# root by following a path via at most 3 edges will be shown. Nodes that lay +# further from the root node will be omitted. Note that setting this option to 1 +# or 2 may greatly reduce the computation time needed for large code bases. Also +# note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. +# Minimum value: 0, maximum value: 1000, default value: 0. +# This tag requires that the tag HAVE_DOT is set to YES. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not seem +# to support this out of the box. +# +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) support +# this, this feature is disabled by default. +# The default value is: NO. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page +# explaining the meaning of the various boxes and arrows in the dot generated +# graphs. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot +# files that are used to generate the various graphs. +# The default value is: YES. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_CLEANUP = YES diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h new file mode 100644 index 00000000..75ae59af --- /dev/null +++ b/include/flatbuffers/flatbuffers.h @@ -0,0 +1,685 @@ +/* + * 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. + */ + +#ifndef FLATBUFFERS_H_ +#define FLATBUFFERS_H_ + +#include <assert.h> + +#include <cstdint> +#include <cstring> +#include <string> +#include <type_traits> +#include <vector> + +#if __cplusplus <= 199711L && \ + (!defined(_MSC_VER) || _MSC_VER < 1600) && \ + (!defined(__GNUC__) || \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40603)) + #error A C++11 compatible compiler is required for FlatBuffers. + #error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ +#endif + +// The wire format uses a little endian encoding (since that's efficient for +// the common platforms). +#if !defined(FLATBUFFERS_LITTLEENDIAN) + #if defined(__GNUC__) || defined(__clang__) + #ifdef __BIG_ENDIAN__ + #define FLATBUFFERS_LITTLEENDIAN 0 + #else + #define FLATBUFFERS_LITTLEENDIAN 1 + #endif // __BIG_ENDIAN__ + #elif defined(_MSC_VER) + #define FLATBUFFERS_LITTLEENDIAN 1 + #else + #error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN. + #endif +#endif // !defined(FLATBUFFERS_LITTLEENDIAN) + +#define FLATBUFFERS_VERSION_MAJOR 1 +#define FLATBUFFERS_VERSION_MINOR 0 +#define FLATBUFFERS_VERSION_REVISION 0 +#define FLATBUFFERS_STRING_EXPAND(X) #X +#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) + +namespace flatbuffers { + +// Our default offset / size type, 32bit on purpose on 64bit systems. +// Also, using a consistent offset type maintains compatibility of serialized +// offset values between 32bit and 64bit systems. +typedef uint32_t uoffset_t; + +// Signed offsets for references that can go in both directions. +typedef int32_t soffset_t; + +// Offset/index used in v-tables, can be changed to uint8_t in +// format forks to save a bit of space if desired. +typedef uint16_t voffset_t; + +typedef uintmax_t largest_scalar_t; + +// Wrapper for uoffset_t to allow safe template specialization. +template<typename T> struct Offset { + uoffset_t o; + Offset() : o(0) {} + explicit Offset(uoffset_t _o) : o(_o) {} + Offset<void> Union() const { return Offset<void>(o); } +}; + +inline void EndianCheck() { + int endiantest = 1; + // If this fails, see FLATBUFFERS_LITTLEENDIAN above. + assert(*reinterpret_cast<char *>(&endiantest) == FLATBUFFERS_LITTLEENDIAN); + (void)endiantest; +} + +template<typename T> T EndianScalar(T t) { + #if FLATBUFFERS_LITTLEENDIAN + return t; + #else + // If you're on the few remaining big endian platforms, we make the bold + // assumption you're also on gcc/clang, and thus have bswap intrinsics: + if (sizeof(T) == 1) { // Compile-time if-then's. + return t; + } else if (sizeof(T) == 2) { + auto r = __builtin_bswap16(*reinterpret_cast<uint16_t *>(&t)); + return *reinterpret_cast<T *>(&r); + } else if (sizeof(T) == 4) { + auto r = __builtin_bswap32(*reinterpret_cast<uint32_t *>(&t)); + return *reinterpret_cast<T *>(&r); + } else if (sizeof(T) == 8) { + auto r = __builtin_bswap64(*reinterpret_cast<uint64_t *>(&t)); + return *reinterpret_cast<T *>(&r); + } else { + assert(0); + } + #endif +} + +template<typename T> T ReadScalar(const void *p) { + return EndianScalar(*reinterpret_cast<const T *>(p)); +} + +template<typename T> void WriteScalar(void *p, T t) { + *reinterpret_cast<T *>(p) = EndianScalar(t); +} + +template<typename T> size_t AlignOf() { + #ifdef _MSC_VER + return __alignof(T); + #else + return alignof(T); + #endif +} + +// When we read serialized data from memory, in the case of most scalars, +// we want to just read T, but in the case of Offset, we want to actually +// perform the indirection and return a pointer. +// The template specialization below does just that. +// It is wrapped in a struct since function templates can't overload on the +// return type like this. +// The typedef is for the convenience of callers of this function +// (avoiding the need for a trailing return decltype) +template<typename T> struct IndirectHelper { + typedef T return_type; + static return_type Read(const uint8_t *p, uoffset_t i) { + return EndianScalar((reinterpret_cast<const T *>(p))[i]); + } +}; +template<typename T> struct IndirectHelper<Offset<T>> { + typedef const T *return_type; + static return_type Read(const uint8_t *p, uoffset_t i) { + p += i * sizeof(uoffset_t); + return EndianScalar(reinterpret_cast<return_type>( + p + ReadScalar<uoffset_t>(p))); + } +}; +template<typename T> struct IndirectHelper<const T *> { + typedef const T &return_type; + static return_type Read(const uint8_t *p, uoffset_t i) { + return *reinterpret_cast<const T *>(p + i * sizeof(T)); + } +}; + +// This is used as a helper type for accessing vectors. +// Vector::data() assumes the vector elements start after the length field. +template<typename T> class Vector { + public: + uoffset_t Length() const { return EndianScalar(length_); } + + typedef typename IndirectHelper<T>::return_type return_type; + + return_type Get(uoffset_t i) const { + assert(i < Length()); + return IndirectHelper<T>::Read(Data(), i); + } + + const void *GetStructFromOffset(size_t o) const { + return reinterpret_cast<const void *>(Data() + o); + } + + protected: + // This class is only used to access pre-existing data. Don't ever + // try to construct these manually. + Vector(); + + const uint8_t *Data() const { + return reinterpret_cast<const uint8_t *>(&length_ + 1); + } + + uoffset_t length_; +}; + +struct String : public Vector<char> { + const char *c_str() const { return reinterpret_cast<const char *>(Data()); } +}; + +// This is a minimal replication of std::vector<uint8_t> functionality, +// except growing from higher to lower addresses. i.e push_back() inserts data +// in the lowest address in the vector. +class vector_downward { + public: + explicit vector_downward(uoffset_t initial_size) + : reserved_(initial_size), + buf_(new uint8_t[reserved_]), + cur_(buf_ + reserved_) { + assert((initial_size & (sizeof(largest_scalar_t) - 1)) == 0); + } + + ~vector_downward() { delete[] buf_; } + + void clear() { cur_ = buf_ + reserved_; } + + uoffset_t growth_policy(uoffset_t size) { + return (size / 2) & ~(sizeof(largest_scalar_t) - 1); + } + + uint8_t *make_space(uoffset_t len) { + if (buf_ > cur_ - len) { + auto old_size = size(); + reserved_ += std::max(len, growth_policy(reserved_)); + auto new_buf = new uint8_t[reserved_]; + auto new_cur = new_buf + reserved_ - old_size; + memcpy(new_cur, cur_, old_size); + cur_ = new_cur; + delete[] buf_; + buf_ = new_buf; + } + cur_ -= len; + // Beyond this, signed offsets may not have enough range: + // (FlatBuffers > 2GB not supported). + assert(size() < (1UL << (sizeof(soffset_t) * 8 - 1)) - 1); + return cur_; + } + + uoffset_t size() const { + return static_cast<uoffset_t>(reserved_ - (cur_ - buf_)); + } + + uint8_t *data() const { return cur_; } + + uint8_t *data_at(uoffset_t offset) { return buf_ + reserved_ - offset; } + + // push() & fill() are most frequently called with small byte counts (<= 4), + // which is why we're using loops rather than calling memcpy/memset. + void push(const uint8_t *bytes, size_t size) { + auto dest = make_space(size); + for (size_t i = 0; i < size; i++) dest[i] = bytes[i]; + } + + void fill(size_t zero_pad_bytes) { + auto dest = make_space(zero_pad_bytes); + for (size_t i = 0; i < zero_pad_bytes; i++) dest[i] = 0; + } + + void pop(size_t bytes_to_remove) { cur_ += bytes_to_remove; } + + private: + uoffset_t reserved_; + uint8_t *buf_; + uint8_t *cur_; // Points at location between empty (below) and used (above). +}; + +// Converts a Field ID to a virtual table offset. +inline voffset_t FieldIndexToOffset(voffset_t field_id) { + // Should correspond to what EndTable() below builds up. + const int fixed_fields = 2; // Vtable size and Object Size. + return (field_id + fixed_fields) * sizeof(voffset_t); +} + +// Computes how many bytes you'd have to pad to be able to write an +// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in +// memory). +inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) { + return ((~buf_size) + 1) & (scalar_size - 1); +} + +// Helper class to hold data needed in creation of a flat buffer. +// To serialize data, you typically call one of the Create*() functions in +// the generated code, which in turn call a sequence of StartTable/PushElement/ +// AddElement/EndTable, or the builtin CreateString/CreateVector functions. +// Do this is depth-first order to build up a tree to the root. +// Finish() wraps up the buffer ready for transport. +class FlatBufferBuilder { + public: + explicit FlatBufferBuilder(uoffset_t initial_size = 1024) + : buf_(initial_size), minalign_(1), force_defaults_(false) { + offsetbuf_.reserve(16); // Avoid first few reallocs. + vtables_.reserve(16); + EndianCheck(); + flatbuffer_version_string = + "FlatBuffers " + FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "." + FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "." + FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION); + } + + // Reset all the state in this FlatBufferBuilder so it can be reused + // to construct another buffer. + void Clear() { + buf_.clear(); + offsetbuf_.clear(); + vtables_.clear(); + } + + // The current size of the serialized buffer, counting from the end. + uoffset_t GetSize() const { return buf_.size(); } + + // Get the serialized buffer (after you call Finish()). + uint8_t *GetBufferPointer() const { return buf_.data(); } + + const char *GetVersionString() { return flatbuffer_version_string; } + + void ForceDefaults(bool fd) { force_defaults_ = fd; } + + void Pad(size_t num_bytes) { buf_.fill(num_bytes); } + + void Align(size_t elem_size) { + if (elem_size > minalign_) minalign_ = elem_size; + buf_.fill(PaddingBytes(buf_.size(), elem_size)); + } + + void PushBytes(const uint8_t *bytes, size_t size) { + buf_.push(bytes, size); + } + + void PopBytes(size_t amount) { buf_.pop(amount); } + + template<typename T> void AssertScalarT() { + // The code assumes power of 2 sizes and endian-swap-ability. + static_assert(std::is_scalar<T>::value + // The Offset<T> type is essentially a scalar but fails is_scalar. + || sizeof(T) == sizeof(Offset<void>), + "T must be a scalar type"); + } + + // Write a single aligned scalar to the buffer + template<typename T> uoffset_t PushElement(T element) { + AssertScalarT<T>(); + T litle_endian_element = EndianScalar(element); + Align(sizeof(T)); + PushBytes(reinterpret_cast<uint8_t *>(&litle_endian_element), sizeof(T)); + return GetSize(); + } + + template<typename T> uoffset_t PushElement(Offset<T> off) { + // Special case for offsets: see ReferTo below. + return PushElement(ReferTo(off.o)); + } + + // When writing fields, we track where they are, so we can create correct + // vtables later. + void TrackField(voffset_t field, uoffset_t off) { + FieldLoc fl = { off, field }; + offsetbuf_.push_back(fl); + } + + // Like PushElement, but additionally tracks the field this represents. + template<typename T> void AddElement(voffset_t field, T e, T def) { + // We don't serialize values equal to the default. + if (e == def && !force_defaults_) return; + auto off = PushElement(e); + TrackField(field, off); + } + + template<typename T> void AddOffset(voffset_t field, Offset<T> off) { + if (!off.o) return; // An offset of 0 means NULL, don't store. + AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); + } + + template<typename T> void AddStruct(voffset_t field, const T *structptr) { + if (!structptr) return; // Default, don't store. + Align(AlignOf<T>()); + PushBytes(reinterpret_cast<const uint8_t *>(structptr), sizeof(T)); + TrackField(field, GetSize()); + } + + void AddStructOffset(voffset_t field, uoffset_t off) { + TrackField(field, off); + } + + // Offsets initially are relative to the end of the buffer (downwards). + // This function converts them to be relative to the current location + // in the buffer (when stored here), pointing upwards. + uoffset_t ReferTo(uoffset_t off) { + Align(sizeof(uoffset_t)); // To ensure GetSize() below is correct. + assert(off <= GetSize()); // Must refer to something already in buffer. + return GetSize() - off + sizeof(uoffset_t); + } + + void NotNested() { + // If you hit this, you're trying to construct an object when another + // hasn't finished yet. + assert(!offsetbuf_.size()); + } + + // From generated code (or from the parser), we call StartTable/EndTable + // with a sequence of AddElement calls in between. + uoffset_t StartTable() { + NotNested(); + return GetSize(); + } + + // This finishes one serialized object by generating the vtable if it's a + // table, comparing it against existing vtables, and writing the + // resulting vtable offset. + uoffset_t EndTable(uoffset_t start, voffset_t numfields) { + // Write the vtable offset, which is the start of any Table. + // We fill it's value later. + auto vtableoffsetloc = PushElement<uoffset_t>(0); + // Write a vtable, which consists entirely of voffset_t elements. + // It starts with the number of offsets, followed by a type id, followed + // by the offsets themselves. In reverse: + buf_.fill(numfields * sizeof(voffset_t)); + auto table_object_size = vtableoffsetloc - start; + assert(table_object_size < 0x10000); // Vtable use 16bit offsets. + PushElement<voffset_t>(table_object_size); + PushElement<voffset_t>(FieldIndexToOffset(numfields)); + // Write the offsets into the table + for (auto field_location = offsetbuf_.begin(); + field_location != offsetbuf_.end(); + ++field_location) { + auto pos = (vtableoffsetloc - field_location->off); + // If this asserts, it means you've set a field twice. + assert(!ReadScalar<voffset_t>(buf_.data() + field_location->id)); + WriteScalar<voffset_t>(buf_.data() + field_location->id, pos); + } + offsetbuf_.clear(); + auto vt1 = reinterpret_cast<voffset_t *>(buf_.data()); + auto vt1_size = *vt1; + auto vt_use = GetSize(); + // See if we already have generated a vtable with this exact same + // layout before. If so, make it point to the old one, remove this one. + for (auto it = vtables_.begin(); it != vtables_.end(); ++it) { + if (memcmp(buf_.data_at(*it), vt1, vt1_size)) continue; + vt_use = *it; + buf_.pop(GetSize() - vtableoffsetloc); + break; + } + // If this is a new vtable, remember it. + if (vt_use == GetSize()) { + vtables_.push_back(vt_use); + } + // Fill the vtable offset we created above. + // The offset points from the beginning of the object to where the + // vtable is stored. + // Offsets default direction is downward in memory for future format + // flexibility (storing all vtables at the start of the file). + WriteScalar(buf_.data_at(vtableoffsetloc), + static_cast<soffset_t>(vt_use) - + static_cast<soffset_t>(vtableoffsetloc)); + return vtableoffsetloc; + } + + uoffset_t StartStruct(size_t alignment) { + Align(alignment); + return GetSize(); + } + + uoffset_t EndStruct() { return GetSize(); } + + void ClearOffsets() { offsetbuf_.clear(); } + + // Aligns such that when "len" bytes are written, an object can be written + // after it with "alignment" without padding. + void PreAlign(size_t len, size_t alignment) { + buf_.fill(PaddingBytes(GetSize() + len, alignment)); + } + template<typename T> void PreAlign(size_t len) { + AssertScalarT<T>(); + PreAlign(len, sizeof(T)); + } + + // Functions to store strings, which are allowed to contain any binary data. + Offset<String> CreateString(const char *str, size_t len) { + NotNested(); + PreAlign<uoffset_t>(len + 1); // Always 0-terminated. + buf_.fill(1); + PushBytes(reinterpret_cast<const uint8_t *>(str), len); + PushElement(static_cast<uoffset_t>(len)); + return Offset<String>(GetSize()); + } + + Offset<String> CreateString(const char *str) { + return CreateString(str, strlen(str)); + } + + Offset<String> CreateString(const std::string &str) { + return CreateString(str.c_str(), str.length()); + } + + uoffset_t EndVector(size_t len) { + return PushElement(static_cast<uoffset_t>(len)); + } + + void StartVector(size_t len, size_t elemsize) { + PreAlign<uoffset_t>(len * elemsize); + PreAlign(len * elemsize, elemsize); // Just in case elemsize > uoffset_t. + } + + uint8_t *ReserveElements(size_t len, size_t elemsize) { + return buf_.make_space(len * elemsize); + } + + template<typename T> Offset<Vector<T>> CreateVector(const T *v, size_t len) { + NotNested(); + StartVector(len, sizeof(T)); + auto i = len; + do { + PushElement(v[--i]); + } while (i); + return Offset<Vector<T>>(EndVector(len)); + } + + template<typename T> Offset<Vector<T>> CreateVector(const std::vector<T> &v){ + return CreateVector(&v[0], v.size()); + } + + template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs( + const T *v, size_t len) { + NotNested(); + StartVector(len, AlignOf<T>()); + PushBytes(reinterpret_cast<const uint8_t *>(v), sizeof(T) * len); + return Offset<Vector<const T *>>(EndVector(len)); + } + + template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs( + const std::vector<T> &v) { + return CreateVector(&v[0], v.size()); + } + + // Finish serializing a buffer by writing the root offset. + template<typename T> void Finish(Offset<T> root) { + // This will cause the whole buffer to be aligned. + PreAlign(sizeof(uoffset_t), minalign_); + PushElement(ReferTo(root.o)); // Location of root. + } + + private: + struct FieldLoc { + uoffset_t off; + voffset_t id; + }; + + vector_downward buf_; + + // Accumulating offsets of table members while it is being built. + std::vector<FieldLoc> offsetbuf_; + + std::vector<uoffset_t> vtables_; // todo: Could make this into a map? + + size_t minalign_; + + bool force_defaults_; // Serialize values equal to their defaults anyway. + + // String which identifies the current version of FlatBuffers. + // flatbuffer_version_string is used by Google developers to identify which + // applications uploaded to Google Play are using this library. This allows + // the development team at Google to determine the popularity of the library. + // How it works: Applications that are uploaded to the Google Play Store are + // scanned for this version string. We track which applications are using it + // to measure popularity. You are free to remove it (of course) but we would + // appreciate if you left it in. + const char *flatbuffer_version_string; +}; + +// Helper to get a typed pointer to the root object contained in the buffer. +template<typename T> const T *GetRoot(const void *buf) { + EndianCheck(); + return reinterpret_cast<const T *>(reinterpret_cast<const uint8_t *>(buf) + + EndianScalar(*reinterpret_cast<const uoffset_t *>(buf))); +} + +// "structs_" are flat structures that do not have an offset table, thus +// always have all members present and do not support forwards/backwards +// compatible extensions. + +class Struct { + public: + template<typename T> T GetField(uoffset_t o) const { + return ReadScalar<T>(&data_[o]); + } + + template<typename T> T GetPointer(uoffset_t o) const { + auto p = &data_[o]; + return reinterpret_cast<T>(p + ReadScalar<uoffset_t>(p)); + } + + template<typename T> T GetStruct(uoffset_t o) const { + return reinterpret_cast<T>(&data_[o]); + } + + private: + uint8_t data_[1]; +}; + +// "tables" use an offset table (possibly shared) that allows fields to be +// omitted and added at will, but uses an extra indirection to read. +class Table { + public: + // This gets the field offset for any of the functions below it, or 0 + // if the field was not present. + voffset_t GetOptionalFieldOffset(voffset_t field) const { + // The vtable offset is always at the start. + auto vtable = &data_ - ReadScalar<soffset_t>(&data_); + // The first element is the size of the vtable (fields + type id + itself). + auto vtsize = ReadScalar<voffset_t>(vtable); + // If the field we're accessing is outside the vtable, we're reading older + // data, so it's the same as if the offset was 0 (not present). + return field < vtsize ? ReadScalar<voffset_t>(vtable + field) : 0; + } + + template<typename T> T GetField(voffset_t field, T defaultval) const { + auto field_offset = GetOptionalFieldOffset(field); + return field_offset ? ReadScalar<T>(&data_[field_offset]) : defaultval; + } + + template<typename P> P GetPointer(voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + auto p = &data_[field_offset]; + return field_offset + ? reinterpret_cast<P>(p + ReadScalar<uoffset_t>(p)) + : nullptr; + } + + template<typename P> P GetStruct(voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + return field_offset ? reinterpret_cast<P>(&data_[field_offset]) : nullptr; + } + + template<typename T> void SetField(voffset_t field, T val) { + auto field_offset = GetOptionalFieldOffset(field); + // If this asserts, you're trying to set a field that's not there + // (or should we return a bool instead?). + // check if it exists first using CheckField() + assert(field_offset); + WriteScalar(&data_[field_offset], val); + } + + bool CheckField(voffset_t field) const { + return GetOptionalFieldOffset(field) != 0; + } + + private: + // private constructor & copy constructor: you obtain instances of this + // class by pointing to existing data only + Table() {}; + Table(const Table &other) {}; + + uint8_t data_[1]; +}; + +// Utility function for reverse lookups on the EnumNames*() functions +// (in the generated C++ code) +// names must be NULL terminated. +inline size_t LookupEnum(const char **names, const char *name) { + for (const char **p = names; *p; p++) + if (!strcmp(*p, name)) + return p - names; + return -1; +} + +// These macros allow us to layout a struct with a guarantee that they'll end +// up looking the same on different compilers and platforms. +// It does this by disallowing the compiler to do any padding, and then +// does padding itself by inserting extra padding fields that make every +// element aligned to its own size. +// Additionally, it manually sets the alignment of the struct as a whole, +// which is typically its largest element, or a custom size set in the schema +// by the force_align attribute. +// These are used in the generated code only. + +#if defined(_MSC_VER) + #define MANUALLY_ALIGNED_STRUCT(alignment) \ + __pragma(pack(1)); \ + struct __declspec(align(alignment)) + #define STRUCT_END(name, size) \ + __pragma(pack()); \ + static_assert(sizeof(name) == size, "compiler breaks packing rules"); +#elif defined(__GNUC__) || defined(__clang__) + #define MANUALLY_ALIGNED_STRUCT(alignment) \ + _Pragma("pack(1)"); \ + struct __attribute__((aligned(alignment))) + #define STRUCT_END(name, size) \ + _Pragma("pack()"); \ + static_assert(sizeof(name) == size, "compiler breaks packing rules"); +#else + #error Unknown compiler, please define structure alignment macros +#endif + +} // namespace flatbuffers + +#endif // FLATBUFFERS_H_ diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h new file mode 100644 index 00000000..bac31a4d --- /dev/null +++ b/include/flatbuffers/idl.h @@ -0,0 +1,317 @@ +/* + * 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. + */ + +#ifndef FLATBUFFERS_IDL_H_ +#define FLATBUFFERS_IDL_H_ + +#include <map> +#include <memory> + +#include "flatbuffers/flatbuffers.h" + +// This file defines the data types representing a parsed IDL (Interface +// Definition Language) / schema file. + +namespace flatbuffers { + +// The order of these matters for Is*() functions below. +// Additionally, Parser::ParseType assumes bool..string is a contiguous range +// of type tokens. +#define FLATBUFFERS_GEN_TYPES_SCALAR(TD) \ + TD(NONE, "", uint8_t, byte ) \ + TD(UTYPE, "", uint8_t, byte ) /* begin scalars, ints */ \ + TD(BOOL, "bool", uint8_t, byte ) \ + TD(CHAR, "byte", int8_t, byte ) \ + TD(UCHAR, "ubyte", uint8_t, byte ) \ + TD(SHORT, "short", int16_t, short ) \ + TD(USHORT, "ushort", uint16_t, short ) \ + TD(INT, "int", int32_t, int ) \ + TD(UINT, "uint", uint32_t, int ) \ + TD(LONG, "long", int64_t, long ) \ + TD(ULONG, "ulong", uint64_t, long ) /* end ints */ \ + TD(FLOAT, "float", float, float ) /* begin floats */ \ + TD(DOUBLE, "double", double, double) /* end floats, scalars */ +#define FLATBUFFERS_GEN_TYPES_POINTER(TD) \ + TD(STRING, "string", Offset<void>, int) \ + TD(VECTOR, "", Offset<void>, int) \ + TD(STRUCT, "", Offset<void>, int) \ + TD(UNION, "", Offset<void>, int) + + +// using these macros, we can now write code dealing with types just once, e.g. + +/* +switch (type) { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + case BASE_TYPE_ ## ENUM: \ + // do something specific to CTYPE here + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD +} +*/ + +#define FLATBUFFERS_GEN_TYPES(TD) \ + FLATBUFFERS_GEN_TYPES_SCALAR(TD) \ + FLATBUFFERS_GEN_TYPES_POINTER(TD) + +// Create an enum for all the types above +enum BaseType { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) BASE_TYPE_ ## ENUM, + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD +}; + +#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + static_assert(sizeof(CTYPE) <= sizeof(largest_scalar_t), \ + "define largest_scalar_t as " #CTYPE); + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) +#undef FLATBUFFERS_TD + +inline bool IsScalar (BaseType t) { return t >= BASE_TYPE_UTYPE && + t <= BASE_TYPE_DOUBLE; } +inline bool IsInteger(BaseType t) { return t >= BASE_TYPE_UTYPE && + t <= BASE_TYPE_ULONG; } +inline bool IsFloat (BaseType t) { return t == BASE_TYPE_FLOAT || + t == BASE_TYPE_DOUBLE; } + +extern const char *const kTypeNames[]; +extern const char kTypeSizes[]; + +inline size_t SizeOf(BaseType t) { + return kTypeSizes[t]; +} + +struct StructDef; +struct EnumDef; + +// Represents any type in the IDL, which is a combination of the BaseType +// and additional information for vectors/structs_. +struct Type { + explicit Type(BaseType _base_type = BASE_TYPE_NONE, StructDef *_sd = nullptr) + : base_type(_base_type), + element(BASE_TYPE_NONE), + struct_def(_sd), + enum_def(nullptr) + {} + + Type VectorType() const { return Type(element, struct_def); } + + BaseType base_type; + BaseType element; // only set if t == BASE_TYPE_VECTOR + StructDef *struct_def; // only set if t or element == BASE_TYPE_STRUCT + EnumDef *enum_def; // only set if t == BASE_TYPE_UNION / BASE_TYPE_UTYPE +}; + +// Represents a parsed scalar value, it's type, and field offset. +struct Value { + Value() : constant("0"), offset(-1) {} + + Type type; + std::string constant; + int offset; +}; + +// Helper class that retains the original order of a set of identifiers and +// also provides quick lookup. +template<typename T> class SymbolTable { + public: + ~SymbolTable() { + for (auto it = vec.begin(); it != vec.end(); ++it) { + delete *it; + } + } + + bool Add(const std::string &name, T *e) { + vec.emplace_back(e); + auto it = dict.find(name); + if (it != dict.end()) return true; + dict[name] = e; + return false; + } + + T *Lookup(const std::string &name) const { + auto it = dict.find(name); + return it == dict.end() ? nullptr : it->second; + } + + private: + std::map<std::string, T *> dict; // quick lookup + + public: + std::vector<T *> vec; // Used to iterate in order of insertion +}; + +// Base class for all definition types (fields, structs_, enums_). +struct Definition { + Definition() : generated(false) {} + + std::string name; + std::string doc_comment; + SymbolTable<Value> attributes; + bool generated; // did we already output code for this definition? +}; + +struct FieldDef : public Definition { + FieldDef() : deprecated(false), padding(0) {} + + Value value; + bool deprecated; + size_t padding; // bytes to always pad after this field +}; + +struct StructDef : public Definition { + StructDef() + : fixed(false), + predecl(true), + sortbysize(true), + minalign(1), + bytesize(0) + {} + + void PadLastField(size_t minalign) { + auto padding = PaddingBytes(bytesize, minalign); + bytesize += padding; + if (fields.vec.size()) fields.vec.back()->padding = padding; + } + + SymbolTable<FieldDef> fields; + bool fixed; // If it's struct, not a table. + bool predecl; // If it's used before it was defined. + bool sortbysize; // Whether fields come in the declaration or size order. + size_t minalign; // What the whole object needs to be aligned to. + size_t bytesize; // Size if fixed. +}; + +inline bool IsStruct(const Type &type) { + return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed; +} + +inline size_t InlineSize(const Type &type) { + return IsStruct(type) ? type.struct_def->bytesize : SizeOf(type.base_type); +} + +inline size_t InlineAlignment(const Type &type) { + return IsStruct(type) ? type.struct_def->minalign : SizeOf(type.base_type); +} + +struct EnumVal { + EnumVal(const std::string &_name, int _val) + : name(_name), value(_val), struct_def(nullptr) {} + + std::string name; + std::string doc_comment; + int value; + StructDef *struct_def; // only set if this is a union +}; + +struct EnumDef : public Definition { + EnumDef() : is_union(false) {} + + StructDef *ReverseLookup(int enum_idx) { + assert(is_union); + for (auto it = vals.vec.begin() + 1; it != vals.vec.end(); ++it) { + if ((*it)->value == enum_idx) { + return (*it)->struct_def; + } + } + return nullptr; + } + + SymbolTable<EnumVal> vals; + bool is_union; + Type underlying_type; +}; + +class Parser { + public: + Parser() : + root_struct_def(nullptr), + source_(nullptr), + cursor_(nullptr), + line_(1) {} + + // Parse the string containing either schema or JSON data, which will + // populate the SymbolTable's or the FlatBufferBuilder above. + bool Parse(const char *_source); + + // Set the root type. May override the one set in the schema. + bool SetRootType(const char *name); + + private: + void Next(); + bool IsNext(int t); + void Expect(int t); + void ParseType(Type &type); + FieldDef &AddField(StructDef &struct_def, + const std::string &name, + const Type &type); + void ParseField(StructDef &struct_def); + void ParseAnyValue(Value &val, FieldDef *field); + uoffset_t ParseTable(const StructDef &struct_def); + void SerializeStruct(const StructDef &struct_def, const Value &val); + void AddVector(bool sortbysize, int count); + uoffset_t ParseVector(const Type &type); + void ParseMetaData(Definition &def); + bool TryTypedValue(int dtoken, bool check, Value &e, BaseType req); + void ParseSingleValue(Value &e); + StructDef *LookupCreateStruct(const std::string &name); + void ParseEnum(bool is_union); + void ParseDecl(); + + public: + SymbolTable<StructDef> structs_; + SymbolTable<EnumDef> enums_; + std::vector<std::string> name_space_; // As set in the schema. + std::string error_; // User readable error_ if Parse() == false + + FlatBufferBuilder builder_; // any data contained in the file + StructDef *root_struct_def; + + private: + const char *source_, *cursor_; + int line_; // the current line being parsed + int token_; + std::string attribute_, doc_comment_; + + std::vector<std::pair<Value, FieldDef *>> field_stack_; + std::vector<uint8_t> struct_stack_; +}; + +// Generate text (JSON) from a given FlatBuffer, and a given Parser +// object that has been populated with the corresponding schema. +// See idl_gen_text.cpp. +extern void GenerateText(const Parser &parser, + const void *flatbuffer, + int indent_step, + std::string *text); + +// Generate a C++ header from the definitions in the Parser object. +// See idl_gen_cpp. +extern std::string GenerateCPP(const Parser &parser); +extern bool GenerateCPP(const Parser &parser, + const std::string &path, + const std::string &file_name); + +// Generate Java files from the definitions in the Parser object. +// See idl_gen_java.cpp. +extern bool GenerateJava(const Parser &parser, + const std::string &path, + const std::string &file_name); + +} // namespace flatbuffers + +#endif // FLATBUFFERS_IDL_H_ + diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h new file mode 100644 index 00000000..4c596574 --- /dev/null +++ b/include/flatbuffers/util.h @@ -0,0 +1,99 @@ +/* + * 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. + */ + +#ifndef FLATBUFFERS_UTIL_H_ +#define FLATBUFFERS_UTIL_H_ + +#include <fstream> +#include <iomanip> +#include <string> +#include <sstream> +#include <stdlib.h> + +namespace flatbuffers { + +// Convert an integer or floating point value to a string. +// In contrast to std::stringstream, "char" values are +// converted to a string of digits. +template<typename T> std::string NumToString(T t) { + // to_string() prints different numbers of digits for floats depending on + // platform and isn't available on Android, so we use stringstream + std::stringstream ss; + if (sizeof(T) > 1) ss << t; + else ss << static_cast<int>(t); // Avoid char types used as character data. + return ss.str(); +} + +// Convert an integer value to a hexadecimal string. +// The returned string length is the number of nibbles in +// the supplied value prefixed by 0 digits. For example, +// IntToStringHex(static_cast<int>(0x23)) returns the +// string "00000023". +template<typename T> std::string IntToStringHex(T i) { + std::stringstream ss; + ss << std::setw(sizeof(T) * 2) + << std::setfill('0') + << std::hex + << std::uppercase + << i; + return ss.str(); +} + +// Portable implementation of strtoull(). +inline int64_t StringToInt(const char *str) { + #ifdef _MSC_VER + return _strtoui64(str, nullptr, 10); + #else + return strtoull(str, nullptr, 10); + #endif +} + +// Load file "name" into "buf" returning true if successful +// false otherwise. If "binary" is false data is read +// using ifstream's text mode, otherwise data is read with +// no transcoding. +inline bool LoadFile(const char *name, bool binary, std::string *buf) { + std::ifstream ifs(name, binary ? std::ifstream::binary : std::ifstream::in); + if (!ifs.is_open()) return false; + *buf = std::string(std::istreambuf_iterator<char>(ifs), + std::istreambuf_iterator<char>()); + return !ifs.bad(); +} + +// Save data "buf" of length "len" bytes into a file +// "name" returning true if successful, false otherwise. +// If "binary" is false data is written using ifstream's +// text mode, otherwise data is written with no +// transcoding. +inline bool SaveFile(const char *name, const char *buf, size_t len, + bool binary) { + std::ofstream ofs(name, binary ? std::ofstream::binary : std::ofstream::out); + if (!ofs.is_open()) return false; + ofs.write(buf, len); + return !ofs.bad(); +} + +// Save data "buf" into file "name" returning true if +// successful, false otherwise. If "binary" is false +// data is written using ifstream's text mode, otherwise +// data is written with no transcoding. +inline bool SaveFile(const char *name, const std::string &buf, bool binary) { + return SaveFile(name, buf.c_str(), buf.size(), binary); +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_UTIL_H_ diff --git a/java/flatbuffers/FlatBufferBuilder.java b/java/flatbuffers/FlatBufferBuilder.java new file mode 100755 index 00000000..44f201ba --- /dev/null +++ b/java/flatbuffers/FlatBufferBuilder.java @@ -0,0 +1,248 @@ +/* + * 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. + */ + +package flatbuffers; + +import java.lang.String; +import java.util.Arrays; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.charset.Charset; + +// Class that helps you build a FlatBuffer. +// See the section "Use in Java" in the main FlatBuffers documentation. + +public class FlatBufferBuilder { + ByteBuffer bb; // Where we construct the FlatBuffer. + int space; // Remaining space in the ByteBuffer. + final Charset utf8charset = Charset.forName("UTF-8"); + int minalign = 1; // Minimum alignment encountered so far. + int[] vtable; // The vtable for the current table, null otherwise. + int object_start; // Starting offset of the current struct/table. + int[] vtables = new int[16]; // List of offsets of all vtables. + int num_vtables = 0; // Number of entries in `vtables` in use. + int vector_num_elems = 0; // For the current vector being built. + + // Java doesn't seem to have these. + final int SIZEOF_SHORT = 2; + final int SIZEOF_INT = 4; + + // Start with a buffer of size `initial_size`, then grow as required. + public FlatBufferBuilder(int initial_size) { + space = initial_size; + bb = newByteBuffer(new byte[initial_size]); + } + + ByteBuffer newByteBuffer(byte[] buf) { + ByteBuffer newbb = ByteBuffer.wrap(buf); + newbb.order(ByteOrder.LITTLE_ENDIAN); + return newbb; + } + + // Doubles the size of the ByteBuffer, and copies the old data towards the + // end of the new buffer (since we build the buffer backwards). + ByteBuffer growByteBuffer(ByteBuffer bb) { + byte[] old_buf = bb.array(); + int old_buf_size = old_buf.length; + int new_buf_size = old_buf_size * 2; + byte[] new_buf = new byte[new_buf_size]; + System.arraycopy(old_buf, 0, new_buf, new_buf_size - old_buf_size, old_buf_size); + ByteBuffer nbb = newByteBuffer(new_buf); + nbb.position(bb.position()); + return nbb; + } + + // Offset relative to the end of the buffer. + public int offset() { + return bb.array().length - space; + } + + public void pad(int byte_size) { + for (int i = 0; i < byte_size; i++) bb.put(--space, (byte)0); + } + + // Prepare to write an element of `size` after `additional_bytes` + // have been written, e.g. if you write a string, you need to align such + // the int length field is aligned to SIZEOF_INT, and the string data follows it + // directly. + // If all you need to do is align, `additional_bytes` will be 0. + public void prep(int size, int additional_bytes) { + // Track the biggest thing we've ever aligned to. + if (size > minalign) minalign = size; + // Find the amount of alignment needed such that `size` is properly + // aligned after `additional_bytes` + int align_size = ((~(bb.array().length - space + additional_bytes)) + 1) & (size - 1); + // Reallocate the buffer if needed. + while (space < align_size + size + additional_bytes) { + int old_buf_size = bb.array().length; + bb = growByteBuffer(bb); + space += bb.array().length - old_buf_size; + } + pad(align_size); + } + + // Add a scalar to the buffer, backwards from the current location. + // Doesn't align nor check for space. + public void putByte (byte x) { bb.put (space -= 1, x); } + public void putShort (short x) { bb.putShort (space -= 2, x); } + public void putInt (int x) { bb.putInt (space -= 4, x); } + public void putLong (long x) { bb.putLong (space -= 8, x); } + public void putFloat (float x) { bb.putFloat (space -= 4, x); } + public void putDouble(double x) { bb.putDouble(space -= 8, x); } + + // Adds a scalar to the buffer, properly aligned, and the buffer grown + // if needed. + public void addByte (byte x) { prep(1, 0); putByte (x); } + public void addShort (short x) { prep(2, 0); putShort (x); } + public void addInt (int x) { prep(4, 0); putInt (x); } + public void addLong (long x) { prep(8, 0); putLong (x); } + public void addFloat (float x) { prep(4, 0); putFloat (x); } + public void addDouble(double x) { prep(8, 0); putDouble(x); } + + // Adds on offset, relative to where it will be written. + public void addOffset(int off) { + prep(SIZEOF_INT, 0); // Ensure alignment is already done. + assert off <= offset(); + off = offset() - off + SIZEOF_INT; + putInt(off); + } + + public void startVector(int elem_size, int num_elems) { + notNested(); + vector_num_elems = num_elems; + prep(SIZEOF_INT, elem_size * num_elems); + } + + public int endVector() { + putInt(vector_num_elems); + return offset(); + } + + public int createString(String s) { + byte[] utf8 = s.getBytes(utf8charset); + bb.put(--space, (byte)0); + startVector(1, utf8.length); + System.arraycopy(utf8, 0, bb.array(), space -= utf8.length, utf8.length); + return endVector(); + } + + public void notNested() { + // You should not be creating any other objects or strings/vectors + // while an object is being constructed + if (vtable != null) + throw new AssertionError("FlatBuffers: object serialization must not be nested."); + } + + public void Nested(int obj) { + // Structs are always stored inline, so need to be created right + // where they are used. You'll get this assert if you created it + // elsewhere. + if (obj != offset()) + throw new AssertionError("FlatBuffers: struct must be serialized inline."); + } + + public void startObject(int numfields) { + notNested(); + vtable = new int[numfields]; + object_start = offset(); + } + + // Add a scalar to a table at `o` into its vtable, with value `x` and default `d` + public void addByte (int o, byte x, int d) { if(x != d) { addByte (x); slot(o); } } + public void addShort (int o, short x, int d) { if(x != d) { addShort (x); slot(o); } } + public void addInt (int o, int x, int d) { if(x != d) { addInt (x); slot(o); } } + public void addLong (int o, long x, long d) { if(x != d) { addLong (x); slot(o); } } + public void addFloat (int o, float x, double d) { if(x != d) { addFloat (x); slot(o); } } + public void addDouble(int o, double x, double d) { if(x != d) { addDouble(x); slot(o); } } + public void addOffset(int o, int x, int d) { if(x != d) { addOffset(x); slot(o); } } + + // Structs are stored inline, so nothing additional is being added. `d` is always 0. + public void addStruct(int voffset, int x, int d) { + if(x != d) { + Nested(x); + slot(voffset); + } + } + + // Set the current vtable at `voffset` to the current location in the buffer. + public void slot(int voffset) { + vtable[voffset] = offset(); + } + + public int endObject() { + assert vtable != null; // calling endObject without a startObject + addInt(0); + int vtableloc = offset(); + // Write out the current vtable. + for (int i = vtable.length - 1; i >= 0 ; i--) { + // Offset relative to the start of the table. + short off = (short)(vtable[i] != 0 ? vtableloc - vtable[i] : 0); + putShort(off); + } + + final int standard_fields = 2; // The fields below: + putShort((short)(vtableloc - object_start)); + putShort((short)((vtable.length + standard_fields) * SIZEOF_SHORT)); + + // Search for an existing vtable that matches the current one. + int existing_vtable = 0; + outer_loop: + for (int i = 0; i < num_vtables; i++) { + int vt1 = bb.array().length - vtables[i]; + int vt2 = space; + short len = bb.getShort(vt1); + if (len == bb.getShort(vt2)) { + for (int j = SIZEOF_SHORT; j < len; j += SIZEOF_SHORT) { + if (bb.getShort(vt1 + j) != bb.getShort(vt2 + j)) { + continue outer_loop; + } + } + existing_vtable = vtables[i]; + break outer_loop; + } + } + + if (existing_vtable != 0) { + // Found a match: + // Remove the current vtable. + space = bb.array().length - vtableloc; + // Point table to existing vtable. + bb.putInt(space, existing_vtable - vtableloc); + } else { + // No match: + // Add the location of the current vtable to the list of vtables. + if (num_vtables == vtables.length) vtables = Arrays.copyOf(vtables, num_vtables * 2); + vtables[num_vtables++] = offset(); + // Point table to current vtable. + bb.putInt(bb.array().length - vtableloc, offset() - vtableloc); + } + + vtable = null; + return vtableloc; + } + + public void finish(int root_table) { + prep(minalign, SIZEOF_INT); + addOffset(root_table); + } + + public ByteBuffer dataBuffer() { return bb; } + + // The FlatBuffer data doesn't start at offset 0 in the ByteBuffer: + public int dataStart() { + return bb.array().length - offset(); + } +} diff --git a/java/flatbuffers/Struct.java b/java/flatbuffers/Struct.java new file mode 100755 index 00000000..aac25bf6 --- /dev/null +++ b/java/flatbuffers/Struct.java @@ -0,0 +1,25 @@ +/* + * 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. + */ + +package flatbuffers; + +import java.nio.ByteBuffer; + +// All structs in the generated code derive from this class, and add their own accessors. +public class Struct { + protected int bb_pos; + protected ByteBuffer bb; +} diff --git a/java/flatbuffers/Table.java b/java/flatbuffers/Table.java new file mode 100755 index 00000000..f2233fa5 --- /dev/null +++ b/java/flatbuffers/Table.java @@ -0,0 +1,69 @@ +/* + * 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. + */ + +package flatbuffers; + +import java.lang.String; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; + +// All tables in the generated code derive from this class, and add their own accessors. +public class Table { + protected int bb_pos; + protected ByteBuffer bb; + + final int SIZEOF_INT = 4; + + // Look up a field in the vtable, return an offset into the object, or 0 if the field is not + // present. + protected int __offset(int vtable_offset) { + int vtable = bb_pos - bb.getInt(bb_pos); + return vtable_offset < bb.getShort(vtable) ? bb.getShort(vtable + vtable_offset) : 0; + } + + // Retrieve the relative offset stored at "offset" + protected int __indirect(int offset) { + return offset + bb.getInt(offset); + } + + // Create a java String from UTF-8 data stored inside the flatbuffer. + protected String __string(int offset) { + offset += bb_pos; + offset += bb.getInt(offset); + return new String(bb.array(), offset + SIZEOF_INT, bb.getInt(offset), Charset.forName("UTF-8")); + } + + // Get the length of a vector whose offset is stored at "offset" in this object. + protected int __vector_len(int offset) { + offset += bb_pos; + offset += bb.getInt(offset); + return bb.getInt(offset); + } + + // Get the start of data of a vector whose offset is stored at "offset" in this object. + protected int __vector(int offset) { + offset += bb_pos; + return offset + bb.getInt(offset) + SIZEOF_INT; // data starts after the length + } + + // Initialize any Table-derived type to point to the union at the given offset. + protected Table __union(Table t, int offset) { + offset += bb_pos; + t.bb_pos = offset + bb.getInt(offset); + t.bb = bb; + return t; + } +} diff --git a/readme.md b/readme.md new file mode 100755 index 00000000..0da14d7a --- /dev/null +++ b/readme.md @@ -0,0 +1,30 @@ +FlatBuffers Version 1.0 + +# Welcome to FlatBuffers! + +FlatBuffers is a serialization library for games and other memory constrained +apps. Go to our [landing page][] to browse our documentation. + +FlatBuffers allows you to directly access serialized data without +unpacking/parsing it first, while still having great forwards/backwards +compatibility. FlatBuffers can be built for many different systems (Android, +Windows, OS X, Linux), see `docs/html/index.html` + +Discuss FlatBuffers with other developers and users on the +[FlatBuffers Google Group][]. File issues on the [FlatBuffers Issues Tracker][] +or post your questions to [stackoverflow.com][] with a mention of +**flatbuffers**. + +For applications on Google Play that integrate this tool, 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. + + [FlatBuffers Google Group]: http://group.google.com/group/flatbuffers + [FlatBuffers Issues Tracker]: http://github.com/google/flatbuffers/issues + [stackoverflow.com]: http://www.stackoverflow.com + [landing page]: http://google.github.io/flatbuffers diff --git a/samples/monster.fbs b/samples/monster.fbs new file mode 100755 index 00000000..2ad0c926 --- /dev/null +++ b/samples/monster.fbs @@ -0,0 +1,25 @@ +// example IDL file + +namespace MyGame.Sample; + +enum Color:byte { Red = 0, Green, Blue = 2 } + +union Any { Monster } // add more elements.. + +struct Vec3 { + x:float; + y:float; + z:float; +} + +table Monster { + pos:Vec3; + mana:short = 150; + hp:short = 100; + name:string; + friendly:bool = false (deprecated); + inventory:[ubyte]; + color:Color = Blue; +} + +root_type Monster; diff --git a/samples/monster_generated.h b/samples/monster_generated.h new file mode 100755 index 00000000..8282a84a --- /dev/null +++ b/samples/monster_generated.h @@ -0,0 +1,88 @@ +// automatically generated, do not modify + +#include "flatbuffers/flatbuffers.h" + +namespace MyGame { +namespace Sample { + +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]; } + +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]; } + +struct Vec3; +struct Monster; + +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); + +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); } +}; + +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)); } +}; + +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(); +} + +inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot<Monster>(buf); } + +}; // namespace MyGame +}; // namespace Sample diff --git a/samples/monsterdata.json b/samples/monsterdata.json new file mode 100755 index 00000000..06bb57af --- /dev/null +++ b/samples/monsterdata.json @@ -0,0 +1,9 @@ +{ + pos: { + x: 1, + y: 2, + z: 3 + }, + hp: 80, + name: "MyMonster" +} diff --git a/samples/sample_binary.cpp b/samples/sample_binary.cpp new file mode 100755 index 00000000..92c4c58e --- /dev/null +++ b/samples/sample_binary.cpp @@ -0,0 +1,62 @@ +/* + * 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. + */ + +#include "flatbuffers/flatbuffers.h" + +#include "monster_generated.h" + +using namespace MyGame::Sample; + +// Example how to use FlatBuffers to create and read binary buffers. + +int main(int argc, const char *argv[]) { + // Build up a serialized buffer algorithmically: + flatbuffers::FlatBufferBuilder builder; + + auto vec = Vec3(1, 2, 3); + + auto name = builder.CreateString("MyMonster"); + + unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + auto inventory = builder.CreateVector(inv_data, 10); + + // Shortcut for creating monster with all fields set: + auto mloc = CreateMonster(builder, &vec, 150, 80, name, inventory, + Color_Blue); + + builder.Finish(mloc); + // We now have a FlatBuffer we can store or send somewhere. + + // ** file/network code goes here :) ** + // access builder.GetBufferPointer() for builder.GetSize() bytes + + // Instead, we're going to access it straight away. + // Get access to the root: + auto monster = GetMonster(builder.GetBufferPointer()); + + assert(monster->hp() == 80); + assert(monster->mana() == 150); // default + assert(!strcmp(monster->name()->c_str(), "MyMonster")); + + auto pos = monster->pos(); + assert(pos); + assert(pos->z() == 3); + + auto inv = monster->inventory(); + assert(inv); + assert(inv->Get(9) == 9); +} + diff --git a/samples/sample_text.cpp b/samples/sample_text.cpp new file mode 100755 index 00000000..b4d2d251 --- /dev/null +++ b/samples/sample_text.cpp @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#include "flatbuffers/flatbuffers.h" +#include "flatbuffers/idl.h" +#include "flatbuffers/util.h" + +#include "monster_generated.h" + +using namespace MyGame::Sample; + +// This is an example of parsing text straight into a buffer and then +// generating flatbuffer (JSON) text from the buffer. +int main(int argc, const char *argv[]) { + // load FlatBuffer schema (.fbs) and JSON from disk + std::string schemafile; + std::string jsonfile; + bool ok = flatbuffers::LoadFile("samples/monster.fbs", false, &schemafile) && + flatbuffers::LoadFile("samples/monsterdata.json", false, &jsonfile); + if (!ok) { + printf("couldn't load files!\n"); + return 1; + } + + // parse schema first, so we can use it to parse the data after + flatbuffers::Parser parser; + ok = parser.Parse(schemafile.c_str()) && + parser.Parse(jsonfile.c_str()); + assert(ok); + + // here, parser.builder_ contains a binary buffer that is the parsed data. + + // to ensure it is correct, we now generate text back from the binary, + // and compare the two: + std::string jsongen; + GenerateText(parser, parser.builder_.GetBufferPointer(), 2, &jsongen); + + if (jsongen != jsonfile) { + printf("%s----------------\n%s", jsongen.c_str(), jsonfile.c_str()); + } +} diff --git a/src/flatc.cpp b/src/flatc.cpp new file mode 100755 index 00000000..e99b1d48 --- /dev/null +++ b/src/flatc.cpp @@ -0,0 +1,180 @@ +/* + * 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. + */ + +#include "flatbuffers/flatbuffers.h" +#include "flatbuffers/idl.h" +#include "flatbuffers/util.h" + +void Error(const char *err, const char *obj = nullptr, bool usage = false); + +namespace flatbuffers { + +bool GenerateBinary(const Parser &parser, + const std::string &path, + const std::string &file_name) { + return !parser.builder_.GetSize() || + flatbuffers::SaveFile( + (path + file_name + "_wire.bin").c_str(), + reinterpret_cast<char *>(parser.builder_.GetBufferPointer()), + parser.builder_.GetSize(), + true); +} + +bool GenerateTextFile(const Parser &parser, + const std::string &path, + const std::string &file_name) { + if (!parser.builder_.GetSize()) return true; + if (!parser.root_struct_def) Error("root_type not set"); + std::string text; + GenerateText(parser, parser.builder_.GetBufferPointer(), 2, &text); + return flatbuffers::SaveFile((path + file_name + "_wire.txt").c_str(), + text, + false); + +} + +} + +// This struct allows us to create a table of all possible output generators +// for the various programming languages and formats we support. +struct Generator { + bool (*generate)(const flatbuffers::Parser &parser, + const std::string &path, + const std::string &file_name); + const char *extension; + const char *name; + const char *help; +}; + +const Generator generators[] = { + { flatbuffers::GenerateBinary, "b", "binary", + "Generate wire format binaries for any data definitions" }, + { flatbuffers::GenerateTextFile, "t", "text", + "Generate text output for any data definitions" }, + { flatbuffers::GenerateCPP, "c", "C++", + "Generate C++ headers for tables/structs" }, + { flatbuffers::GenerateJava, "j", "Java", + "Generate Java classes for tables/structs" }, +}; + +const char *program_name = NULL; + +void Error(const char *err, const char *obj, bool usage) { + printf("%s: %s\n", program_name, err); + if (obj) printf(": %s", obj); + printf("\n"); + if (usage) { + printf("usage: %s [OPTION]... FILE...\n", program_name); + for (size_t i = 0; i < sizeof(generators) / sizeof(generators[0]); ++i) + printf(" -%s %s.\n", generators[i].extension, generators[i].help); + printf(" -o PATH Prefix PATH to all generated files.\n" + "FILEs may depend on declarations in earlier files.\n" + "Output files are named using the base file name of the input," + "and written to the current directory or the path given by -o.\n" + "example: %s -c -b schema1.fbs schema2.fbs data.json\n", + program_name); + } + exit(1); +} + +std::string StripExtension(const std::string &filename) { + size_t i = filename.find_last_of("."); + return i != std::string::npos ? filename.substr(0, i) : filename; +} + +int main(int argc, const char *argv[]) { + program_name = argv[0]; + flatbuffers::Parser parser; + std::string output_path; + const size_t num_generators = sizeof(generators) / sizeof(generators[0]); + bool generator_enabled[num_generators] = { false }; + bool any_generator = false; + std::vector<std::string> filenames; + for (int i = 1; i < argc; i++) { + const char *arg = argv[i]; + if (arg[0] == '-') { + if (filenames.size()) + Error("invalid option location", arg, true); + if (strlen(arg) != 2) + Error("invalid commandline argument", arg, true); + switch (arg[1]) { + case 'o': + if (++i >= argc) Error("missing path following", arg, true); + output_path = argv[i]; + break; + default: + for (size_t i = 0; i < num_generators; ++i) { + if(!strcmp(arg+1, generators[i].extension)) { + generator_enabled[i] = true; + any_generator = true; + goto found; + } + } + Error("unknown commandline argument", arg, true); + found: + break; + } + } else { + filenames.push_back(argv[i]); + } + } + + if (!filenames.size()) Error("missing input files", nullptr, true); + + if (!any_generator) + Error("no options: no output files generated.", + "specify one of -c -j -t -b etc.", true); + + // Now process the files: + for (auto file_it = filenames.begin(); + file_it != filenames.end(); + ++file_it) { + std::string contents; + if (!flatbuffers::LoadFile(file_it->c_str(), true, &contents)) + Error("unable to load file", file_it->c_str()); + + if (!parser.Parse(contents.c_str())) + Error(parser.error_.c_str()); + + std::string filebase = StripExtension(*file_it); + + for (size_t i = 0; i < num_generators; ++i) { + if (generator_enabled[i]) { + if (!generators[i].generate(parser, output_path, filebase)) { + Error((std::string("Unable to generate ") + + generators[i].name + + " for " + + filebase).c_str()); + } + } + } + + // Since the Parser object retains definitions across files, we must + // ensure we only output code for these once, in the file they are first + // declared: + for (auto it = parser.enums_.vec.begin(); + it != parser.enums_.vec.end(); ++it) { + (*it)->generated = true; + } + for (auto it = parser.structs_.vec.begin(); + it != parser.structs_.vec.end(); ++it) { + (*it)->generated = true; + } + } + + return 0; +} + diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp new file mode 100644 index 00000000..36819e72 --- /dev/null +++ b/src/idl_gen_cpp.cpp @@ -0,0 +1,371 @@ +/* + * 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. + */ + +// independent from idl_parser, since this code is not needed for most clients + +#include "flatbuffers/flatbuffers.h" +#include "flatbuffers/idl.h" +#include "flatbuffers/util.h" + +namespace flatbuffers { +namespace cpp { + +// Return a C++ type from the table in idl.h +static std::string GenTypeBasic(const Type &type) { + static const char *ctypename[] = { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) #CTYPE, + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + }; + return ctypename[type.base_type]; +} + +static std::string GenTypeWire(const Type &type, const char *postfix); + +// Return a C++ pointer type, specialized to the actual struct/table types, +// and vector element types. +static std::string GenTypePointer(const Type &type) { + switch (type.base_type) { + case BASE_TYPE_STRING: + return "flatbuffers::String"; + case BASE_TYPE_VECTOR: + return "flatbuffers::Vector<" + GenTypeWire(type.VectorType(), "") + ">"; + case BASE_TYPE_STRUCT: + return type.struct_def->name; + case BASE_TYPE_UNION: + // fall through + default: + return "void"; + } +} + +// Return a C++ type for any type (scalar/pointer) specifically for +// building a flatbuffer. +static std::string GenTypeWire(const Type &type, const char *postfix) { + return IsScalar(type.base_type) + ? GenTypeBasic(type) + postfix + : IsStruct(type) + ? "const " + GenTypePointer(type) + " *" + : "flatbuffers::Offset<" + GenTypePointer(type) + ">" + postfix; +} + +// Return a C++ type for any type (scalar/pointer) specifically for +// using a flatbuffer. +static std::string GenTypeGet(const Type &type, const char *afterbasic, + const char *beforeptr, const char *afterptr) { + return IsScalar(type.base_type) + ? GenTypeBasic(type) + afterbasic + : beforeptr + GenTypePointer(type) + afterptr; +} + +// Generate a documentation comment, if available. +static void GenComment(const std::string &dc, + std::string *code_ptr, + const char *prefix = "") { + std::string &code = *code_ptr; + if (dc.length()) { + code += std::string(prefix) + "///" + dc + "\n"; + } +} + +// Generate an enum declaration and an enum string lookup table. +static void GenEnum(EnumDef &enum_def, std::string *code_ptr) { + if (enum_def.generated) return; + std::string &code = *code_ptr; + GenComment(enum_def.doc_comment, code_ptr); + code += "enum {\n"; + for (auto it = enum_def.vals.vec.begin(); + it != enum_def.vals.vec.end(); + ++it) { + auto &ev = **it; + GenComment(ev.doc_comment, code_ptr, " "); + code += " " + enum_def.name + "_" + ev.name + " = "; + code += NumToString(ev.value) + ",\n"; + } + code += "};\n\n"; + + // Generate a generate string table for enum values. + // Problem is, if values are very sparse that could generate really big + // tables. Ideally in that case we generate a map lookup instead, but for + // the moment we simply don't output a table at all. + int range = enum_def.vals.vec.back()->value - + enum_def.vals.vec.front()->value + 1; + // Average distance between values above which we consider a table + // "too sparse". Change at will. + static const int kMaxSparseness = 5; + if (range / static_cast<int>(enum_def.vals.vec.size()) < kMaxSparseness) { + code += "inline const char **EnumNames" + enum_def.name + "() {\n"; + code += " static const char *names[] = { "; + int val = enum_def.vals.vec.front()->value; + for (auto it = enum_def.vals.vec.begin(); + it != enum_def.vals.vec.end(); + ++it) { + while (val++ != (*it)->value) code += "\"\", "; + code += "\"" + (*it)->name + "\", "; + } + code += "nullptr };\n return names;\n}\n\n"; + code += "inline const char *EnumName" + enum_def.name; + code += "(int e) { return EnumNames" + enum_def.name + "()[e"; + if (enum_def.vals.vec.front()->value) + code += " - " + enum_def.name + "_" + enum_def.vals.vec.front()->name; + code += "]; }\n\n"; + } +} + +// Generate an accessor struct, builder structs & function for a table. +static void GenTable(StructDef &struct_def, std::string *code_ptr) { + if (struct_def.generated) return; + std::string &code = *code_ptr; + + // Generate an accessor struct, with methods of the form: + // type name() const { return GetField<type>(offset, defaultval); } + GenComment(struct_def.doc_comment, code_ptr); + code += "struct " + struct_def.name + " : private flatbuffers::Table"; + code += " {\n"; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (!field.deprecated) { // Deprecated fields won't be accessible. + GenComment(field.doc_comment, code_ptr, " "); + code += " " + GenTypeGet(field.value.type, " ", "const ", " *"); + code += field.name + "() const { return "; + // Call a different accessor for pointers, that indirects. + code += IsScalar(field.value.type.base_type) + ? "GetField<" + : (IsStruct(field.value.type) ? "GetStruct<" : "GetPointer<"); + code += GenTypeGet(field.value.type, "", "const ", " *") + ">("; + code += NumToString(field.value.offset); + // Default value as second arg for non-pointer types. + if (IsScalar(field.value.type.base_type)) + code += ", " + field.value.constant; + code += "); }\n"; + } + } + code += "};\n\n"; + + // Generate a builder struct, with methods of the form: + // void add_name(type name) { fbb_.AddElement<type>(offset, name, default); } + code += "struct " + struct_def.name; + code += "Builder {\n flatbuffers::FlatBufferBuilder &fbb_;\n"; + code += " flatbuffers::uoffset_t start_;\n"; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (!field.deprecated) { + code += " void add_" + field.name + "("; + code += GenTypeWire(field.value.type, " ") + field.name + ") { fbb_.Add"; + if (IsScalar(field.value.type.base_type)) + code += "Element<" + GenTypeWire(field.value.type, "") + ">"; + else if (IsStruct(field.value.type)) + code += "Struct"; + else + code += "Offset"; + code += "(" + NumToString(field.value.offset) + ", " + field.name; + if (IsScalar(field.value.type.base_type)) + code += ", " + field.value.constant; + code += "); }\n"; + } + } + code += " " + struct_def.name; + code += "Builder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) "; + code += "{ start_ = fbb_.StartTable(); }\n"; + code += " flatbuffers::Offset<" + struct_def.name; + code += "> Finish() { return flatbuffers::Offset<" + struct_def.name; + code += ">(fbb_.EndTable(start_, "; + code += NumToString(struct_def.fields.vec.size()) + ")); }\n};\n\n"; + + // Generate a convenient CreateX function that uses the above builder + // to create a table in one go. + code += "inline flatbuffers::Offset<" + struct_def.name + "> Create"; + code += struct_def.name; + code += "(flatbuffers::FlatBufferBuilder &_fbb"; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (!field.deprecated) { + code += ", " + GenTypeWire(field.value.type, " ") + field.name; + } + } + code += ") {\n " + struct_def.name + "Builder builder_(_fbb);\n"; + for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1; + size; + size /= 2) { + for (auto it = struct_def.fields.vec.rbegin(); + it != struct_def.fields.vec.rend(); + ++it) { + auto &field = **it; + if (!field.deprecated && + (!struct_def.sortbysize || + size == SizeOf(field.value.type.base_type))) { + code += " builder_.add_" + field.name + "(" + field.name + ");\n"; + } + } + } + code += " return builder_.Finish();\n}\n\n"; +} + +// Generate an accessor struct with constructor for a flatbuffers struct. +static void GenStruct(StructDef &struct_def, std::string *code_ptr) { + if (struct_def.generated) return; + std::string &code = *code_ptr; + + // Generate an accessor struct, with private variables of the form: + // type name_; + // Generates manual padding and alignment. + // Variables are private because they contain little endian data on all + // platforms. + GenComment(struct_def.doc_comment, code_ptr); + code += "MANUALLY_ALIGNED_STRUCT(" + NumToString(struct_def.minalign) + ") "; + code += struct_def.name + " {\n private:\n"; + int padding_id = 0; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + code += " " + GenTypeGet(field.value.type, " ", "", " "); + code += field.name + "_;\n"; + if (field.padding) { + for (int i = 0; i < 4; i++) + if (static_cast<int>(field.padding) & (1 << i)) + code += " int" + NumToString((1 << i) * 8) + + "_t __padding" + NumToString(padding_id++) + ";\n"; + assert(!(field.padding & ~0xF)); + } + } + + // Generate a constructor that takes all fields as arguments. + code += "\n public:\n " + struct_def.name + "("; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (it != struct_def.fields.vec.begin()) code += ", "; + code += GenTypeGet(field.value.type, " ", "const ", " &") + field.name; + } + code += ")\n : "; + padding_id = 0; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (it != struct_def.fields.vec.begin()) code += ", "; + code += field.name + "_("; + if (IsScalar(field.value.type.base_type)) + code += "flatbuffers::EndianScalar(" + field.name + "))"; + else + code += field.name + ")"; + if (field.padding) + code += ", __padding" + NumToString(padding_id++) + "(0)"; + } + code += " {}\n\n"; + + // Generate accessor methods of the form: + // type name() const { return flatbuffers::EndianScalar(name_); } + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + GenComment(field.doc_comment, code_ptr, " "); + code += " " + GenTypeGet(field.value.type, " ", "const ", " &"); + code += field.name + "() const { return "; + if (IsScalar(field.value.type.base_type)) + code += "flatbuffers::EndianScalar(" + field.name + "_)"; + else + code += field.name + "_"; + code += "; }\n"; + } + code += "};\nSTRUCT_END(" + struct_def.name + ", "; + code += NumToString(struct_def.bytesize) + ");\n\n"; +} + +} // namespace cpp + +// Iterate through all definitions we haven't generate code for (enums, structs, +// and tables) and output them to a single file. +static std::string GenerateCPP(const Parser &parser) { + using namespace cpp; + + // Generate code for all the enum declarations. + std::string enum_code; + for (auto it = parser.enums_.vec.begin(); + it != parser.enums_.vec.end(); ++it) { + GenEnum(**it, &enum_code); + } + + // Generate forward declarations for all structs/tables, since they may + // have circular references. + std::string forward_decl_code; + for (auto it = parser.structs_.vec.begin(); + it != parser.structs_.vec.end(); ++it) { + if (!(*it)->generated) + forward_decl_code += "struct " + (*it)->name + ";\n"; + } + + // Generate code for all structs, then all tables. + std::string decl_code; + for (auto it = parser.structs_.vec.begin(); + it != parser.structs_.vec.end(); ++it) { + if ((**it).fixed) GenStruct(**it, &decl_code); + } + for (auto it = parser.structs_.vec.begin(); + it != parser.structs_.vec.end(); ++it) { + if (!(**it).fixed) GenTable(**it, &decl_code); + } + + // Only output file-level code if there were any declarations. + if (enum_code.length() || forward_decl_code.length() || decl_code.length()) { + std::string code; + code = "// automatically generated, do not modify\n\n"; + code += "#include \"flatbuffers/flatbuffers.h\"\n\n"; + for (auto it = parser.name_space_.begin(); + it != parser.name_space_.end(); ++it) { + code += "namespace " + *it + " {\n"; + } + code += "\n"; + code += enum_code; + code += forward_decl_code; + code += "\n"; + code += decl_code; + if (parser.root_struct_def) { + code += "inline const " + parser.root_struct_def->name + " *Get"; + code += parser.root_struct_def->name; + code += "(const void *buf) { return flatbuffers::GetRoot<"; + code += parser.root_struct_def->name + ">(buf); }\n\n"; + } + for (auto it = parser.name_space_.begin(); + it != parser.name_space_.end(); ++it) { + code += "}; // namespace " + *it + "\n"; + } + + return code; + } + + return std::string(); +} + +bool GenerateCPP(const Parser &parser, + const std::string &path, + const std::string &file_name) { + auto code = GenerateCPP(parser); + return !code.length() || + SaveFile((path + file_name + "_generated.h").c_str(), code, false); +} + +} // namespace flatbuffers + diff --git a/src/idl_gen_java.cpp b/src/idl_gen_java.cpp new file mode 100755 index 00000000..d68932c9 --- /dev/null +++ b/src/idl_gen_java.cpp @@ -0,0 +1,399 @@ +/* + * 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. + */ + +// independent from idl_parser, since this code is not needed for most clients + +#include "flatbuffers/flatbuffers.h" +#include "flatbuffers/idl.h" +#include "flatbuffers/util.h" + +#ifdef _WIN32 +#include <direct.h> +#define PATH_SEPARATOR "\\" +#define mkdir(n, m) _mkdir(n) +#else +#include <sys/stat.h> +#define PATH_SEPARATOR "/" +#endif + +namespace flatbuffers { +namespace java { + +static std::string GenTypeBasic(const Type &type) { + static const char *ctypename[] = { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) #JTYPE, + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + }; + return ctypename[type.base_type]; +} + +static std::string GenTypeGet(const Type &type); + +static std::string GenTypePointer(const Type &type) { + switch (type.base_type) { + case BASE_TYPE_STRING: + return "String"; + case BASE_TYPE_VECTOR: + return GenTypeGet(type.VectorType()); + case BASE_TYPE_STRUCT: + return type.struct_def->name; + case BASE_TYPE_UNION: + // fall through + default: + return "Table"; + } +} + +static std::string GenTypeGet(const Type &type) { + return IsScalar(type.base_type) + ? GenTypeBasic(type) + : GenTypePointer(type); +} + +static void GenComment(const std::string &dc, + std::string *code_ptr, + const char *prefix = "") { + std::string &code = *code_ptr; + if (dc.length()) { + code += std::string(prefix) + "///" + dc + "\n"; + } +} + +// Convert an underscore_based_indentifier in to camelCase. +// Also uppercases the first character if first is true. +static std::string MakeCamel(const std::string &in, bool first = true) { + std::string s; + for (size_t i = 0; i < in.length(); i++) { + if (!i && first) s += toupper(in[0]); + else if (in[i] == '_' && i + 1 < in.length()) s += toupper(in[++i]); + else s += in[i]; + } + return s; +} + +static void GenEnum(EnumDef &enum_def, std::string *code_ptr) { + std::string &code = *code_ptr; + if (enum_def.generated) return; + + // Generate enum definitions of the form: + // public static final int name = value; + // We use ints rather than the Java Enum feature, because we want them + // to map directly to how they're used in C/C++ and file formats. + // That, and Java Enums are expensive, and not universally liked. + GenComment(enum_def.doc_comment, code_ptr); + code += "public class " + enum_def.name + " {\n"; + for (auto it = enum_def.vals.vec.begin(); + it != enum_def.vals.vec.end(); + ++it) { + auto &ev = **it; + GenComment(ev.doc_comment, code_ptr, " "); + code += " public static final " + GenTypeBasic(enum_def.underlying_type); + code += " " + ev.name + " = "; + code += NumToString(ev.value) + ";\n"; + } + code += "};\n\n"; +} + +// Returns the function name that is able to read a value of the given type. +static std::string GenGetter(const Type &type) { + switch (type.base_type) { + case BASE_TYPE_STRING: return "__string"; + case BASE_TYPE_STRUCT: return "__struct"; + case BASE_TYPE_UNION: return "__union"; + case BASE_TYPE_VECTOR: return GenGetter(type.VectorType()); + default: + return "bb.get" + (SizeOf(type.base_type) > 1 + ? MakeCamel(GenTypeGet(type)) + : ""); + } +} + +// Returns the method name for use with add/put calls. +static std::string GenMethod(const FieldDef &field) { + return IsScalar(field.value.type.base_type) + ? MakeCamel(GenTypeBasic(field.value.type)) + : (IsStruct(field.value.type) ? "Struct" : "Offset"); +} + +// Recursively generate arguments for a constructor, to deal with nested +// structs. +static void GenStructArgs(const StructDef &struct_def, std::string *code_ptr, + const char *nameprefix) { + std::string &code = *code_ptr; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (IsStruct(field.value.type)) { + // Generate arguments for a struct inside a struct. To ensure names + // don't clash, and to make it obvious these arguments are constructing + // a nested struct, prefix the name with the struct name. + GenStructArgs(*field.value.type.struct_def, code_ptr, + (field.value.type.struct_def->name + "_").c_str()); + } else { + code += ", " + GenTypeBasic(field.value.type) + " " + nameprefix; + code += MakeCamel(field.name, false); + } + } +} + +// Recusively generate struct construction statements of the form: +// builder.putType(name); +// and insert manual padding. +static void GenStructBody(const StructDef &struct_def, std::string *code_ptr, + const char *nameprefix) { + std::string &code = *code_ptr; + code += " builder.prep(" + NumToString(struct_def.minalign) + ", 0);\n"; + for (auto it = struct_def.fields.vec.rbegin(); + it != struct_def.fields.vec.rend(); + ++it) { + auto &field = **it; + if (field.padding) + code += " builder.pad(" + NumToString(field.padding) + ");\n"; + if (IsStruct(field.value.type)) { + GenStructBody(*field.value.type.struct_def, code_ptr, + (field.value.type.struct_def->name + "_").c_str()); + } else { + code += " builder.put" + GenMethod(field) + "("; + code += nameprefix + MakeCamel(field.name, false) + ");\n"; + } + } +} + +static void GenStruct(StructDef &struct_def, + std::string *code_ptr, + StructDef *root_struct_def) { + if (struct_def.generated) return; + std::string &code = *code_ptr; + + // Generate a struct accessor class, with methods of the form: + // public type name() { return bb.getType(i + offset); } + // or for tables of the form: + // public type name() { + // int o = __offset(offset); return o != 0 ? bb.getType(o + i) : default; + // } + GenComment(struct_def.doc_comment, code_ptr); + code += "public class " + struct_def.name + " extends "; + code += struct_def.fixed ? "Struct" : "Table"; + code += " {\n"; + if (&struct_def == root_struct_def) { + // Generate a special accessor for the table that has been declared as + // the root type. + code += " public static " + struct_def.name + " getRootAs"; + code += struct_def.name; + code += "(ByteBuffer _bb, int offset) { "; + code += "_bb.order(ByteOrder.LITTLE_ENDIAN); "; + code += "return (new " + struct_def.name; + code += "()).__init(_bb.getInt(offset) + offset, _bb); }\n"; + } + // Generate the __init method that sets the field in a pre-existing + // accessor object. This is to allow object reuse. + code += " public " + struct_def.name; + code += " __init(int _i, ByteBuffer _bb) "; + code += "{ bb_pos = _i; bb = _bb; return this; }\n"; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (field.deprecated) continue; + GenComment(field.doc_comment, code_ptr, " "); + std::string type_name = GenTypeGet(field.value.type); + std::string method_start = " public " + type_name + " " + + MakeCamel(field.name, false); + // Generate the accessors that don't do object reuse. + if (field.value.type.base_type == BASE_TYPE_STRUCT) { + // Calls the accessor that takes an accessor object with a new object. + code += method_start + "() { return " + MakeCamel(field.name, false); + code += "(new "; + code += type_name + "()); }\n"; + } else if (field.value.type.base_type == BASE_TYPE_VECTOR && + field.value.type.element == BASE_TYPE_STRUCT) { + // Accessors for vectors of structs also take accessor objects, this + // generates a variant without that argument. + code += method_start + "(int j) { return " + MakeCamel(field.name, false); + code += "(new "; + code += type_name + "(), j); }\n"; + } + std::string getter = GenGetter(field.value.type); + code += method_start + "("; + // Most field accessors need to retrieve and test the field offset first, + // this is the prefix code for that: + auto offset_prefix = ") { int o = __offset(" + + NumToString(field.value.offset) + + "); return o != 0 ? "; + if (IsScalar(field.value.type.base_type)) { + if (struct_def.fixed) { + code += ") { return " + getter; + code += "(bb_pos + " + NumToString(field.value.offset) + ")"; + } else { + code += offset_prefix + getter; + code += "(o + bb_pos) : " + field.value.constant; + } + } else { + switch (field.value.type.base_type) { + case BASE_TYPE_STRUCT: + code += type_name + " obj"; + if (struct_def.fixed) { + code += ") { return obj.__init(bb_pos + "; + code += NumToString(field.value.offset) + ", bb)"; + } else { + code += offset_prefix; + code += "obj.__init("; + code += field.value.type.struct_def->fixed + ? "o + bb_pos" + : "__indirect(o + i)"; + code += ", bb) : null"; + } + break; + case BASE_TYPE_STRING: + code += offset_prefix + getter +"(o) : null"; + break; + case BASE_TYPE_VECTOR: { + auto vectortype = field.value.type.VectorType(); + if (vectortype.base_type == BASE_TYPE_STRUCT) { + code += type_name + " obj, "; + getter = "obj.__init"; + } + code += "int j" + offset_prefix + getter +"("; + auto index = "__vector(o) + j * " + + NumToString(InlineSize(vectortype)); + if (vectortype.base_type == BASE_TYPE_STRUCT) { + code += vectortype.struct_def->fixed + ? index + : "__indirect(" + index + ")"; + code += ", bb"; + } else { + code += index; + } + code += ") : "; + code += IsScalar(field.value.type.element) ? "0" : "null"; + break; + } + case BASE_TYPE_UNION: + code += type_name + " obj" + offset_prefix + getter; + code += "(obj, o) : null"; + break; + default: + assert(0); + } + } + code += "; }\n"; + if (field.value.type.base_type == BASE_TYPE_VECTOR) { + code += " public int " + MakeCamel(field.name, false) + "Length("; + code += offset_prefix; + code += "__vector_len(o) : 0; }\n"; + } + } + code += "\n"; + if (struct_def.fixed) { + // create a struct constructor function + code += " public static int create" + struct_def.name; + code += "(FlatBufferBuilder builder"; + GenStructArgs(struct_def, code_ptr, ""); + code += ") {\n"; + GenStructBody(struct_def, code_ptr, ""); + code += " return builder.offset();\n }\n"; + } else { + // Create a set of static methods that allow table construction, + // of the form: + // public static void addName(FlatBufferBuilder builder, short name) + // { builder.addShort(id, name, default); } + code += " public static void start" + struct_def.name; + code += "(FlatBufferBuilder builder) { builder.startObject("; + code += NumToString(struct_def.fields.vec.size()) + "); }\n"; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + auto &field = **it; + if (field.deprecated) continue; + code += " public static void add" + MakeCamel(field.name); + code += "(FlatBufferBuilder builder, " + GenTypeBasic(field.value.type); + code += " " + MakeCamel(field.name, false) + ") { builder.add"; + code += GenMethod(field) + "("; + code += NumToString(it - struct_def.fields.vec.begin()) + ", "; + code += MakeCamel(field.name, false) + ", " + field.value.constant; + code += "); }\n"; + if (field.value.type.base_type == BASE_TYPE_VECTOR) { + code += " public static void start" + MakeCamel(field.name); + code += "Vector(FlatBufferBuilder builder, int numElems) "; + code += "{ builder.startVector("; + code += NumToString(InlineSize(field.value.type)); + code += ", numElems); }\n"; + } + } + code += " public static int end" + struct_def.name; + code += "(FlatBufferBuilder builder) { return builder.endObject(); }\n"; + } + code += "};\n\n"; +} + +// Save out the generated code for a single Java class while adding +// declaration boilerplate. +static bool SaveClass(const Parser &parser, const Definition &def, + const std::string &classcode, const std::string &path) { + if (!classcode.length()) return true; + + std::string name_space_java; + std::string name_space_dir = path; + for (auto it = parser.name_space_.begin(); + it != parser.name_space_.end(); ++it) { + if (name_space_java.length()) { + name_space_java += "."; + name_space_dir += PATH_SEPARATOR; + } + name_space_java += *it; + name_space_dir += *it; + mkdir(name_space_dir.c_str(), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); + } + + std::string code = "// automatically generated, do not modify\n\n"; + code += "package " + name_space_java + ";\n\n"; + code += "import java.nio.*;\nimport java.lang.*;\nimport java.util.*;\n"; + code += "import flatbuffers.*;\n\n"; + code += classcode; + auto filename = name_space_dir + PATH_SEPARATOR + def.name + ".java"; + return SaveFile(filename.c_str(), code, false); +} + +} // namespace java + +bool GenerateJava(const Parser &parser, + const std::string &path, + const std::string &file_name) { + using namespace java; + + for (auto it = parser.enums_.vec.begin(); + it != parser.enums_.vec.end(); ++it) { + std::string enumcode; + GenEnum(**it, &enumcode); + if (!SaveClass(parser, **it, enumcode, path)) + return false; + } + + for (auto it = parser.structs_.vec.begin(); + it != parser.structs_.vec.end(); ++it) { + std::string declcode; + GenStruct(**it, &declcode, parser.root_struct_def); + if (!SaveClass(parser, **it, declcode, path)) + return false; + } + + return true; +} + +} // namespace flatbuffers + diff --git a/src/idl_gen_text.cpp b/src/idl_gen_text.cpp new file mode 100644 index 00000000..2bb4ddd1 --- /dev/null +++ b/src/idl_gen_text.cpp @@ -0,0 +1,214 @@ +/* + * 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. + */ + +// independent from idl_parser, since this code is not needed for most clients + +#include "flatbuffers/flatbuffers.h" +#include "flatbuffers/idl.h" +#include "flatbuffers/util.h" + +namespace flatbuffers { + +static void GenStruct(const StructDef &struct_def, const Table *table, + int indent, int indent_step, std::string *_text); + +// Print (and its template specialization below for pointers) generate text +// for a single FlatBuffer value into JSON format. +// The general case for scalars: +template<typename T> void Print(T val, Type type, int indent, int indent_step, + StructDef * /*union_sd*/, std::string *_text) { + std::string &text = *_text; + text += NumToString(val); +} + +// Print a vector a sequence of JSON values, comma separated, wrapped in "[]". +template<typename T> void PrintVector(const Vector<T> &v, Type type, + int indent, int indent_step, + std::string *_text) { + std::string &text = *_text; + text += "[\n"; + for (uoffset_t i = 0; i < v.Length(); i++) { + if (i) text += ",\n"; + text.append(indent + indent_step, ' '); + if (IsStruct(type)) + Print(v.GetStructFromOffset(i * type.struct_def->bytesize), type, + indent + indent_step, indent_step, nullptr, _text); + else + Print(v.Get(i), type, indent + indent_step, indent_step, nullptr, _text); + } + text += "\n"; + text.append(indent, ' '); + text += "]"; +} + +static void EscapeString(const String &s, std::string *_text) { + std::string &text = *_text; + text += "\""; + for (uoffset_t i = 0; i < s.Length(); i++) { + char c = s.Get(i); + switch (c) { + case '\n': text += "\\n"; break; + case '\t': text += "\\t"; break; + case '\r': text += "\\r"; break; + case '\"': text += "\\\""; break; + case '\\': text += "\\\\"; break; + default: + if (c >= ' ' && c <= '~') { + text += c; + } else { + auto u = static_cast<unsigned char>(c); + text += "\\x" + IntToStringHex(u); + } + break; + } + } + text += "\""; +} + +// Specialization of Print above for pointer types. +template<> void Print<const void *>(const void *val, + Type type, int indent, int indent_step, + StructDef *union_sd, std::string *_text) { + switch (type.base_type) { + case BASE_TYPE_UNION: + // If this assert hits, you have an corrupt buffer, a union type field + // was not present or was out of range. + assert(union_sd); + GenStruct(*union_sd, + reinterpret_cast<const Table *>(val), + indent, + indent_step, + _text); + break; + case BASE_TYPE_STRUCT: + GenStruct(*type.struct_def, + reinterpret_cast<const Table *>(val), + indent, + indent_step, + _text); + break; + case BASE_TYPE_STRING: { + EscapeString(*reinterpret_cast<const String *>(val), _text); + break; + } + case BASE_TYPE_VECTOR: + type = type.VectorType(); + // Call PrintVector above specifically for each element type: + switch (type.base_type) { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + case BASE_TYPE_ ## ENUM: \ + PrintVector<CTYPE>( \ + *reinterpret_cast<const Vector<CTYPE> *>(val), \ + type, indent, indent_step, _text); break; + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + } + break; + default: assert(0); + } +} + +// Generate text for a scalar field. +template<typename T> static void GenField(const FieldDef &fd, + const Table *table, bool fixed, + int indent_step, int indent, + std::string *_text) { + Print(fixed ? + reinterpret_cast<const Struct *>(table)->GetField<T>(fd.value.offset) : + table->GetField<T>(fd.value.offset, 0), fd.value.type, indent, indent_step, + nullptr, _text); +} + +// Generate text for non-scalar field. +static void GenFieldOffset(const FieldDef &fd, const Table *table, bool fixed, + int indent, int indent_step, StructDef *union_sd, + std::string *_text) { + const void *val = nullptr; + if (fixed) { + // The only non-scalar fields in structs are structs. + assert(IsStruct(fd.value.type)); + val = reinterpret_cast<const Struct *>(table)-> + GetStruct<const void *>(fd.value.offset); + } else { + val = IsStruct(fd.value.type) + ? table->GetStruct<const void *>(fd.value.offset) + : table->GetPointer<const void *>(fd.value.offset); + } + Print(val, fd.value.type, indent, indent_step, union_sd, _text); +} + +// Generate text for a struct or table, values separated by commas, indented, +// and bracketed by "{}" +static void GenStruct(const StructDef &struct_def, const Table *table, + int indent, int indent_step, std::string *_text) { + std::string &text = *_text; + text += "{\n"; + int fieldout = 0; + StructDef *union_sd = nullptr; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); + ++it) { + FieldDef &fd = **it; + if (struct_def.fixed || table->CheckField(fd.value.offset)) { + // The field is present. + if (fieldout++) text += ",\n"; + text.append(indent + indent_step, ' '); + text += fd.name; + text += ": "; + switch (fd.value.type.base_type) { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + case BASE_TYPE_ ## ENUM: \ + GenField<CTYPE>(fd, table, struct_def.fixed, \ + indent + indent_step, indent_step, _text); \ + break; + FLATBUFFERS_GEN_TYPES_SCALAR(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + // Generate drop-thru case statements for all pointer types: + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + case BASE_TYPE_ ## ENUM: + FLATBUFFERS_GEN_TYPES_POINTER(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + GenFieldOffset(fd, table, struct_def.fixed, indent + indent_step, + indent_step, union_sd, _text); + break; + } + if (fd.value.type.base_type == BASE_TYPE_UTYPE) { + union_sd = fd.value.type.enum_def->ReverseLookup( + table->GetField<uint8_t>(fd.value.offset, 0)); + } + } + } + text += "\n"; + text.append(indent, ' '); + text += "}"; +} + +// Generate a text representation of a flatbuffer in JSON format. +void GenerateText(const Parser &parser, const void *flatbuffer, + int indent_step, std::string *_text) { + std::string &text = *_text; + assert(parser.root_struct_def); // call SetRootType() + text.reserve(1024); // Reduce amount of inevitable reallocs. + GenStruct(*parser.root_struct_def, + GetRoot<Table>(flatbuffer), + 0, + indent_step, + _text); + text += "\n"; +} + +} // namespace flatbuffers + diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp new file mode 100644 index 00000000..4e053ec3 --- /dev/null +++ b/src/idl_parser.cpp @@ -0,0 +1,724 @@ +/* + * 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. + */ + +#include <algorithm> + +#include "flatbuffers/flatbuffers.h" +#include "flatbuffers/idl.h" +#include "flatbuffers/util.h" + +namespace flatbuffers { + +const char *const kTypeNames[] = { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) IDLTYPE, + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + nullptr +}; + +const char kTypeSizes[] = { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) sizeof(CTYPE), + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD +}; + +static void Error(const std::string &msg) { + throw msg; +} + +// Ensure that integer values we parse fit inside the declared integer type. +static void CheckBitsFit(int64_t val, size_t bits) { + auto mask = (1ll << bits) - 1; // Bits we allow to be used. + if (bits < 64 && + (val & ~mask) != 0 && // Positive or unsigned. + (val | mask) != -1) // Negative. + Error("constant does not fit in a " + NumToString(bits) + "-bit field"); +} + +// atot: templated version of atoi/atof: convert a string to an instance of T. +template<typename T> inline T atot(const char *s) { + auto val = StringToInt(s); + CheckBitsFit(val, sizeof(T) * 8); + return (T)val; +} +template<> inline bool atot<bool>(const char *s) { + return 0 != atoi(s); +} +template<> inline float atot<float>(const char *s) { + return static_cast<float>(strtod(s, nullptr)); +} +template<> inline double atot<double>(const char *s) { + return strtod(s, nullptr); +} + +template<> inline Offset<void> atot<Offset<void>>(const char *s) { + return Offset<void>(atoi(s)); +} + +// Declare tokens we'll use. Single character tokens are represented by their +// ascii character code (e.g. '{'), others above 256. +#define FLATBUFFERS_GEN_TOKENS(TD) \ + TD(Eof, 256, "end of file") \ + TD(StringConstant, 257, "string constant") \ + TD(IntegerConstant, 258, "integer constant") \ + TD(FloatConstant, 259, "float constant") \ + TD(Identifier, 260, "identifier") \ + TD(Table, 261, "table") \ + TD(Struct, 262, "struct") \ + TD(Enum, 263, "enum") \ + TD(Union, 264, "union") \ + TD(NameSpace, 265, "namespace") \ + TD(RootType, 266, "root_type") +enum { + #define FLATBUFFERS_TOKEN(NAME, VALUE, STRING) kToken ## NAME, + FLATBUFFERS_GEN_TOKENS(FLATBUFFERS_TOKEN) + #undef FLATBUFFERS_TOKEN + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) kToken ## ENUM, + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD +}; + +static std::string TokenToString(int t) { + static const char *tokens[] = { + #define FLATBUFFERS_TOKEN(NAME, VALUE, STRING) STRING, + FLATBUFFERS_GEN_TOKENS(FLATBUFFERS_TOKEN) + #undef FLATBUFFERS_TOKEN + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) IDLTYPE, + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + }; + if (t < 256) { // A single ascii char token. + std::string s; + s.append(1, t); + return s; + } else { // Other tokens. + return tokens[t - 256]; + } +} + +void Parser::Next() { + doc_comment_.clear(); + bool seen_newline = false; + for (;;) { + char c = *cursor_++; + token_ = c; + switch (c) { + case '\0': cursor_--; token_ = kTokenEof; return; + case ' ': case '\r': case '\t': break; + case '\n': line_++; seen_newline = true; break; + case '{': case '}': case '(': case ')': case '[': case ']': return; + case ',': case ':': case ';': case '=': return; + case '.': + if(!isdigit(*cursor_)) return; + Error("floating point constant can\'t start with \".\""); + break; + case '\"': + attribute_ = ""; + while (*cursor_ != '\"') { + if (*cursor_ < ' ' && *cursor_ >= 0) + Error("illegal character in string constant"); + if (*cursor_ == '\\') { + cursor_++; + switch (*cursor_) { + case 'n': attribute_ += '\n'; cursor_++; break; + case 't': attribute_ += '\t'; cursor_++; break; + case 'r': attribute_ += '\r'; cursor_++; break; + case '\"': attribute_ += '\"'; cursor_++; break; + case '\\': attribute_ += '\\'; cursor_++; break; + default: Error("unknown escape code in string constant"); break; + } + } else { // printable chars + UTF-8 bytes + attribute_ += *cursor_++; + } + } + cursor_++; + token_ = kTokenStringConstant; + return; + case '/': + if (*cursor_ == '/') { + const char *start = ++cursor_; + while (*cursor_ && *cursor_ != '\n') cursor_++; + if (*start == '/') { // documentation comment + if (!seen_newline) + Error("a documentation comment should be on a line on its own"); + // todo: do we want to support multiline comments instead? + doc_comment_ += std::string(start + 1, cursor_); + } + break; + } + // fall thru + default: + if (isalpha(static_cast<unsigned char>(c))) { + // Collect all chars of an identifier: + const char *start = cursor_ - 1; + while (isalnum(static_cast<unsigned char>(*cursor_)) || + *cursor_ == '_') + cursor_++; + attribute_.clear(); + attribute_.append(start, cursor_); + // First, see if it is a type keyword from the table of types: + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + if (attribute_ == IDLTYPE) { \ + token_ = kToken ## ENUM; \ + return; \ + } + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + // If it's a boolean constant keyword, turn those into integers, + // which simplifies our logic downstream. + if (attribute_ == "true" || attribute_ == "false") { + attribute_ = NumToString(attribute_ == "true"); + token_ = kTokenIntegerConstant; + return; + } + // Check for declaration keywords: + if (attribute_ == "table") { token_ = kTokenTable; return; } + if (attribute_ == "struct") { token_ = kTokenStruct; return; } + if (attribute_ == "enum") { token_ = kTokenEnum; return; } + if (attribute_ == "union") { token_ = kTokenUnion; return; } + if (attribute_ == "namespace") { token_ = kTokenNameSpace; return; } + if (attribute_ == "root_type") { token_ = kTokenRootType; return; } + // If not, it is a user-defined identifier: + token_ = kTokenIdentifier; + return; + } else if (isdigit(static_cast<unsigned char>(c)) || c == '-') { + const char *start = cursor_ - 1; + while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++; + if (*cursor_ == '.') { + cursor_++; + while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++; + token_ = kTokenFloatConstant; + } else { + token_ = kTokenIntegerConstant; + } + attribute_.clear(); + attribute_.append(start, cursor_); + return; + } + std::string ch; + ch = c; + if (c < ' ' || c > '~') ch = "code: " + NumToString(c); + Error("illegal character: " + ch); + break; + } + } +} + +// Check if a given token is next, if so, consume it as well. +bool Parser::IsNext(int t) { + bool isnext = t == token_; + if (isnext) Next(); + return isnext; +} + +// Expect a given token to be next, consume it, or error if not present. +void Parser::Expect(int t) { + if (t != token_) { + Error("expecting: " + TokenToString(t) + " instead got: " + + TokenToString(token_)); + } + Next(); +} + +// Parse any IDL type. +void Parser::ParseType(Type &type) { + if (token_ >= kTokenBOOL && token_ <= kTokenSTRING) { + type.base_type = static_cast<BaseType>(token_ - kTokenNONE); + } else { + if (token_ == kTokenIdentifier) { + auto enum_def = enums_.Lookup(attribute_); + if (enum_def) { + type = enum_def->underlying_type; + if (enum_def->is_union) type.base_type = BASE_TYPE_UNION; + } else { + type.base_type = BASE_TYPE_STRUCT; + type.struct_def = LookupCreateStruct(attribute_); + } + } else if (token_ == '[') { + Next(); + Type subtype; + ParseType(subtype); + if (subtype.base_type == BASE_TYPE_VECTOR) { + // We could support this, but it will complicate things, and it's + // easier to work around with a struct around the inner vector. + Error("nested vector types not supported (wrap in table first)."); + } + if (subtype.base_type == BASE_TYPE_UNION) { + // We could support this if we stored a struct of 2 elements per + // union element. + Error("vector of union types not supported (wrap in table first)."); + } + type = Type(BASE_TYPE_VECTOR, subtype.struct_def); + type.element = subtype.base_type; + Expect(']'); + return; + } else { + Error("illegal type syntax"); + } + } + Next(); +} + +FieldDef &Parser::AddField(StructDef &struct_def, + const std::string &name, + const Type &type) { + auto &field = *new FieldDef(); + field.value.offset = + FieldIndexToOffset(static_cast<voffset_t>(struct_def.fields.vec.size())); + field.name = name; + field.value.type = type; + if (struct_def.fixed) { // statically compute the field offset + auto size = InlineSize(type); + auto alignment = InlineAlignment(type); + // structs_ need to have a predictable format, so we need to align to + // the largest scalar + struct_def.minalign = std::max(struct_def.minalign, alignment); + struct_def.PadLastField(alignment); + field.value.offset = static_cast<uoffset_t>(struct_def.bytesize); + struct_def.bytesize += size; + } + if (struct_def.fields.Add(name, &field)) + Error("field already exists: " + name); + return field; +} + +void Parser::ParseField(StructDef &struct_def) { + std::string name = attribute_; + std::string dc = doc_comment_; + Expect(kTokenIdentifier); + Expect(':'); + Type type; + ParseType(type); + + if (struct_def.fixed && !IsScalar(type.base_type) && !IsStruct(type)) + Error("structs_ may contain only scalar or struct fields"); + + if (type.base_type == BASE_TYPE_UNION) { + // For union fields, add a second auto-generated field to hold the type, + // with _type appended as the name. + AddField(struct_def, name + "_type", type.enum_def->underlying_type); + } + + auto &field = AddField(struct_def, name, type); + + if (token_ == '=') { + Next(); + ParseSingleValue(field.value); + } + + field.doc_comment = dc; + ParseMetaData(field); + field.deprecated = field.attributes.Lookup("deprecated") != nullptr; + if (field.deprecated && struct_def.fixed) + Error("can't deprecate fields in a struct"); + + Expect(';'); +} + +void Parser::ParseAnyValue(Value &val, FieldDef *field) { + switch (val.type.base_type) { + case BASE_TYPE_UNION: { + assert(field); + if (!field_stack_.size() || + field_stack_.back().second->value.type.base_type != BASE_TYPE_UTYPE) + Error("missing type field before this union value: " + field->name); + auto enum_idx = atot<unsigned char>( + field_stack_.back().first.constant.c_str()); + auto struct_def = val.type.enum_def->ReverseLookup(enum_idx); + if (!struct_def) Error("illegal type id for: " + field->name); + val.constant = NumToString(ParseTable(*struct_def)); + break; + } + case BASE_TYPE_STRUCT: + val.constant = NumToString(ParseTable(*val.type.struct_def)); + break; + case BASE_TYPE_STRING: { + auto s = attribute_; + Expect(kTokenStringConstant); + val.constant = NumToString(builder_.CreateString(s).o); + break; + } + case BASE_TYPE_VECTOR: { + Expect('['); + val.constant = NumToString(ParseVector(val.type.VectorType())); + break; + } + default: + ParseSingleValue(val); + break; + } +} + +void Parser::SerializeStruct(const StructDef &struct_def, const Value &val) { + auto off = atot<uoffset_t>(val.constant.c_str()); + assert(struct_stack_.size() - off == struct_def.bytesize); + builder_.Align(struct_def.minalign); + builder_.PushBytes(&struct_stack_[off], struct_def.bytesize); + struct_stack_.resize(struct_stack_.size() - struct_def.bytesize); + builder_.AddStructOffset(val.offset, builder_.GetSize()); +} + +uoffset_t Parser::ParseTable(const StructDef &struct_def) { + Expect('{'); + size_t fieldn = 0; + for (;;) { + std::string name = attribute_; + if (!IsNext(kTokenStringConstant)) Expect(kTokenIdentifier); + auto field = struct_def.fields.Lookup(name); + if (!field) Error("unknown field: " + name); + if (struct_def.fixed && (fieldn >= struct_def.fields.vec.size() + || struct_def.fields.vec[fieldn] != field)) { + Error("struct field appearing out of order: " + name); + } + Expect(':'); + Value val = field->value; + ParseAnyValue(val, field); + field_stack_.push_back(std::make_pair(val, field)); + fieldn++; + if (IsNext('}')) break; + Expect(','); + } + if (struct_def.fixed && fieldn != struct_def.fields.vec.size()) + Error("incomplete struct initialization: " + struct_def.name); + auto start = struct_def.fixed + ? builder_.StartStruct(struct_def.minalign) + : builder_.StartTable(); + + for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1; + size; + size /= 2) { + // Go through elements in reverse, since we're building the data backwards. + for (auto it = field_stack_.rbegin(); + it != field_stack_.rbegin() + fieldn; ++it) { + auto &value = it->first; + auto field = it->second; + if (!struct_def.sortbysize || size == SizeOf(value.type.base_type)) { + switch (value.type.base_type) { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + case BASE_TYPE_ ## ENUM: \ + builder_.Pad(field->padding); \ + builder_.AddElement(value.offset, \ + atot<CTYPE>( value.constant.c_str()), \ + atot<CTYPE>(field->value.constant.c_str())); \ + break; + FLATBUFFERS_GEN_TYPES_SCALAR(FLATBUFFERS_TD); + #undef FLATBUFFERS_TD + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + case BASE_TYPE_ ## ENUM: \ + builder_.Pad(field->padding); \ + if (IsStruct(field->value.type)) { \ + SerializeStruct(*field->value.type.struct_def, value); \ + } else { \ + builder_.AddOffset(value.offset, \ + atot<CTYPE>(value.constant.c_str())); \ + } \ + break; + FLATBUFFERS_GEN_TYPES_POINTER(FLATBUFFERS_TD); + #undef FLATBUFFERS_TD + } + } + } + } + for (size_t i = 0; i < fieldn; i++) field_stack_.pop_back(); + + if (struct_def.fixed) { + builder_.ClearOffsets(); + builder_.EndStruct(); + // Temporarily store this struct in a side buffer, since this data has to + // be stored in-line later in the parent object. + auto off = struct_stack_.size(); + struct_stack_.insert(struct_stack_.end(), + builder_.GetBufferPointer(), + builder_.GetBufferPointer() + struct_def.bytesize); + builder_.PopBytes(struct_def.bytesize); + return static_cast<uoffset_t>(off); + } else { + return builder_.EndTable( + start, + static_cast<voffset_t>(struct_def.fields.vec.size())); + } +} + +uoffset_t Parser::ParseVector(const Type &type) { + int count = 0; + if (token_ != ']') for (;;) { + Value val; + val.type = type; + ParseAnyValue(val, NULL); + field_stack_.push_back(std::make_pair(val, nullptr)); + count++; + if (token_ == ']') break; + Expect(','); + } + Next(); + + builder_.StartVector(count * InlineSize(type), InlineAlignment((type))); + for (int i = 0; i < count; i++) { + // start at the back, since we're building the data backwards. + auto &val = field_stack_.back().first; + switch (val.type.base_type) { + #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE) \ + case BASE_TYPE_ ## ENUM: \ + if (IsStruct(val.type)) SerializeStruct(*val.type.struct_def, val); \ + else builder_.PushElement(atot<CTYPE>(val.constant.c_str())); \ + break; + FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) + #undef FLATBUFFERS_TD + } + field_stack_.pop_back(); + } + + builder_.ClearOffsets(); + return builder_.EndVector(count); +} + +void Parser::ParseMetaData(Definition &def) { + if (IsNext('(')) { + for (;;) { + auto name = attribute_; + Expect(kTokenIdentifier); + auto e = new Value(); + def.attributes.Add(name, e); + if (IsNext(':')) { + ParseSingleValue(*e); + } + if (IsNext(')')) break; + Expect(','); + } + } +} + +bool Parser::TryTypedValue(int dtoken, + bool check, + Value &e, + BaseType req) { + bool match = dtoken == token_; + if (match) { + e.constant = attribute_; + if (!check) { + if (e.type.base_type == BASE_TYPE_NONE) { + e.type.base_type = req; + } else { + Error(std::string("type mismatch: expecting: ") + + kTypeNames[e.type.base_type] + + ", found: " + + kTypeNames[req]); + } + } + Next(); + } + return match; +} + +void Parser::ParseSingleValue(Value &e) { + if (TryTypedValue(kTokenIntegerConstant, + IsScalar(e.type.base_type), + e, + BASE_TYPE_INT) || + TryTypedValue(kTokenFloatConstant, + IsFloat(e.type.base_type), + e, + BASE_TYPE_FLOAT) || + TryTypedValue(kTokenStringConstant, + e.type.base_type == BASE_TYPE_STRING, + e, + BASE_TYPE_STRING)) { + } else if (token_ == kTokenIdentifier) { + for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) { + auto ev = (*it)->vals.Lookup(attribute_); + if (ev) { + attribute_ = NumToString(ev->value); + TryTypedValue(kTokenIdentifier, + IsInteger(e.type.base_type), + e, + BASE_TYPE_INT); + return; + } + } + Error("not valid enum value: " + attribute_); + } else { + Error("cannot parse value starting with: " + TokenToString(token_)); + } +} + +StructDef *Parser::LookupCreateStruct(const std::string &name) { + auto struct_def = structs_.Lookup(name); + if (!struct_def) { + // Rather than failing, we create a "pre declared" StructDef, due to + // circular references, and check for errors at the end of parsing. + struct_def = new StructDef(); + structs_.Add(name, struct_def); + struct_def->name = name; + struct_def->predecl = true; + } + return struct_def; +} + +void Parser::ParseEnum(bool is_union) { + std::string dc = doc_comment_; + Next(); + std::string name = attribute_; + Expect(kTokenIdentifier); + auto &enum_def = *new EnumDef(); + enum_def.name = name; + enum_def.doc_comment = dc; + enum_def.is_union = is_union; + if (enums_.Add(name, &enum_def)) Error("enum already exists: " + name); + if (is_union) { + enum_def.underlying_type.base_type = BASE_TYPE_UTYPE; + enum_def.underlying_type.enum_def = &enum_def; + } else if (IsNext(':')) { + // short is the default type for fields when you use enums, + // though people are encouraged to pick any integer type instead. + ParseType(enum_def.underlying_type); + if (!IsInteger(enum_def.underlying_type.base_type)) + Error("underlying enum type must be integral"); + } else { + enum_def.underlying_type.base_type = BASE_TYPE_SHORT; + } + ParseMetaData(enum_def); + Expect('{'); + if (is_union) enum_def.vals.Add("NONE", new EnumVal("NONE", 0)); + do { + std::string name = attribute_; + std::string dc = doc_comment_; + Expect(kTokenIdentifier); + auto prevsize = enum_def.vals.vec.size(); + auto &ev = *new EnumVal(name, static_cast<int>( + enum_def.vals.vec.size() + ? enum_def.vals.vec.back()->value + 1 + : 0)); + if (enum_def.vals.Add(name, &ev)) + Error("enum value already exists: " + name); + ev.doc_comment = dc; + if (is_union) { + ev.struct_def = LookupCreateStruct(name); + } + if (IsNext('=')) { + ev.value = atoi(attribute_.c_str()); + Expect(kTokenIntegerConstant); + if (prevsize && enum_def.vals.vec[prevsize - 1]->value >= ev.value) + Error("enum values must be specified in ascending order"); + } + } while (IsNext(',')); + Expect('}'); +} + +void Parser::ParseDecl() { + std::string dc = doc_comment_; + bool fixed = IsNext(kTokenStruct); + if (!fixed) Expect(kTokenTable); + std::string name = attribute_; + Expect(kTokenIdentifier); + auto &struct_def = *LookupCreateStruct(name); + if (!struct_def.predecl) Error("datatype already exists: " + name); + struct_def.predecl = false; + struct_def.name = name; + struct_def.doc_comment = dc; + struct_def.fixed = fixed; + // Move this struct to the back of the vector just in case it was predeclared, + // to preserve declartion order. + remove(structs_.vec.begin(), structs_.vec.end(), &struct_def); + structs_.vec.back() = &struct_def; + ParseMetaData(struct_def); + struct_def.sortbysize = + struct_def.attributes.Lookup("original_order") == nullptr && !fixed; + Expect('{'); + while (token_ != '}') ParseField(struct_def); + struct_def.PadLastField(struct_def.minalign); + Expect('}'); + auto force_align = struct_def.attributes.Lookup("force_align"); + if (fixed && force_align) { + auto align = static_cast<size_t>(atoi(force_align->constant.c_str())); + if (force_align->type.base_type != BASE_TYPE_INT || + align < struct_def.minalign || + align > 256 || + align & (align - 1)) + Error("force_align must be a power of two integer ranging from the" + "struct\'s natural alignment to 256"); + struct_def.minalign = align; + } +} + +bool Parser::SetRootType(const char *name) { + root_struct_def = structs_.Lookup(name); + return root_struct_def != nullptr; +} + +bool Parser::Parse(const char *source) { + source_ = cursor_ = source; + line_ = 1; + error_.clear(); + builder_.Clear(); + try { + Next(); + while (token_ != kTokenEof) { + if (token_ == kTokenNameSpace) { + Next(); + for (;;) { + name_space_.push_back(attribute_); + Expect(kTokenIdentifier); + if (!IsNext('.')) break; + } + Expect(';'); + } else if (token_ == '{') { + if (!root_struct_def) Error("no root type set to parse json with"); + if (builder_.GetSize()) { + Error("cannot have more than one json object in a file"); + } + builder_.Finish(Offset<Table>(ParseTable(*root_struct_def))); + } else if (token_ == kTokenEnum) { + ParseEnum(false); + } else if (token_ == kTokenUnion) { + ParseEnum(true); + } else if (token_ == kTokenRootType) { + Next(); + auto root_type = attribute_; + Expect(kTokenIdentifier); + Expect(';'); + if (!SetRootType(root_type.c_str())) + Error("unknown root type: " + root_type); + if (root_struct_def->fixed) + Error("root type must be a table"); + } else { + ParseDecl(); + } + } + for (auto it = structs_.vec.begin(); it != structs_.vec.end(); ++it) { + if ((*it)->predecl) + Error("type referenced but not defined: " + (*it)->name); + } + for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) { + auto &enum_def = **it; + if (enum_def.is_union) { + for (auto it = enum_def.vals.vec.begin(); + it != enum_def.vals.vec.end(); + ++it) { + auto &val = **it; + if (val.struct_def && val.struct_def->fixed) + Error("only tables can be union elements: " + val.name); + } + } + } + } catch (const std::string &msg) { + error_ = "line " + NumToString(line_) + ": " + msg; + return false; + } + assert(!struct_stack_.size()); + return true; +} + +} // namespace flatbuffers diff --git a/tests/JavaTest.bat b/tests/JavaTest.bat new file mode 100755 index 00000000..b8a0b5a0 --- /dev/null +++ b/tests/JavaTest.bat @@ -0,0 +1,21 @@ +@echo off +rem Copyright 2014 Google Inc. All rights reserved. +rem +rem Licensed under the Apache License, Version 2.0 (the "License"); +rem you may not use this file except in compliance with the License. +rem You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +rem Compile then run the Java test. + +set batch_file_dir=%~d0%~p0 + +javac -classpath %batch_file_dir%\..\java;%batch_file_dir% JavaTest.java +java -classpath %batch_file_dir%\..\java;%batch_file_dir% JavaTest diff --git a/tests/JavaTest.java b/tests/JavaTest.java new file mode 100755 index 00000000..86424b18 --- /dev/null +++ b/tests/JavaTest.java @@ -0,0 +1,145 @@ +/* + * 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. + */ + +import java.io.*; +import java.nio.ByteBuffer; +import MyGame.Example.*; +import flatbuffers.FlatBufferBuilder; + +class JavaTest { + public static void main(String[] args) { + + // First, let's test reading a FlatBuffer generated by C++ code: + // This file was generated from monsterdata_test.json + + byte[] data = null; + File file = new File("monsterdata_test_wire.bin"); + RandomAccessFile f = null; + try { + f = new RandomAccessFile(file, "r"); + data = new byte[(int)f.length()]; + f.readFully(data); + f.close(); + } catch(java.io.IOException e) { + System.out.println("FlatBuffers test: couldn't read file"); + return; + } + + // Now test it: + + ByteBuffer bb = ByteBuffer.wrap(data); + TestBuffer(bb, 0); + + // Second, let's create a FlatBuffer from scratch in Java, and test it also. + // We set up the same values as monsterdata.json: + + FlatBufferBuilder fbb = new FlatBufferBuilder(1024); + + int str = fbb.createString("MyMonster"); + + Monster.startInventoryVector(fbb, 5); + for (byte i = 4; i >=0; i--) fbb.addByte(i); + int inv = fbb.endVector(); + + Monster.startMonster(fbb); + Monster.addHp(fbb, (short)20); + int mon2 = Monster.endMonster(fbb); + + Monster.startTest4Vector(fbb, 2); + Test.createTest(fbb, (short)10, (byte)20); + Test.createTest(fbb, (short)30, (byte)40); + int test4 = fbb.endVector(); + + 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.addTestType(fbb, (byte)1); + Monster.addTest(fbb, mon2); + Monster.addTest4(fbb, test4); + int mon = Monster.endMonster(fbb); + + fbb.finish(mon); + + // Write the result to a file for debugging purposes: + // Note that the binaries are not necessarily identical, since the JSON + // parser may serialize in a slightly different order than the above + // Java code. They are functionally equivalent though. + + try { + DataOutputStream os = new DataOutputStream(new FileOutputStream( + "monsterdata_java_wire.bin")); + os.write(fbb.dataBuffer().array(), fbb.dataStart(), fbb.offset()); + os.close(); + } catch(java.io.IOException e) { + System.out.println("FlatBuffers test: couldn't write file"); + return; + } + + // Test it: + + TestBuffer(fbb.dataBuffer(), fbb.dataStart()); + + System.out.println("FlatBuffers test: completed successfully"); + } + + static void TestBuffer(ByteBuffer bb, int start) { + Monster monster = Monster.getRootAsMonster(bb, start); + + TestEq(monster.hp(), (short)80); + TestEq(monster.mana(), (short)150); // default + + TestEq(monster.name(), "MyMonster"); + // monster.friendly() // can't access, deprecated + + Vec3 pos = monster.pos(); + TestEq(pos.x(), 1.0f); + TestEq(pos.y(), 2.0f); + TestEq(pos.z(), 3.0f); + TestEq(pos.test1(), 3.0); + TestEq(pos.test2(), (byte)4); + Test t = pos.test3(); + TestEq(t.a(), (short)5); + TestEq(t.b(), (byte)6); + + TestEq(monster.testType(), (byte)Any.Monster); + Monster monster2 = new Monster(); + TestEq(monster.test(monster2) != null, true); + TestEq(monster2.hp(), (short)20); + + TestEq(monster.inventoryLength(), 5); + int invsum = 0; + for (int i = 0; i < monster.inventoryLength(); i++) + invsum += monster.inventory(i); + TestEq(invsum, 10); + + Test test_0 = monster.test4(0); + Test test_1 = monster.test4(1); + TestEq(monster.test4Length(), 2); + TestEq(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100); + } + + static <T> void TestEq(T a, T b) { + if (!a.equals(b)) { + System.out.println("" + a.getClass().getName() + " " + b.getClass().getName()); + System.out.println("FlatBuffers test FAILED: \'" + a + "\' != \'" + b + "\'"); + assert false; + System.exit(1); + } + } +} diff --git a/tests/MyGame/Example/Any.java b/tests/MyGame/Example/Any.java new file mode 100755 index 00000000..9cbafb15 --- /dev/null +++ b/tests/MyGame/Example/Any.java @@ -0,0 +1,14 @@ +// automatically generated, do not modify + +package MyGame.Example; + +import java.nio.*; +import java.lang.*; +import java.util.*; +import flatbuffers.*; + +public class Any { + public static final byte NONE = 0; + public static final byte Monster = 1; +}; + diff --git a/tests/MyGame/Example/Color.java b/tests/MyGame/Example/Color.java new file mode 100755 index 00000000..f983c392 --- /dev/null +++ b/tests/MyGame/Example/Color.java @@ -0,0 +1,15 @@ +// automatically generated, do not modify + +package MyGame.Example; + +import java.nio.*; +import java.lang.*; +import java.util.*; +import flatbuffers.*; + +public class Color { + public static final byte Red = 0; + public static final byte Green = 1; + public static final byte Blue = 2; +}; + diff --git a/tests/MyGame/Example/Monster.java b/tests/MyGame/Example/Monster.java new file mode 100755 index 00000000..e07d9b8c --- /dev/null +++ b/tests/MyGame/Example/Monster.java @@ -0,0 +1,42 @@ +// automatically generated, do not modify + +package MyGame.Example; + +import java.nio.*; +import java.lang.*; +import java.util.*; +import flatbuffers.*; + +public class Monster extends Table { + public static Monster getRootAsMonster(ByteBuffer _bb, int offset) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (new Monster()).__init(_bb.getInt(offset) + offset, _bb); } + public Monster __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } + public Vec3 pos() { return pos(new Vec3()); } + public Vec3 pos(Vec3 obj) { int o = __offset(4); return o != 0 ? obj.__init(o + bb_pos, bb) : null; } + public short mana() { int o = __offset(6); return o != 0 ? bb.getShort(o + bb_pos) : 150; } + public short hp() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) : 100; } + public String name() { int o = __offset(10); return o != 0 ? __string(o) : null; } + public byte inventory(int j) { int o = __offset(14); return o != 0 ? bb.get(__vector(o) + j * 1) : 0; } + public int inventoryLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; } + /// an example documentation comment: this will end up in the generated code multiline too + public byte color() { int o = __offset(16); return o != 0 ? bb.get(o + bb_pos) : 2; } + public byte testType() { int o = __offset(18); return o != 0 ? bb.get(o + bb_pos) : 0; } + public Table test(Table obj) { int o = __offset(20); return o != 0 ? __union(obj, o) : null; } + public Test test4(int j) { return test4(new Test(), j); } + public Test test4(Test obj, int j) { int o = __offset(22); return o != 0 ? obj.__init(__vector(o) + j * 4, bb) : null; } + public int test4Length() { int o = __offset(22); return o != 0 ? __vector_len(o) : 0; } + + public static void startMonster(FlatBufferBuilder builder) { builder.startObject(10); } + public static void addPos(FlatBufferBuilder builder, int pos) { builder.addStruct(0, pos, 0); } + public static void addMana(FlatBufferBuilder builder, short mana) { builder.addShort(1, mana, 150); } + public static void addHp(FlatBufferBuilder builder, short hp) { builder.addShort(2, hp, 100); } + public static void addName(FlatBufferBuilder builder, int name) { builder.addOffset(3, name, 0); } + public static void addInventory(FlatBufferBuilder builder, int inventory) { builder.addOffset(5, inventory, 0); } + public static void startInventoryVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems); } + public static void addColor(FlatBufferBuilder builder, byte color) { builder.addByte(6, color, 2); } + public static void addTestType(FlatBufferBuilder builder, byte testType) { builder.addByte(7, testType, 0); } + public static void addTest(FlatBufferBuilder builder, int test) { builder.addOffset(8, test, 0); } + public static void addTest4(FlatBufferBuilder builder, int test4) { builder.addOffset(9, test4, 0); } + public static void startTest4Vector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems); } + public static int endMonster(FlatBufferBuilder builder) { return builder.endObject(); } +}; + diff --git a/tests/MyGame/Example/Test.java b/tests/MyGame/Example/Test.java new file mode 100755 index 00000000..1773658b --- /dev/null +++ b/tests/MyGame/Example/Test.java @@ -0,0 +1,23 @@ +// automatically generated, do not modify + +package MyGame.Example; + +import java.nio.*; +import java.lang.*; +import java.util.*; +import flatbuffers.*; + +public class Test extends Struct { + public Test __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } + public short a() { return bb.getShort(bb_pos + 0); } + public byte b() { return bb.get(bb_pos + 2); } + + public static int createTest(FlatBufferBuilder builder, short a, byte b) { + builder.prep(2, 0); + builder.pad(1); + builder.putByte(b); + builder.putShort(a); + return builder.offset(); + } +}; + diff --git a/tests/MyGame/Example/Vec3.java b/tests/MyGame/Example/Vec3.java new file mode 100755 index 00000000..a71cbccd --- /dev/null +++ b/tests/MyGame/Example/Vec3.java @@ -0,0 +1,37 @@ +// automatically generated, do not modify + +package MyGame.Example; + +import java.nio.*; +import java.lang.*; +import java.util.*; +import flatbuffers.*; + +public class Vec3 extends Struct { + public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } + public float x() { return bb.getFloat(bb_pos + 0); } + public float y() { return bb.getFloat(bb_pos + 4); } + public float z() { return bb.getFloat(bb_pos + 8); } + public double test1() { return bb.getDouble(bb_pos + 16); } + public byte test2() { return bb.get(bb_pos + 24); } + public Test test3() { return test3(new Test()); } + public Test test3(Test obj) { return obj.__init(bb_pos + 26, bb); } + + public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double test1, byte test2, short Test_a, byte Test_b) { + builder.prep(16, 0); + builder.pad(2); + builder.prep(2, 0); + builder.pad(1); + builder.putByte(Test_b); + builder.putShort(Test_a); + builder.pad(1); + builder.putByte(test2); + builder.putDouble(test1); + builder.pad(4); + builder.putFloat(z); + builder.putFloat(y); + builder.putFloat(x); + return builder.offset(); + } +}; + diff --git a/tests/monster_test.fbs b/tests/monster_test.fbs new file mode 100755 index 00000000..d4c3a72f --- /dev/null +++ b/tests/monster_test.fbs @@ -0,0 +1,34 @@ +// example IDL file + +namespace MyGame.Example; + +enum Color:byte { Red = 0, Green, Blue = 2 } + +union Any { Monster } // TODO: add more elements + +struct Test { a:short; b:byte; } + +struct Vec3 (force_align: 16) { + x:float; + y:float; + z:float; + test1:double; + test2:byte; + test3:Test; +} + +table Monster { + pos:Vec3; + mana:short = 150; + hp:short = 100; + name:string; + friendly:bool = false (deprecated, priority: 1); + inventory:[ubyte]; + /// an example documentation comment: this will end up in the generated code + /// multiline too + color:Color = Blue; + test:Any; + test4:[Test]; +} + +root_type Monster; diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h new file mode 100755 index 00000000..4b240fa6 --- /dev/null +++ b/tests/monster_test_generated.h @@ -0,0 +1,123 @@ +// automatically generated, do not modify + +#include "flatbuffers/flatbuffers.h" + +namespace MyGame { +namespace Example { + +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]; } + +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]; } + +struct Test; +struct Vec3; +struct Monster; + +MANUALLY_ALIGNED_STRUCT(2) Test { + private: + int16_t a_; + int8_t b_; + int8_t __padding0; + + public: + Test(int16_t a, int8_t b) + : a_(flatbuffers::EndianScalar(a)), b_(flatbuffers::EndianScalar(b)), __padding0(0) {} + + int16_t a() const { return flatbuffers::EndianScalar(a_); } + int8_t b() const { return flatbuffers::EndianScalar(b_); } +}; +STRUCT_END(Test, 4); + +MANUALLY_ALIGNED_STRUCT(16) Vec3 { + private: + float x_; + float y_; + float z_; + int32_t __padding0; + double test1_; + int8_t test2_; + int8_t __padding1; + Test test3_; + int16_t __padding2; + + public: + Vec3(float x, float y, float z, double test1, int8_t test2, const Test &test3) + : x_(flatbuffers::EndianScalar(x)), y_(flatbuffers::EndianScalar(y)), z_(flatbuffers::EndianScalar(z)), __padding0(0), test1_(flatbuffers::EndianScalar(test1)), test2_(flatbuffers::EndianScalar(test2)), __padding1(0), test3_(test3), __padding2(0) {} + + float x() const { return flatbuffers::EndianScalar(x_); } + float y() const { return flatbuffers::EndianScalar(y_); } + float z() const { return flatbuffers::EndianScalar(z_); } + double test1() const { return flatbuffers::EndianScalar(test1_); } + int8_t test2() const { return flatbuffers::EndianScalar(test2_); } + const Test &test3() const { return test3_; } +}; +STRUCT_END(Vec3, 32); + +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); } + /// an example documentation comment: this will end up in the generated code multiline too + int8_t color() const { return GetField<int8_t>(16, 2); } + uint8_t test_type() const { return GetField<uint8_t>(18, 0); } + const void *test() const { return GetPointer<const void *>(20); } + const flatbuffers::Vector<const Test *> *test4() const { return GetPointer<const flatbuffers::Vector<const Test *> *>(22); } +}; + +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); } + void add_test_type(uint8_t test_type) { fbb_.AddElement<uint8_t>(18, test_type, 0); } + void add_test(flatbuffers::Offset<void> test) { fbb_.AddOffset(20, test); } + void add_test4(flatbuffers::Offset<flatbuffers::Vector<const Test *>> test4) { fbb_.AddOffset(22, test4); } + MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + flatbuffers::Offset<Monster> Finish() { return flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 10)); } +}; + +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, uint8_t test_type, flatbuffers::Offset<void> test, flatbuffers::Offset<flatbuffers::Vector<const Test *>> test4) { + MonsterBuilder builder_(_fbb); + builder_.add_test4(test4); + builder_.add_test(test); + builder_.add_inventory(inventory); + builder_.add_name(name); + builder_.add_pos(pos); + builder_.add_hp(hp); + builder_.add_mana(mana); + builder_.add_test_type(test_type); + builder_.add_color(color); + return builder_.Finish(); +} + +inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot<Monster>(buf); } + +}; // namespace MyGame +}; // namespace Example diff --git a/tests/monsterdata_test.json b/tests/monsterdata_test.json new file mode 100755 index 00000000..26d53041 --- /dev/null +++ b/tests/monsterdata_test.json @@ -0,0 +1,36 @@ +{ + pos: { + x: 1, + y: 2, + z: 3, + test1: 3, + test2: 4, + test3: { + a: 5, + b: 6 + } + }, + hp: 80, + name: "MyMonster", + inventory: [ + 0, + 1, + 2, + 3, + 4 + ], + test_type: 1, + test: { + hp: 20 + }, + test4: [ + { + a: 10, + b: 20 + }, + { + a: 30, + b: 40 + } + ] +} diff --git a/tests/monsterdata_test_wire.bin b/tests/monsterdata_test_wire.bin Binary files differnew file mode 100755 index 00000000..0d374481 --- /dev/null +++ b/tests/monsterdata_test_wire.bin diff --git a/tests/test.cpp b/tests/test.cpp new file mode 100644 index 00000000..d0d54039 --- /dev/null +++ b/tests/test.cpp @@ -0,0 +1,471 @@ +/* + * 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. + */ + +#include "flatbuffers/flatbuffers.h" +#include "flatbuffers/idl.h" +#include "flatbuffers/util.h" + +#include "monster_test_generated.h" + +#include <random> + +using namespace MyGame::Example; + +#ifdef __ANDROID__ + #include <android/log.h> + #define TEST_OUTPUT_LINE(...) \ + __android_log_print(ANDROID_LOG_INFO, "FlatBuffers", __VA_ARGS__) +#else + #define TEST_OUTPUT_LINE(...) \ + { printf(__VA_ARGS__); printf("\n"); } +#endif + +bool testing_fails = 0; + +template<typename T, typename U> +void TestEq(T expval, U val, const char *exp, const char *file, int line) { + if (expval != val) { + auto expval_str = flatbuffers::NumToString(expval); + auto val_str = flatbuffers::NumToString(val); + TEST_OUTPUT_LINE("TEST FAILED: %s:%d, %s (%s) != %s", file, line, + exp, expval_str.c_str(), val_str.c_str()); + assert(0); + testing_fails++; + } +} + +#define TEST_EQ(exp, val) TestEq( exp, val, #exp, __FILE__, __LINE__) +#define TEST_NOTNULL(exp) TestEq(!exp, false, #exp, __FILE__, __LINE__) + +// Include simple random number generator to ensure results will be the +// same cross platform. +// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator +uint32_t lcg_seed = 48271; +uint32_t lcg_rand() { + return lcg_seed = ((uint64_t)lcg_seed * 279470273UL) % 4294967291UL; +} +void lcg_reset() { lcg_seed = 48271; } + +// example of how to build up a serialized buffer algorithmically: +std::string CreateFlatBufferTest() { + flatbuffers::FlatBufferBuilder builder; + + auto vec = Vec3(1, 2, 3, 0, 0, Test(10, 20)); + + auto name = builder.CreateString("MyMonster"); + + unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + auto inventory = builder.CreateVector(inv_data, 10); + + Test tests[] = { Test(10, 20), Test(30, 40) }; + auto testv = builder.CreateVectorOfStructs(tests, 2); + + // create monster with very few fields set: + // (same functionality as CreateMonster below, but sets fields manually) + MonsterBuilder mb(builder); + mb.add_hp(20); + auto mloc2 = mb.Finish(); + + // shortcut for creating monster with all fields set: + auto mloc = CreateMonster(builder, &vec, 150, 80, name, inventory, Color_Blue, + Any_Monster, mloc2.Union(), // Store a union. + testv); + + builder.Finish(mloc); + + #ifdef FLATBUFFERS_TEST_VERBOSE + // print byte data for debugging: + auto p = builder.GetBufferPointer(); + for (flatbuffers::uoffset_t i = 0; i < builder.GetSize(); i++) + printf("%d ", p[i]); + #endif + + // return the buffer for the caller to use. + return std::string(reinterpret_cast<const char *>(builder.GetBufferPointer()), + builder.GetSize()); +} + +// example of accessing a buffer loaded in memory: +void AccessFlatBufferTest(const std::string &flatbuf) { + + auto monster = GetMonster(flatbuf.c_str()); + + TEST_EQ(monster->hp(), 80); + TEST_EQ(monster->mana(), 150); // default + TEST_EQ(strcmp(monster->name()->c_str(), "MyMonster"), 0); + // Can't access the following field, it is deprecated in the schema, + // which means accessors are not generated: + // monster.friendly() + + auto pos = monster->pos(); + TEST_NOTNULL(pos); + TEST_EQ(pos->z(), 3); + TEST_EQ(pos->test3().a(), 10); + TEST_EQ(pos->test3().b(), 20); + + auto inventory = monster->inventory(); + TEST_NOTNULL(inventory); + unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + for (flatbuffers::uoffset_t i = 0; i < inventory->Length(); i++) + TEST_EQ(inventory->Get(i), inv_data[i]); + + // Example of accessing a union: + TEST_EQ(monster->test_type(), Any_Monster); // First make sure which it is. + auto monster2 = reinterpret_cast<const Monster *>(monster->test()); + TEST_NOTNULL(monster2); + TEST_EQ(monster2->hp(), 20); + + // Since Flatbuffers uses explicit mechanisms to override the default + // compiler alignment, double check that the compiler indeed obeys them: + // (Test consists of a short and byte): + TEST_EQ(flatbuffers::AlignOf<Test>(), static_cast<size_t>(2)); + TEST_EQ(sizeof(Test), static_cast<size_t>(4)); + + auto tests = monster->test4(); + TEST_NOTNULL(tests); + auto &test_0 = tests->Get(0); + auto &test_1 = tests->Get(1); + TEST_EQ(test_0.a(), 10); + TEST_EQ(test_0.b(), 20); + TEST_EQ(test_1.a(), 30); + TEST_EQ(test_1.b(), 40); +} + +// example of parsing text straight into a buffer, and generating +// text back from it: +void ParseAndGenerateTextTest() { + + // load FlatBuffer schema (.fbs) and JSON from disk + std::string schemafile; + std::string jsonfile; + TEST_EQ(flatbuffers::LoadFile( + "tests/monster_test.fbs", false, &schemafile), true); + TEST_EQ(flatbuffers::LoadFile( + "tests/monsterdata_test.json", false, &jsonfile), true); + + // parse schema first, so we can use it to parse the data after + flatbuffers::Parser parser; + TEST_EQ(parser.Parse(schemafile.c_str()), true); + TEST_EQ(parser.Parse(jsonfile.c_str()), true); + + // here, parser.builder_ contains a binary buffer that is the parsed data. + + // to ensure it is correct, we now generate text back from the binary, + // and compare the two: + std::string jsongen; + GenerateText(parser, parser.builder_.GetBufferPointer(), 2, &jsongen); + + if (jsongen != jsonfile) { + printf("%s----------------\n%s", jsongen.c_str(), jsonfile.c_str()); + TEST_NOTNULL(NULL); + } +} + +template<typename T> void CompareTableFieldValue(flatbuffers::Table *table, + int voffset, T val) { + T read = table->GetField(voffset, static_cast<T>(0)); + TEST_EQ(read, val); +} + +// Low level stress/fuzz test: serialize/deserialize a variety of +// different kinds of data in different combinations +void FuzzTest1() { + + // Values we're testing against: chosen to ensure no bits get chopped + // off anywhere, and also be different from eachother. + const uint8_t bool_val = true; + const int8_t char_val = -127; // 0x81 + const uint8_t uchar_val = 0xFF; + const int16_t short_val = -32222; // 0x8222; + const uint16_t ushort_val = 0xFEEE; + const int32_t int_val = 0x83333333; + const uint32_t uint_val = 0xFDDDDDDD; + const int64_t long_val = 0x8444444444444444; + const uint64_t ulong_val = 0xFCCCCCCCCCCCCCCC; + const float float_val = 3.14159f; + const double double_val = 3.14159265359; + + const int test_values_max = 11; + const int fields_per_object = 4; + const int num_fuzz_objects = 10000; // The higher, the more thorough :) + + flatbuffers::FlatBufferBuilder builder; + + lcg_reset(); // Keep it deterministic. + + flatbuffers::uoffset_t objects[num_fuzz_objects]; + + // Generate num_fuzz_objects random objects each consisting of + // fields_per_object fields, each of a random type. + for (int i = 0; i < num_fuzz_objects; i++) { + auto start = builder.StartTable(); + for (int f = 0; f < fields_per_object; f++) { + int choice = lcg_rand() % test_values_max; + flatbuffers::voffset_t off = flatbuffers::FieldIndexToOffset(f); + switch (choice) { + case 0: builder.AddElement<uint8_t >(off, bool_val, 0); break; + case 1: builder.AddElement<int8_t >(off, char_val, 0); break; + case 2: builder.AddElement<uint8_t >(off, uchar_val, 0); break; + case 3: builder.AddElement<int16_t >(off, short_val, 0); break; + case 4: builder.AddElement<uint16_t>(off, ushort_val, 0); break; + case 5: builder.AddElement<int32_t >(off, int_val, 0); break; + case 6: builder.AddElement<uint32_t>(off, uint_val, 0); break; + case 7: builder.AddElement<int64_t >(off, long_val, 0); break; + case 8: builder.AddElement<uint64_t>(off, ulong_val, 0); break; + case 9: builder.AddElement<float >(off, float_val, 0); break; + case 10: builder.AddElement<double >(off, double_val, 0); break; + } + } + objects[i] = builder.EndTable(start, fields_per_object); + } + builder.PreAlign<flatbuffers::largest_scalar_t>(0); // Align whole buffer. + + lcg_reset(); // Reset. + + uint8_t *eob = builder.GetBufferPointer() + builder.GetSize(); + + // Test that all objects we generated are readable and return the + // expected values. We generate random objects in the same order + // so this is deterministic. + for (int i = 0; i < num_fuzz_objects; i++) { + auto table = reinterpret_cast<flatbuffers::Table *>(eob - objects[i]); + for (int f = 0; f < fields_per_object; f++) { + int choice = lcg_rand() % test_values_max; + flatbuffers::voffset_t off = flatbuffers::FieldIndexToOffset(f); + switch (choice) { + case 0: CompareTableFieldValue(table, off, bool_val ); break; + case 1: CompareTableFieldValue(table, off, char_val ); break; + case 2: CompareTableFieldValue(table, off, uchar_val ); break; + case 3: CompareTableFieldValue(table, off, short_val ); break; + case 4: CompareTableFieldValue(table, off, ushort_val); break; + case 5: CompareTableFieldValue(table, off, int_val ); break; + case 6: CompareTableFieldValue(table, off, uint_val ); break; + case 7: CompareTableFieldValue(table, off, long_val ); break; + case 8: CompareTableFieldValue(table, off, ulong_val ); break; + case 9: CompareTableFieldValue(table, off, float_val ); break; + case 10: CompareTableFieldValue(table, off, double_val); break; + } + } + } +} + +// High level stress/fuzz test: generate a big schema and +// matching json data in random combinations, then parse both, +// generate json back from the binary, and compare with the original. +void FuzzTest2() { + lcg_reset(); // Keep it deterministic. + + const int num_definitions = 30; + const int num_struct_definitions = 5; // Subset of num_definitions. + const int fields_per_definition = 15; + const int instances_per_definition = 5; + + std::string schema = "namespace test;\n\n"; + + struct RndDef { + std::string instances[instances_per_definition]; + }; + + RndDef definitions[num_definitions]; + + // We are going to generate num_definitions, the first + // num_struct_definitions will be structs, the rest tables. For each + // generate random fields, some of which may be struct/table types + // referring to previously generated structs/tables. + // Simultanenously, we generate instances_per_definition JSON data + // definitions, which will have identical structure to the schema + // being generated. We generate multiple instances such that when creating + // hierarchy, we get some variety by picking one randomly. + for (int definition = 0; definition < num_definitions; definition++) { + // Since we're generating schema & and corresponding data in tandem, + // this convenience function adds strings to both at once. + auto AddToSchemaAndInstances = [&](const char *schema_add, + const char *instance_add) { + schema += schema_add; + for (int i = 0; i < instances_per_definition; i++) + definitions[definition].instances[i] += instance_add; + }; + // Generate a default type if we can't generate something else. + auto Dummy = [&]() { AddToSchemaAndInstances("byte", "1"); }; + + std::string definition_name = "D" + flatbuffers::NumToString(definition); + + bool is_struct = definition < num_struct_definitions; + + AddToSchemaAndInstances( + ((is_struct ? "struct " : "table ") + definition_name + " {\n").c_str(), + "{\n"); + + for (int field = 0; field < fields_per_definition; field++) { + std::string field_name = "f" + flatbuffers::NumToString(field); + AddToSchemaAndInstances((" " + field_name + ":").c_str(), + (field_name + ": ").c_str()); + // Pick random type: + int base_type = lcg_rand() % (flatbuffers::BASE_TYPE_UNION + 1); + switch (base_type) { + case flatbuffers::BASE_TYPE_STRING: + if (is_struct) { + Dummy(); // No strings in structs, + } else { + AddToSchemaAndInstances("string", "\"hi\""); + } + break; + case flatbuffers::BASE_TYPE_NONE: + case flatbuffers::BASE_TYPE_UTYPE: + case flatbuffers::BASE_TYPE_STRUCT: + case flatbuffers::BASE_TYPE_UNION: + case flatbuffers::BASE_TYPE_VECTOR: + if (definition) { + // Pick a random previous definition and random data instance of + // that definition. + int defref = lcg_rand() % definition; + int instance = lcg_rand() % instances_per_definition; + AddToSchemaAndInstances( + ("D" + flatbuffers::NumToString(defref)).c_str(), + definitions[defref].instances[instance].c_str()); + } else { + // If this is the first definition, we have no definition we can + // refer to. + Dummy(); + } + break; + default: + // All the scalar types. + AddToSchemaAndInstances( + flatbuffers::kTypeNames[base_type], + flatbuffers::NumToString(lcg_rand() % 128).c_str()); + } + AddToSchemaAndInstances( + ";\n", + field == fields_per_definition - 1 ? "\n" : ",\n"); + } + AddToSchemaAndInstances("}\n\n", "}"); + } + + schema += "root_type D" + flatbuffers::NumToString(num_definitions - 1); + schema += ";\n"; + + flatbuffers::Parser parser; + + // Will not compare against the original if we don't write defaults + parser.builder_.ForceDefaults(true); + + // Parse the schema, parse the generated data, then generate text back + // from the binary and compare against the original. + TEST_EQ(parser.Parse(schema.c_str()), true); + + const std::string &json = + definitions[num_definitions - 1].instances[0] + "\n"; + + TEST_EQ(parser.Parse(json.c_str()), true); + + std::string jsongen; + GenerateText(parser, parser.builder_.GetBufferPointer(), 0, &jsongen); + + if (jsongen != json) { + // These strings are larger than a megabyte, so we show the bytes around + // the first bytes that are different rather than the whole string. + size_t len = std::min(json.length(), jsongen.length()); + for (size_t i = 0; i < len; i++) { + if (json[i] != jsongen[i]) { + i -= std::min(static_cast<size_t>(10), i); // show some context; + size_t end = std::min(len, i + 20); + for (; i < end; i++) + printf("at %d: found \"%c\", expected \"%c\"\n", + static_cast<int>(i), jsongen[i], json[i]); + break; + } + } + TEST_NOTNULL(NULL); + } + + printf("%dk schema tested with %dk of json\n", + static_cast<int>(schema.length() / 1024), + static_cast<int>(json.length() / 1024)); +} + +// Test that parser errors are actually generated. +void TestError(const char *src, const char *error_substr) { + flatbuffers::Parser parser; + TEST_EQ(parser.Parse(src), false); // Must signal error + // Must be the error we're expecting + TEST_NOTNULL(strstr(parser.error_.c_str(), error_substr)); +} + +// Test that parsing errors occur as we'd expect. +// Also useful for coverage, making sure these paths are run. +void ErrorTest() { + // In order they appear in idl_parser.cpp + TestError("table X { Y:byte; } root_type X; { Y: 999 }", "bit field"); + TestError(".0", "floating point"); + TestError("\"\0", "illegal"); + TestError("\"\\q", "escape code"); + TestError("table ///", "documentation"); + TestError("@", "illegal"); + TestError("table 1", "expecting"); + TestError("table X { Y:[[int]]; }", "nested vector"); + TestError("union Z { X } table X { Y:[Z]; }", "vector of union"); + TestError("table X { Y:1; }", "illegal type"); + TestError("table X { Y:int; Y:int; }", "field already"); + TestError("struct X { Y:string; }", "only scalar"); + TestError("struct X { Y:int (deprecated); }", "deprecate"); + TestError("union Z { X } table X { Y:Z; } root_type X; { Y: {", + "missing type field"); + TestError("union Z { X } table X { Y:Z; } root_type X; { Y_type: 99, Y: {", + "type id"); + TestError("table X { Y:int; } root_type X; { Z:", "unknown field"); + TestError("struct X { Y:int; Z:int; } table W { V:X; } root_type W; " + "{ V:{ Y:1 } }", "incomplete"); + TestError("table X { Y:byte; } root_type X; { Y:U }", "valid enum"); + TestError("table X { Y:byte; } root_type X; { Y:; }", "starting"); + TestError("enum X:byte { Y } enum X {", "enum already"); + TestError("enum X:float {}", "underlying"); + TestError("enum X:byte { Y, Y }", "value already"); + TestError("enum X:byte { Y=2, Z=1 }", "ascending"); + TestError("table X { Y:int; } table X {", "datatype already"); + TestError("struct X (force_align: 7) { Y:int; }", "force_align"); + TestError("{}", "no root"); + TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "one json"); + TestError("root_type X;", "unknown root"); + TestError("struct X { Y:int; } root_type X;", "a table"); + TestError("union X { Y }", "referenced"); + TestError("union Z { X } struct X { Y:int; }", "only tables"); +} + +int main(int argc, const char *argv[]) { + // Run our various test suites: + + auto flatbuf = CreateFlatBufferTest(); + AccessFlatBufferTest(flatbuf); + + #ifndef __ANDROID__ // requires file access + ParseAndGenerateTextTest(); + #endif + + FuzzTest1(); + FuzzTest2(); + + ErrorTest(); + + if (!testing_fails) { + TEST_OUTPUT_LINE("ALL TESTS PASSED"); + return 0; + } else { + TEST_OUTPUT_LINE("%d FAILED TESTS", testing_fails); + return 1; + } +} + |