Add byte slice accessor to Go code

Change-Id: I15cc8924d6607bd93068c762fd67e6088cfd9789
This commit is contained in:
Ben Harper
2015-04-01 16:39:53 +02:00
committed by Wouter van Oortmerssen
parent c4a3e2f6bd
commit 8b99bf614c
4 changed files with 48 additions and 1 deletions

View File

@@ -26,10 +26,15 @@ func (t *Table) Indirect(off UOffsetT) UOffsetT {
// String gets a string from data stored inside the flatbuffer.
func (t *Table) String(off UOffsetT) string {
return string(t.ByteVector(off))
}
// ByteVector gets a byte slice from data stored inside the flatbuffer.
func (t *Table) ByteVector(off UOffsetT) []byte {
off += GetUOffsetT(t.Bytes[off:])
start := off + UOffsetT(SizeUOffsetT)
length := GetUOffsetT(t.Bytes[off:])
return string(t.Bytes[start : start+length])
return t.Bytes[start : start+length]
}
// VectorLen retrieves the length of the vector whose offset is stored at