Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 1 | import Foundation |
2 | |||||
3 | public struct Struct { | ||||
4 | public private(set) var bb: ByteBuffer | ||||
5 | public private(set) var postion: Int32 | ||||
6 | |||||
7 | public init(bb: ByteBuffer, position: Int32 = 0) { | ||||
8 | self.bb = bb | ||||
9 | self.postion = position | ||||
10 | } | ||||
11 | |||||
12 | public func readBuffer<T: Scalar>(of type: T.Type, at o: Int32) -> T { | ||||
13 | let r = bb.read(def: T.self, position: Int(o + postion)) | ||||
14 | return r | ||||
15 | } | ||||
16 | } |