// Code generated by the FlatBuffers compiler. DO NOT EDIT.

package reflection

import (
	"bytes"
	flatbuffers "github.com/google/flatbuffers/go"
)

/// File specific information.
/// Symbols declared within a file may be recovered by iterating over all
/// symbols and examining the `declaration_file` field.
type SchemaFile struct {
	_tab flatbuffers.Table
}

func GetRootAsSchemaFile(buf []byte, offset flatbuffers.UOffsetT) *SchemaFile {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &SchemaFile{}
	x.Init(buf, n+offset)
	return x
}

func FinishSchemaFileBuffer(builder *flatbuffers.Builder, offset flatbuffers.UOffsetT) {
	builder.Finish(offset)
}

func GetSizePrefixedRootAsSchemaFile(buf []byte, offset flatbuffers.UOffsetT) *SchemaFile {
	n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
	x := &SchemaFile{}
	x.Init(buf, n+offset+flatbuffers.SizeUint32)
	return x
}

func FinishSizePrefixedSchemaFileBuffer(builder *flatbuffers.Builder, offset flatbuffers.UOffsetT) {
	builder.FinishSizePrefixed(offset)
}

func (rcv *SchemaFile) Init(buf []byte, i flatbuffers.UOffsetT) {
	rcv._tab.Bytes = buf
	rcv._tab.Pos = i
}

func (rcv *SchemaFile) Table() flatbuffers.Table {
	return rcv._tab
}

/// Filename, relative to project root.
func (rcv *SchemaFile) Filename() []byte {
	o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
	if o != 0 {
		return rcv._tab.ByteVector(o + rcv._tab.Pos)
	}
	return nil
}

/// Filename, relative to project root.
func SchemaFileKeyCompare(o1, o2 flatbuffers.UOffsetT, buf []byte) bool {
	obj1 := &SchemaFile{}
	obj2 := &SchemaFile{}
	obj1.Init(buf, flatbuffers.UOffsetT(len(buf))-o1)
	obj2.Init(buf, flatbuffers.UOffsetT(len(buf))-o2)
	return string(obj1.Filename()) < string(obj2.Filename())
}

func (rcv *SchemaFile) LookupByKey(key string, vectorLocation flatbuffers.UOffsetT, buf []byte) bool {
	span := flatbuffers.GetUOffsetT(buf[vectorLocation-4:])
	start := flatbuffers.UOffsetT(0)
	bKey := []byte(key)
	for span != 0 {
		middle := span / 2
		tableOffset := flatbuffers.GetIndirectOffset(buf, vectorLocation+4*(start+middle))
		obj := &SchemaFile{}
		obj.Init(buf, tableOffset)
		comp := bytes.Compare(obj.Filename(), bKey)
		if comp > 0 {
			span = middle
		} else if comp < 0 {
			middle += 1
			start += middle
			span -= middle
		} else {
			rcv.Init(buf, tableOffset)
			return true
		}
	}
	return false
}

/// Names of included files, relative to project root.
func (rcv *SchemaFile) IncludedFilenames(j int) []byte {
	o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
	if o != 0 {
		a := rcv._tab.Vector(o)
		return rcv._tab.ByteVector(a + flatbuffers.UOffsetT(j*4))
	}
	return nil
}

func (rcv *SchemaFile) IncludedFilenamesLength() int {
	o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
	if o != 0 {
		return rcv._tab.VectorLen(o)
	}
	return 0
}

/// Names of included files, relative to project root.
func SchemaFileStart(builder *flatbuffers.Builder) {
	builder.StartObject(2)
}
func SchemaFileAddFilename(builder *flatbuffers.Builder, filename flatbuffers.UOffsetT) {
	builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(filename), 0)
}
func SchemaFileAddIncludedFilenames(builder *flatbuffers.Builder, includedFilenames flatbuffers.UOffsetT) {
	builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(includedFilenames), 0)
}
func SchemaFileStartIncludedFilenamesVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
	return builder.StartVector(4, numElems, 4)
}
func SchemaFileEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
	return builder.EndObject()
}
