File: reading_bytebuffer.tutorial

package info (click to toggle)
flatbuffers 2.0.8%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,308 kB
  • sloc: cpp: 44,808; python: 6,544; cs: 4,852; java: 4,389; ansic: 1,615; php: 1,455; xml: 973; javascript: 938; sh: 806; makefile: 35
file content (27 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@Tutorial(time: 2) {
  @Intro(title: "Reading ByteBuffers") {
    After getting our ByteBuffer created, we can now read it.
    }
    
    @Section(title: "Reading your first buffer") {
      @ContentAndMedia {}
      @Steps {
        @Step {
          After fetching the data from disk or network you need to access that data, and that can be done.
          By simply calling `getCheckedRoot`, which checks if the data is valid before enabling you to read from a corrupt buffer.
          however, if you are sure that the data is 100% correct you can simply call `getRoot`
          @Code(name: "ViewController.swift", file: "swift_code_11.swift")
        }
        @Step {
          Now since we have a Monster object, all the fields can be accessed by simply fetching the data. Note, Deprecated fields will not
          show up
          @Code(name: "ViewController.swift", file: "swift_code_12.swift")
        }
        @Step {
          And you can access union types as easy as this
          @Code(name: "ViewController.swift", file: "swift_code_13.swift")
        }
      }
    }
  }