forked from vesoft-inc/fbthrift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
150 lines (118 loc) · 3.59 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// @generated by Thrift for [[[ program path ]]]
// This file is probably not the place you want to edit!
package matching_names // [[[ program thrift source path ]]]
import (
"fmt"
includesAlso "IncludesAlso"
"github.com/facebook/fbthrift/thrift/lib/go/thrift"
)
var _ = includesAlso.GoUnusedProtection__
// (needed to ensure safety because of naive import list construction)
var _ = fmt.Printf
var _ = thrift.ZERO
type IncludesAlso struct {
Also *includesAlso.Also `thrift:"also,1" json:"also" db:"also"`
}
// Compile time interface enforcer
var _ thrift.Struct = &IncludesAlso{}
func NewIncludesAlso() *IncludesAlso {
return (&IncludesAlso{})
}
func (x *IncludesAlso) GetAlso() *includesAlso.Also {
return x.Also
}
func (x *IncludesAlso) SetAlso(value includesAlso.Also) *IncludesAlso {
x.Also = &value
return x
}
func (x *IncludesAlso) IsSetAlso() bool {
return x.Also != nil
}
func (x *IncludesAlso) writeField1(p thrift.Protocol) error { // Also
if !x.IsSetAlso() {
return nil
}
if err := p.WriteFieldBegin("also", thrift.STRUCT, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err)
}
item := *x.GetAlso()
if err := item.Write(p); err != nil {
return err
}
if err := p.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err)
}
return nil
}
func (x *IncludesAlso) readField1(p thrift.Protocol) error { // Also
result := *includesAlso.NewAlso()
err := result.Read(p)
if err != nil {
return err
}
x.SetAlso(result)
return nil
}
// Deprecated: Use IncludesAlso.Set* methods instead or set the fields directly.
type IncludesAlsoBuilder struct {
obj *IncludesAlso
}
func NewIncludesAlsoBuilder() *IncludesAlsoBuilder {
return &IncludesAlsoBuilder{
obj: NewIncludesAlso(),
}
}
func (x *IncludesAlsoBuilder) Also(value *includesAlso.Also) *IncludesAlsoBuilder {
x.obj.Also = value
return x
}
func (x *IncludesAlsoBuilder) Emit() *IncludesAlso {
var objCopy IncludesAlso = *x.obj
return &objCopy
}
func (x *IncludesAlso) Write(p thrift.Protocol) error {
if err := p.WriteStructBegin("IncludesAlso"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", x), err)
}
if err := x.writeField1(p); err != nil {
return err
}
if err := p.WriteFieldStop(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", x), err)
}
if err := p.WriteStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", x), err)
}
return nil
}
func (x *IncludesAlso) Read(p thrift.Protocol) error {
if _, err := p.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", x), err)
}
for {
_, typ, id, err := p.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", x, id), err)
}
if typ == thrift.STOP {
break;
}
switch id {
case 1: // also
if err := x.readField1(p); err != nil {
return err
}
default:
if err := p.Skip(typ); err != nil {
return err
}
}
if err := p.ReadFieldEnd(); err != nil {
return err
}
}
if err := p.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", x), err)
}
return nil
}