// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable

library namespace_c;

import 'dart:typed_data' show Uint8List;
import 'package:flat_buffers/flat_buffers.dart' as fb;

import './namespace_test2_namespace_a_generated.dart' as namespace_a;

class TableInC {
  TableInC._(this._bc, this._bcOffset);
  factory TableInC(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<TableInC> reader = _TableInCReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  namespace_a.TableInFirstNS? get referToA1 => namespace_a.TableInFirstNS.reader.vTableGetNullable(_bc, _bcOffset, 4);
  namespace_a.SecondTableInA? get referToA2 => namespace_a.SecondTableInA.reader.vTableGetNullable(_bc, _bcOffset, 6);

  @override
  String toString() {
    return 'TableInC{referToA1: $referToA1, referToA2: $referToA2}';
  }

  TableInCT unpack() => TableInCT(
      referToA1: referToA1?.unpack(),
      referToA2: referToA2?.unpack());

  static int pack(fb.Builder fbBuilder, TableInCT? object) {
    if (object == null) return 0;
    return object.pack(fbBuilder);
  }
}

class TableInCT implements fb.Packable {
  namespace_a.TableInFirstNST? referToA1;
  namespace_a.SecondTableInAT? referToA2;

  TableInCT({
      this.referToA1,
      this.referToA2});

  @override
  int pack(fb.Builder fbBuilder) {
    final int? referToA1Offset = referToA1?.pack(fbBuilder);
    final int? referToA2Offset = referToA2?.pack(fbBuilder);
    fbBuilder.startTable(2);
    fbBuilder.addOffset(0, referToA1Offset);
    fbBuilder.addOffset(1, referToA2Offset);
    return fbBuilder.endTable();
  }

  @override
  String toString() {
    return 'TableInCT{referToA1: $referToA1, referToA2: $referToA2}';
  }
}

class _TableInCReader extends fb.TableReader<TableInC> {
  const _TableInCReader();

  @override
  TableInC createObject(fb.BufferContext bc, int offset) => 
    TableInC._(bc, offset);
}

class TableInCBuilder {
  TableInCBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(2);
  }

  int addReferToA1Offset(int? offset) {
    fbBuilder.addOffset(0, offset);
    return fbBuilder.offset;
  }
  int addReferToA2Offset(int? offset) {
    fbBuilder.addOffset(1, offset);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class TableInCObjectBuilder extends fb.ObjectBuilder {
  final namespace_a.TableInFirstNSObjectBuilder? _referToA1;
  final namespace_a.SecondTableInAObjectBuilder? _referToA2;

  TableInCObjectBuilder({
    namespace_a.TableInFirstNSObjectBuilder? referToA1,
    namespace_a.SecondTableInAObjectBuilder? referToA2,
  })
      : _referToA1 = referToA1,
        _referToA2 = referToA2;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? referToA1Offset = _referToA1?.getOrCreateOffset(fbBuilder);
    final int? referToA2Offset = _referToA2?.getOrCreateOffset(fbBuilder);
    fbBuilder.startTable(2);
    fbBuilder.addOffset(0, referToA1Offset);
    fbBuilder.addOffset(1, referToA2Offset);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}
