本文整理匯總了Golang中mojo/public/go/bindings.Decoder.StartMap方法的典型用法代碼示例。如果您正苦於以下問題:Golang Decoder.StartMap方法的具體用法?Golang Decoder.StartMap怎麽用?Golang Decoder.StartMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mojo/public/go/bindings.Decoder
的用法示例。
在下文中一共展示了Decoder.StartMap方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Decode
func (s *MojomFileGraph) Decode(decoder *bindings.Decoder) error {
header, err := decoder.StartStruct()
if err != nil {
return err
}
index := sort.Search(len(mojomFileGraph_Versions), func(i int) bool {
return mojomFileGraph_Versions[i].ElementsOrVersion >= header.ElementsOrVersion
})
if index < len(mojomFileGraph_Versions) {
if mojomFileGraph_Versions[index].ElementsOrVersion > header.ElementsOrVersion {
index--
}
expectedSize := mojomFileGraph_Versions[index].Size
if expectedSize != header.Size {
return &bindings.ValidationError{bindings.UnexpectedStructHeader,
fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size),
}
}
}
if header.ElementsOrVersion >= 0 {
pointer0, err := decoder.ReadPointer()
if err != nil {
return err
}
if pointer0 == 0 {
return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"}
} else {
if err := decoder.StartMap(); err != nil {
return err
}
var keys0 []string
{
pointer1, err := decoder.ReadPointer()
if err != nil {
return err
}
if pointer1 == 0 {
return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"}
} else {
len1, err := decoder.StartArray(64)
if err != nil {
return err
}
keys0 = make([]string, len1)
for i1 := uint32(0); i1 < len1; i1++ {
pointer2, err := decoder.ReadPointer()
if err != nil {
return err
}
if pointer2 == 0 {
return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"}
} else {
value2, err := decoder.ReadString()
if err != nil {
return err
}
keys0[i1] = value2
}
}
if err := decoder.Finish(); err != nil {
return err
}
}
}
var values0 []MojomFile
{
pointer1, err := decoder.ReadPointer()
if err != nil {
return err
}
if pointer1 == 0 {
return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"}
} else {
len1, err := decoder.StartArray(64)
if err != nil {
return err
}
values0 = make([]MojomFile, len1)
for i1 := uint32(0); i1 < len1; i1++ {
pointer2, err := decoder.ReadPointer()
if err != nil {
return err
}
if pointer2 == 0 {
return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"}
} else {
if err := values0[i1].Decode(decoder); err != nil {
return err
}
}
}
if err := decoder.Finish(); err != nil {
return err
}
}
}
if len(keys0) != len(values0) {
return &bindings.ValidationError{bindings.DifferentSizedArraysInMap,
fmt.Sprintf("Number of keys %d is different from number of values %d", len(keys0), len(values0)),
}
//.........這裏部分代碼省略.........