// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { HttpRow } from './http-row.js';


export class HttpResultSet {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):HttpResultSet {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsHttpResultSet(bb:flatbuffers.ByteBuffer, obj?:HttpResultSet):HttpResultSet {
  return (obj || new HttpResultSet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsHttpResultSet(bb:flatbuffers.ByteBuffer, obj?:HttpResultSet):HttpResultSet {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new HttpResultSet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

columns(index: number):string
columns(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
columns(index: number,optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
}

columnsLength():number {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

rows(index: number, obj?:HttpRow):HttpRow|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? (obj || new HttpRow()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}

rowsLength():number {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

static startHttpResultSet(builder:flatbuffers.Builder) {
  builder.startObject(2);
}

static addColumns(builder:flatbuffers.Builder, columnsOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, columnsOffset, 0);
}

static createColumnsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
  builder.startVector(4, data.length, 4);
  for (let i = data.length - 1; i >= 0; i--) {
    builder.addOffset(data[i]!);
  }
  return builder.endVector();
}

static startColumnsVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addRows(builder:flatbuffers.Builder, rowsOffset:flatbuffers.Offset) {
  builder.addFieldOffset(1, rowsOffset, 0);
}

static createRowsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
  builder.startVector(4, data.length, 4);
  for (let i = data.length - 1; i >= 0; i--) {
    builder.addOffset(data[i]!);
  }
  return builder.endVector();
}

static startRowsVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static endHttpResultSet(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static createHttpResultSet(builder:flatbuffers.Builder, columnsOffset:flatbuffers.Offset, rowsOffset:flatbuffers.Offset):flatbuffers.Offset {
  HttpResultSet.startHttpResultSet(builder);
  HttpResultSet.addColumns(builder, columnsOffset);
  HttpResultSet.addRows(builder, rowsOffset);
  return HttpResultSet.endHttpResultSet(builder);
}
}
