// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all

import FlatBuffers

public struct zzz_DflatGen_PaintColor: FlatBufferObject, Verifiable {

  static func validateVersion() { FlatBuffersVersion_22_9_29() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table

  public static func getRootAsPaintColor(bb: ByteBuffer) -> zzz_DflatGen_PaintColor {
    return zzz_DflatGen_PaintColor(
      Table(
        bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))
    )
  }

  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }

  private enum VTOFFSET: VOffset {
    case index = 4
    case r = 6
    case g = 8
    case b = 10
    case a = 12
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var index: Int64 {
    let o = _accessor.offset(VTOFFSET.index.v)
    return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o)
  }
  public var r: Float32 {
    let o = _accessor.offset(VTOFFSET.r.v)
    return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o)
  }
  public var g: Float32 {
    let o = _accessor.offset(VTOFFSET.g.v)
    return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o)
  }
  public var b: Float32 {
    let o = _accessor.offset(VTOFFSET.b.v)
    return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o)
  }
  public var a: Float32 {
    let o = _accessor.offset(VTOFFSET.a.v)
    return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o)
  }
  public static func startPaintColor(_ fbb: inout FlatBufferBuilder) -> UOffset {
    fbb.startTable(with: 5)
  }
  public static func add(index: Int64, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: index, def: 0, at: VTOFFSET.index.p)
  }
  public static func add(r: Float32, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: r, def: 0.0, at: VTOFFSET.r.p)
  }
  public static func add(g: Float32, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: g, def: 0.0, at: VTOFFSET.g.p)
  }
  public static func add(b: Float32, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: b, def: 0.0, at: VTOFFSET.b.p)
  }
  public static func add(a: Float32, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: a, def: 0.0, at: VTOFFSET.a.p)
  }
  public static func endPaintColor(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset {
    let end = Offset(offset: fbb.endTable(at: start))
    return end
  }
  public static func createPaintColor(
    _ fbb: inout FlatBufferBuilder,
    index: Int64 = 0,
    r: Float32 = 0.0,
    g: Float32 = 0.0,
    b: Float32 = 0.0,
    a: Float32 = 0.0
  ) -> Offset {
    let __start = zzz_DflatGen_PaintColor.startPaintColor(&fbb)
    zzz_DflatGen_PaintColor.add(index: index, &fbb)
    zzz_DflatGen_PaintColor.add(r: r, &fbb)
    zzz_DflatGen_PaintColor.add(g: g, &fbb)
    zzz_DflatGen_PaintColor.add(b: b, &fbb)
    zzz_DflatGen_PaintColor.add(a: a, &fbb)
    return zzz_DflatGen_PaintColor.endPaintColor(&fbb, start: __start)
  }

  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws
  where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(field: VTOFFSET.index.p, fieldName: "index", required: false, type: Int64.self)
    try _v.visit(field: VTOFFSET.r.p, fieldName: "r", required: false, type: Float32.self)
    try _v.visit(field: VTOFFSET.g.p, fieldName: "g", required: false, type: Float32.self)
    try _v.visit(field: VTOFFSET.b.p, fieldName: "b", required: false, type: Float32.self)
    try _v.visit(field: VTOFFSET.a.p, fieldName: "a", required: false, type: Float32.self)
    _v.finish()
  }
}
