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


Golang go.Builder類代碼示例

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


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

示例1: 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

示例2: 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

示例3: serializeUsingFlatBuffers

func serializeUsingFlatBuffers(builder *flatbuffers.Builder, a *A) []byte {
	builder.Reset()

	name := builder.CreateString(a.Name)
	phone := builder.CreateString(a.Phone)

	FlatBufferAStart(builder)
	FlatBufferAAddName(builder, name)
	FlatBufferAAddPhone(builder, phone)
	FlatBufferAAddBirthDay(builder, a.BirthDay.Unix())
	FlatBufferAAddSiblings(builder, int32(a.Siblings))
	var spouse byte
	if a.Spouse {
		spouse = byte(1)
	}
	FlatBufferAAddSpouse(builder, spouse)
	FlatBufferAAddMoney(builder, a.Money)
	builder.Finish(FlatBufferAEnd(builder))
	return builder.Bytes[builder.Head():]
}
開發者ID:junchaowu,項目名稱:go_serialization_benchmarks,代碼行數:20,代碼來源:serialization_benchmarks_test.go

示例4: MakeMonster

func MakeMonster(builder *flatbuffers.Builder) []byte {
	builder.Reset()

	name := []byte("One Sample Monster")
	name_position := builder.CreateByteString(name)

	example.MonsterStart(builder)
	example.MonsterAddPos(builder, example.CreateVec3(builder, 1.0, 2.0, 3.0))
	example.MonsterAddHp(builder, 80)
	example.MonsterAddName(builder, name_position)

	monster_position := example.MonsterEnd(builder)

	builder.Finish(monster_position)

	return builder.Bytes[builder.Head():]
}
開發者ID:jforns,項目名稱:flatbuffers-monster-sample,代碼行數:17,代碼來源:monster.go

示例5: MakeUser

// main.go part 2 of 4
func MakeUser(b *flatbuffers.Builder, name []byte, id uint64) []byte {
	// re-use the already-allocated Builder:
	b.Reset()

	// create the name object and get its offset:
	name_position := b.CreateByteString(name)

	// write the User object:
	users.UserStart(b)
	users.UserAddName(b, name_position)
	users.UserAddId(b, id)
	user_position := users.UserEnd(b)

	// finish the write operations by our User the root object:
	b.Finish(user_position)

	// return the byte slice containing encoded data:
	return b.Bytes[b.Head():]
}
開發者ID:rw,項目名稱:go-flatbuffers-example,代碼行數:20,代碼來源:main.go

示例6: StatAddCount

func StatAddCount(builder *flatbuffers.Builder, count uint16)   { builder.PrependUint16Slot(2, count, 0) }
開發者ID:mystal,項目名稱:flatbuffers,代碼行數:1,代碼來源:Stat.go

示例7: StatAddId

func StatAddId(builder *flatbuffers.Builder, id flatbuffers.UOffsetT) {
	builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(id), 0)
}
開發者ID:mystal,項目名稱:flatbuffers,代碼行數:3,代碼來源:Stat.go

示例8: MonsterEnd

func MonsterEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
開發者ID:BlueBrain,項目名稱:flatbuffers,代碼行數:1,代碼來源:Monster.go

示例9: MonsterStartTestnestedflatbufferVector

func MonsterStartTestnestedflatbufferVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
	return builder.StartVector(1, numElems, 1)
}
開發者ID:BlueBrain,項目名稱:flatbuffers,代碼行數:3,代碼來源:Monster.go

示例10: MonsterAddEnemy

func MonsterAddEnemy(builder *flatbuffers.Builder, enemy flatbuffers.UOffsetT) {
	builder.PrependUOffsetTSlot(12, flatbuffers.UOffsetT(enemy), 0)
}
開發者ID:BlueBrain,項目名稱:flatbuffers,代碼行數:3,代碼來源:Monster.go

示例11: MonsterAddTestarrayoftables

func MonsterAddTestarrayoftables(builder *flatbuffers.Builder, testarrayoftables flatbuffers.UOffsetT) {
	builder.PrependUOffsetTSlot(11, flatbuffers.UOffsetT(testarrayoftables), 0)
}
開發者ID:BlueBrain,項目名稱:flatbuffers,代碼行數:3,代碼來源:Monster.go

示例12: MonsterAddMana

func MonsterAddMana(builder *flatbuffers.Builder, mana int16) { builder.PrependInt16Slot(1, mana, 150) }
開發者ID:BlueBrain,項目名稱:flatbuffers,代碼行數:1,代碼來源:Monster.go

示例13: MonsterAddPos

func MonsterAddPos(builder *flatbuffers.Builder, pos flatbuffers.UOffsetT) {
	builder.PrependStructSlot(0, flatbuffers.UOffsetT(pos), 0)
}
開發者ID:BlueBrain,項目名稱:flatbuffers,代碼行數:3,代碼來源:Monster.go

示例14: MonsterStart

func MonsterStart(builder *flatbuffers.Builder) { builder.StartObject(15) }
開發者ID:BlueBrain,項目名稱:flatbuffers,代碼行數:1,代碼來源:Monster.go

示例15: PostingEnd

func PostingEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:1,代碼來源:Posting.go


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