當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Builder.Offset方法代碼示例

本文整理匯總了Golang中github.com/google/flatbuffers/go.Builder.Offset方法的典型用法代碼示例。如果您正苦於以下問題:Golang Builder.Offset方法的具體用法?Golang Builder.Offset怎麽用?Golang Builder.Offset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/flatbuffers/go.Builder的用法示例。


在下文中一共展示了Builder.Offset方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CreateVec3

func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32) flatbuffers.UOffsetT {
	builder.Prep(4, 12)
	builder.PrependFloat32(z)
	builder.PrependFloat32(y)
	builder.PrependFloat32(x)
	return builder.Offset()
}
開發者ID:jforns,項目名稱:flatbuffers-monster-sample,代碼行數:7,代碼來源:Vec3.go

示例2: CreateTest

func CreateTest(builder *flatbuffers.Builder, a int16, b int8) flatbuffers.UOffsetT {
	builder.Prep(2, 4)
	builder.Pad(1)
	builder.PrependInt8(b)
	builder.PrependInt16(a)
	return builder.Offset()
}
開發者ID:google,項目名稱:flatbuffers,代碼行數:7,代碼來源:Test.go

示例3: CreateVec3

func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 int8, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
	builder.Prep(16, 32)
	builder.Pad(2)
	builder.Prep(2, 4)
	builder.Pad(1)
	builder.PrependInt8(test3_b)
	builder.PrependInt16(test3_a)
	builder.Pad(1)
	builder.PrependInt8(test2)
	builder.PrependFloat64(test1)
	builder.Pad(4)
	builder.PrependFloat32(z)
	builder.PrependFloat32(y)
	builder.PrependFloat32(x)
	return builder.Offset()
}
開發者ID:CadeLaRen,項目名稱:flatbuffers,代碼行數:16,代碼來源:Vec3.go

示例4: CreateGeoPoint

func CreateGeoPoint(builder *flatbuffers.Builder, lat int32, lon int32) flatbuffers.UOffsetT {
	builder.Prep(4, 8)
	builder.PrependInt32(lon)
	builder.PrependInt32(lat)
	return builder.Offset()
}
開發者ID:jeffallen,項目名稱:routedb,代碼行數:6,代碼來源:GeoPoint.go

示例5: CreateStructInNestedNS

func CreateStructInNestedNS(builder *flatbuffers.Builder, a int32, b int32) flatbuffers.UOffsetT {
	builder.Prep(4, 8)
	builder.PrependInt32(b)
	builder.PrependInt32(a)
	return builder.Offset()
}
開發者ID:CadeLaRen,項目名稱:flatbuffers,代碼行數:6,代碼來源:StructInNestedNS.go

示例6: CheckByteLayout


//.........這裏部分代碼省略.........
	b.EndObject()
	check([]byte{
		8, 0, // vtable bytes
		8, 0, // end of object from here
		6, 0, // offset to value 0
		4, 0, // offset to value 1
		8, 0, 0, 0, // offset for start of vtable (int32)
		0x9A, 0x78, // value 1
		0x56, 0x34, // value 0
	})

	// test 12: vtable with int16 and bool
	b = flatbuffers.NewBuilder(0)
	b.StartObject(2)
	b.PrependInt16Slot(0, 0x3456, 0)
	b.PrependBoolSlot(1, true, false)
	b.EndObject()
	check([]byte{
		8, 0, // vtable bytes
		8, 0, // end of object from here
		6, 0, // offset to value 0
		5, 0, // offset to value 1
		8, 0, 0, 0, // offset for start of vtable (int32)
		0,          // padding
		1,          // value 1
		0x56, 0x34, // value 0
	})

	// test 12: vtable with empty vector
	b = flatbuffers.NewBuilder(0)
	b.StartVector(flatbuffers.SizeByte, 0, 1)
	vecend := b.EndVector(0)
	b.StartObject(1)
	b.PrependUOffsetTSlot(0, vecend, 0)
	b.EndObject()
	check([]byte{
		6, 0, // vtable bytes
		8, 0,
		4, 0, // offset to vector offset
		6, 0, 0, 0, // offset for start of vtable (int32)
		4, 0, 0, 0,
		0, 0, 0, 0, // length of vector (not in struct)
	})

	// test 12b: vtable with empty vector of byte and some scalars
	b = flatbuffers.NewBuilder(0)
	b.StartVector(flatbuffers.SizeByte, 0, 1)
	vecend = b.EndVector(0)
	b.StartObject(2)
	b.PrependInt16Slot(0, 55, 0)
	b.PrependUOffsetTSlot(1, vecend, 0)
	b.EndObject()
	check([]byte{
		8, 0, // vtable bytes
		12, 0,
		10, 0, // offset to value 0
		4, 0, // offset to vector offset
		8, 0, 0, 0, // vtable loc
		8, 0, 0, 0, // value 1
		0, 0, 55, 0, // value 0

		0, 0, 0, 0, // length of vector (not in struct)
	})

	// test 13: vtable with 1 int16 and 2-vector of int16
	b = flatbuffers.NewBuilder(0)
開發者ID:bunnyblue,項目名稱:flatbuffers,代碼行數:67,代碼來源:go_test.go


注:本文中的github.com/google/flatbuffers/go.Builder.Offset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。