James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame^] | 1 | // Copyright 2021 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | |
| 16 | // trying to represent a typical mix of datatypes: |
| 17 | // 1 array of 3 elements, each element: 1 string, 3 nested objects, 9 scalars |
| 18 | // root element has the array, additional string and an enum |
| 19 | |
| 20 | namespace benchmarks_flatbuffers; |
| 21 | |
| 22 | enum Enum : short { Apples, Pears, Bananas} |
| 23 | |
| 24 | struct Foo { |
| 25 | id:ulong; |
| 26 | count:short; |
| 27 | prefix:byte; |
| 28 | length:uint; |
| 29 | } |
| 30 | |
| 31 | struct Bar { |
| 32 | parent:Foo; |
| 33 | time:int; |
| 34 | ratio:float; |
| 35 | size:ushort; |
| 36 | } |
| 37 | |
| 38 | table FooBar { |
| 39 | sibling:Bar; |
| 40 | name:string; |
| 41 | rating:double; |
| 42 | postfix:ubyte; |
| 43 | } |
| 44 | |
| 45 | table FooBarContainer { |
| 46 | list:[FooBar]; // 3 copies of the above |
| 47 | initialized:bool; |
| 48 | fruit:Enum; |
| 49 | location:string; |
| 50 | } |
| 51 | |
| 52 | root_type FooBarContainer; |