Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 1 | import Foundation |
| 2 | |
| 3 | public final class FlatBuffersUtils { |
| 4 | |
| 5 | /// Gets the size of the prefix |
| 6 | /// - Parameter bb: Flatbuffer object |
| 7 | public static func getSizePrefix(bb: ByteBuffer) -> Int32 { |
| 8 | return bb.read(def: Int32.self, position: bb.reader) |
| 9 | } |
| 10 | |
| 11 | /// Removes the prefix by duplicating the Flatbuffer |
| 12 | /// - Parameter bb: Flatbuffer object |
| 13 | public static func removeSizePrefix(bb: ByteBuffer) -> ByteBuffer { |
| 14 | return bb.duplicate(removing: MemoryLayout<Int32>.size) |
| 15 | } |
| 16 | } |