-
Notifications
You must be signed in to change notification settings - Fork 2
/
service2.addOrIncrMany.go
379 lines (349 loc) · 13.2 KB
/
service2.addOrIncrMany.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
// Copyright 2022 V Kontakte LLC
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// Code generated by vktl/cmd/tlgen2; DO NOT EDIT.
package tlService2AddOrIncrMany
import (
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal/tl/tlBuiltinTupleInt"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal/tl/tlBuiltinTupleService2CounterSet"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal/tl/tlBuiltinTupleService2DeltaSet"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal/tlservice2/tlService2CounterSet"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal/tlservice2/tlService2DeltaSet"
"github.com/vkcom/tl/pkg/basictl"
)
var _ = basictl.NatWrite
var _ = internal.ErrorInvalidEnumTag
type Service2AddOrIncrMany struct {
ObjectIdLength uint32
IntCountersNum uint32
FloatCountersNum uint32
ObjectsNum uint32
IntCounters []int32
FloatCounters []int32
Deltas []tlService2DeltaSet.Service2DeltaSet
}
func (Service2AddOrIncrMany) TLName() string { return "service2.addOrIncrMany" }
func (Service2AddOrIncrMany) TLTag() uint32 { return 0x5aa52489 }
func (item *Service2AddOrIncrMany) Reset() {
item.ObjectIdLength = 0
item.IntCountersNum = 0
item.FloatCountersNum = 0
item.ObjectsNum = 0
item.IntCounters = item.IntCounters[:0]
item.FloatCounters = item.FloatCounters[:0]
item.Deltas = item.Deltas[:0]
}
func (item *Service2AddOrIncrMany) Read(w []byte) (_ []byte, err error) {
if w, err = basictl.NatRead(w, &item.ObjectIdLength); err != nil {
return w, err
}
if w, err = basictl.NatRead(w, &item.IntCountersNum); err != nil {
return w, err
}
if w, err = basictl.NatRead(w, &item.FloatCountersNum); err != nil {
return w, err
}
if w, err = basictl.NatRead(w, &item.ObjectsNum); err != nil {
return w, err
}
if w, err = tlBuiltinTupleInt.BuiltinTupleIntRead(w, &item.IntCounters, item.IntCountersNum); err != nil {
return w, err
}
if w, err = tlBuiltinTupleInt.BuiltinTupleIntRead(w, &item.FloatCounters, item.FloatCountersNum); err != nil {
return w, err
}
return tlBuiltinTupleService2DeltaSet.BuiltinTupleService2DeltaSetRead(w, &item.Deltas, item.ObjectsNum, item.ObjectIdLength, item.IntCountersNum, item.FloatCountersNum)
}
// This method is general version of Write, use it instead!
func (item *Service2AddOrIncrMany) WriteGeneral(w []byte) (_ []byte, err error) {
return item.Write(w)
}
func (item *Service2AddOrIncrMany) Write(w []byte) (_ []byte, err error) {
w = basictl.NatWrite(w, item.ObjectIdLength)
w = basictl.NatWrite(w, item.IntCountersNum)
w = basictl.NatWrite(w, item.FloatCountersNum)
w = basictl.NatWrite(w, item.ObjectsNum)
if w, err = tlBuiltinTupleInt.BuiltinTupleIntWrite(w, item.IntCounters, item.IntCountersNum); err != nil {
return w, err
}
if w, err = tlBuiltinTupleInt.BuiltinTupleIntWrite(w, item.FloatCounters, item.FloatCountersNum); err != nil {
return w, err
}
if w, err = tlBuiltinTupleService2DeltaSet.BuiltinTupleService2DeltaSetWrite(w, item.Deltas, item.ObjectsNum, item.ObjectIdLength, item.IntCountersNum, item.FloatCountersNum); err != nil {
return w, err
}
return w, nil
}
func (item *Service2AddOrIncrMany) ReadBoxed(w []byte) (_ []byte, err error) {
if w, err = basictl.NatReadExactTag(w, 0x5aa52489); err != nil {
return w, err
}
return item.Read(w)
}
// This method is general version of WriteBoxed, use it instead!
func (item *Service2AddOrIncrMany) WriteBoxedGeneral(w []byte) (_ []byte, err error) {
return item.WriteBoxed(w)
}
func (item *Service2AddOrIncrMany) WriteBoxed(w []byte) (_ []byte, err error) {
w = basictl.NatWrite(w, 0x5aa52489)
return item.Write(w)
}
func (item *Service2AddOrIncrMany) ReadResult(w []byte, ret *[]tlService2CounterSet.Service2CounterSet) (_ []byte, err error) {
if w, err = basictl.NatReadExactTag(w, 0x9770768a); err != nil {
return w, err
}
return tlBuiltinTupleService2CounterSet.BuiltinTupleService2CounterSetRead(w, ret, item.ObjectsNum, item.IntCountersNum, item.FloatCountersNum)
}
func (item *Service2AddOrIncrMany) WriteResult(w []byte, ret []tlService2CounterSet.Service2CounterSet) (_ []byte, err error) {
w = basictl.NatWrite(w, 0x9770768a)
if w, err = tlBuiltinTupleService2CounterSet.BuiltinTupleService2CounterSetWrite(w, ret, item.ObjectsNum, item.IntCountersNum, item.FloatCountersNum); err != nil {
return w, err
}
return w, nil
}
func (item *Service2AddOrIncrMany) ReadResultJSON(legacyTypeNames bool, in *basictl.JsonLexer, ret *[]tlService2CounterSet.Service2CounterSet) error {
if err := tlBuiltinTupleService2CounterSet.BuiltinTupleService2CounterSetReadJSON(legacyTypeNames, in, ret, item.ObjectsNum, item.IntCountersNum, item.FloatCountersNum); err != nil {
return err
}
return nil
}
func (item *Service2AddOrIncrMany) WriteResultJSON(w []byte, ret []tlService2CounterSet.Service2CounterSet) (_ []byte, err error) {
return item.writeResultJSON(true, false, w, ret)
}
func (item *Service2AddOrIncrMany) writeResultJSON(newTypeNames bool, short bool, w []byte, ret []tlService2CounterSet.Service2CounterSet) (_ []byte, err error) {
if w, err = tlBuiltinTupleService2CounterSet.BuiltinTupleService2CounterSetWriteJSONOpt(newTypeNames, short, w, ret, item.ObjectsNum, item.IntCountersNum, item.FloatCountersNum); err != nil {
return w, err
}
return w, nil
}
func (item *Service2AddOrIncrMany) ReadResultWriteResultJSON(r []byte, w []byte) (_ []byte, _ []byte, err error) {
var ret []tlService2CounterSet.Service2CounterSet
if r, err = item.ReadResult(r, &ret); err != nil {
return r, w, err
}
w, err = item.WriteResultJSON(w, ret)
return r, w, err
}
func (item *Service2AddOrIncrMany) ReadResultWriteResultJSONOpt(newTypeNames bool, short bool, r []byte, w []byte) (_ []byte, _ []byte, err error) {
var ret []tlService2CounterSet.Service2CounterSet
if r, err = item.ReadResult(r, &ret); err != nil {
return r, w, err
}
w, err = item.writeResultJSON(newTypeNames, short, w, ret)
return r, w, err
}
func (item *Service2AddOrIncrMany) ReadResultJSONWriteResult(r []byte, w []byte) ([]byte, []byte, error) {
var ret []tlService2CounterSet.Service2CounterSet
err := item.ReadResultJSON(true, &basictl.JsonLexer{Data: r}, &ret)
if err != nil {
return r, w, err
}
w, err = item.WriteResult(w, ret)
return r, w, err
}
func (item Service2AddOrIncrMany) String() string {
w, err := item.WriteJSON(nil)
if err != nil {
return err.Error()
}
return string(w)
}
func (item *Service2AddOrIncrMany) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error {
var propObjectIdLengthPresented bool
var propIntCountersNumPresented bool
var propFloatCountersNumPresented bool
var propObjectsNumPresented bool
var rawIntCounters []byte
var rawFloatCounters []byte
var rawDeltas []byte
if in != nil {
in.Delim('{')
if !in.Ok() {
return in.Error()
}
for !in.IsDelim('}') {
key := in.UnsafeFieldName(true)
in.WantColon()
switch key {
case "objectIdLength":
if propObjectIdLengthPresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service2.addOrIncrMany", "objectIdLength")
}
if err := internal.Json2ReadUint32(in, &item.ObjectIdLength); err != nil {
return err
}
propObjectIdLengthPresented = true
case "intCountersNum":
if propIntCountersNumPresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service2.addOrIncrMany", "intCountersNum")
}
if err := internal.Json2ReadUint32(in, &item.IntCountersNum); err != nil {
return err
}
propIntCountersNumPresented = true
case "floatCountersNum":
if propFloatCountersNumPresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service2.addOrIncrMany", "floatCountersNum")
}
if err := internal.Json2ReadUint32(in, &item.FloatCountersNum); err != nil {
return err
}
propFloatCountersNumPresented = true
case "objectsNum":
if propObjectsNumPresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service2.addOrIncrMany", "objectsNum")
}
if err := internal.Json2ReadUint32(in, &item.ObjectsNum); err != nil {
return err
}
propObjectsNumPresented = true
case "intCounters":
if rawIntCounters != nil {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service2.addOrIncrMany", "intCounters")
}
rawIntCounters = in.Raw()
if !in.Ok() {
return in.Error()
}
case "floatCounters":
if rawFloatCounters != nil {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service2.addOrIncrMany", "floatCounters")
}
rawFloatCounters = in.Raw()
if !in.Ok() {
return in.Error()
}
case "deltas":
if rawDeltas != nil {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service2.addOrIncrMany", "deltas")
}
rawDeltas = in.Raw()
if !in.Ok() {
return in.Error()
}
default:
return internal.ErrorInvalidJSONExcessElement("service2.addOrIncrMany", key)
}
in.WantComma()
}
in.Delim('}')
if !in.Ok() {
return in.Error()
}
}
if !propObjectIdLengthPresented {
item.ObjectIdLength = 0
}
if !propIntCountersNumPresented {
item.IntCountersNum = 0
}
if !propFloatCountersNumPresented {
item.FloatCountersNum = 0
}
if !propObjectsNumPresented {
item.ObjectsNum = 0
}
var inIntCountersPointer *basictl.JsonLexer
inIntCounters := basictl.JsonLexer{Data: rawIntCounters}
if rawIntCounters != nil {
inIntCountersPointer = &inIntCounters
}
if err := tlBuiltinTupleInt.BuiltinTupleIntReadJSON(legacyTypeNames, inIntCountersPointer, &item.IntCounters, item.IntCountersNum); err != nil {
return err
}
var inFloatCountersPointer *basictl.JsonLexer
inFloatCounters := basictl.JsonLexer{Data: rawFloatCounters}
if rawFloatCounters != nil {
inFloatCountersPointer = &inFloatCounters
}
if err := tlBuiltinTupleInt.BuiltinTupleIntReadJSON(legacyTypeNames, inFloatCountersPointer, &item.FloatCounters, item.FloatCountersNum); err != nil {
return err
}
var inDeltasPointer *basictl.JsonLexer
inDeltas := basictl.JsonLexer{Data: rawDeltas}
if rawDeltas != nil {
inDeltasPointer = &inDeltas
}
if err := tlBuiltinTupleService2DeltaSet.BuiltinTupleService2DeltaSetReadJSON(legacyTypeNames, inDeltasPointer, &item.Deltas, item.ObjectsNum, item.ObjectIdLength, item.IntCountersNum, item.FloatCountersNum); err != nil {
return err
}
return nil
}
// This method is general version of WriteJSON, use it instead!
func (item *Service2AddOrIncrMany) WriteJSONGeneral(w []byte) (_ []byte, err error) {
return item.WriteJSONOpt(true, false, w)
}
func (item *Service2AddOrIncrMany) WriteJSON(w []byte) (_ []byte, err error) {
return item.WriteJSONOpt(true, false, w)
}
func (item *Service2AddOrIncrMany) WriteJSONOpt(newTypeNames bool, short bool, w []byte) (_ []byte, err error) {
w = append(w, '{')
backupIndexObjectIdLength := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"objectIdLength":`...)
w = basictl.JSONWriteUint32(w, item.ObjectIdLength)
if (item.ObjectIdLength != 0) == false {
w = w[:backupIndexObjectIdLength]
}
backupIndexIntCountersNum := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"intCountersNum":`...)
w = basictl.JSONWriteUint32(w, item.IntCountersNum)
if (item.IntCountersNum != 0) == false {
w = w[:backupIndexIntCountersNum]
}
backupIndexFloatCountersNum := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"floatCountersNum":`...)
w = basictl.JSONWriteUint32(w, item.FloatCountersNum)
if (item.FloatCountersNum != 0) == false {
w = w[:backupIndexFloatCountersNum]
}
backupIndexObjectsNum := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"objectsNum":`...)
w = basictl.JSONWriteUint32(w, item.ObjectsNum)
if (item.ObjectsNum != 0) == false {
w = w[:backupIndexObjectsNum]
}
backupIndexIntCounters := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"intCounters":`...)
if w, err = tlBuiltinTupleInt.BuiltinTupleIntWriteJSONOpt(newTypeNames, short, w, item.IntCounters, item.IntCountersNum); err != nil {
return w, err
}
if (len(item.IntCounters) != 0) == false {
w = w[:backupIndexIntCounters]
}
backupIndexFloatCounters := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"floatCounters":`...)
if w, err = tlBuiltinTupleInt.BuiltinTupleIntWriteJSONOpt(newTypeNames, short, w, item.FloatCounters, item.FloatCountersNum); err != nil {
return w, err
}
if (len(item.FloatCounters) != 0) == false {
w = w[:backupIndexFloatCounters]
}
backupIndexDeltas := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"deltas":`...)
if w, err = tlBuiltinTupleService2DeltaSet.BuiltinTupleService2DeltaSetWriteJSONOpt(newTypeNames, short, w, item.Deltas, item.ObjectsNum, item.ObjectIdLength, item.IntCountersNum, item.FloatCountersNum); err != nil {
return w, err
}
if (len(item.Deltas) != 0) == false {
w = w[:backupIndexDeltas]
}
return append(w, '}'), nil
}
func (item *Service2AddOrIncrMany) MarshalJSON() ([]byte, error) {
return item.WriteJSON(nil)
}
func (item *Service2AddOrIncrMany) UnmarshalJSON(b []byte) error {
if err := item.ReadJSON(true, &basictl.JsonLexer{Data: b}); err != nil {
return internal.ErrorInvalidJSON("service2.addOrIncrMany", err.Error())
}
return nil
}