Files
flatbuffers/tests/MyGame/Example/StructOfStructsOfStructs.go
Andrei Burdulescu c793621567 [golang] Add support for text parsing with json struct tags (#7353)
* [golang] Add support for text parsing with json struct tags

Add struct tags to Go native structs generated when object API is used.

This allows to use the same JSON file as for C++ text
parsing(i.e. snake_case vs CamelCase) and thus enabling text parsing
for Go(when using object API).

* [golang] Add test for text parsing

Added small test to check and demonstrate text parsing in Go.
Also, ran clang-format on cpp file changes.
2022-08-08 11:30:06 -07:00

64 lines
1.7 KiB
Go

// Code generated by the FlatBuffers compiler. DO NOT EDIT.
package Example
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type StructOfStructsOfStructsT struct {
A *StructOfStructsT `json:"a"`
}
func (t *StructOfStructsOfStructsT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
return CreateStructOfStructsOfStructs(builder, t.A.A.Id, t.A.A.Distance, t.A.B.A, t.A.B.B, t.A.C.Id, t.A.C.Distance)
}
func (rcv *StructOfStructsOfStructs) UnPackTo(t *StructOfStructsOfStructsT) {
t.A = rcv.A(nil).UnPack()
}
func (rcv *StructOfStructsOfStructs) UnPack() *StructOfStructsOfStructsT {
if rcv == nil { return nil }
t := &StructOfStructsOfStructsT{}
rcv.UnPackTo(t)
return t
}
type StructOfStructsOfStructs struct {
_tab flatbuffers.Struct
}
func (rcv *StructOfStructsOfStructs) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
}
func (rcv *StructOfStructsOfStructs) Table() flatbuffers.Table {
return rcv._tab.Table
}
func (rcv *StructOfStructsOfStructs) A(obj *StructOfStructs) *StructOfStructs {
if obj == nil {
obj = new(StructOfStructs)
}
obj.Init(rcv._tab.Bytes, rcv._tab.Pos+0)
return obj
}
func CreateStructOfStructsOfStructs(builder *flatbuffers.Builder, a_a_id uint32, a_a_distance uint32, a_b_a int16, a_b_b int8, a_c_id uint32, a_c_distance uint32) flatbuffers.UOffsetT {
builder.Prep(4, 20)
builder.Prep(4, 20)
builder.Prep(4, 8)
builder.PrependUint32(a_c_distance)
builder.PrependUint32(a_c_id)
builder.Prep(2, 4)
builder.Pad(1)
builder.PrependInt8(a_b_b)
builder.PrependInt16(a_b_a)
builder.Prep(4, 8)
builder.PrependUint32(a_a_distance)
builder.PrependUint32(a_a_id)
return builder.Offset()
}