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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
|
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod (C)2013 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#if defined _protobuf_included
#endinput
#endif
#define _protobuf_included
#define PB_FIELD_NOT_REPEATED -1
methodmap Protobuf < Handle
{
// Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message.
//
// @param field Field name.
// @param index Index into repeated field.
// @return Integer value read.
// @error Non-existent field, or incorrect field type.
public native int ReadInt(const char[] field, int index = PB_FIELD_NOT_REPEATED);
// Reads an int64, uint64, sint64, fixed64, sfixed64 from a protobuf message.
//
// @param field Field name.
// @param value Array to represent the large integer (0=High bits, 1=Low bits).
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void ReadInt64(const char[] field, int value[2], int index = PB_FIELD_NOT_REPEATED);
// Reads a float or downcasted double from a protobuf message.
//
// @param field Field name.
// @param index Index into repeated field.
// @return Float value read.
// @error Non-existent field, or incorrect field type.
public native float ReadFloat(const char[] field, int index = PB_FIELD_NOT_REPEATED);
// Reads a bool from a protobuf message.
//
// @param field Field name.
// @param index Index into repeated field.
// @return Boolean value read.
// @error Non-existent field, or incorrect field type.
public native bool ReadBool(const char[] field, int index = PB_FIELD_NOT_REPEATED);
// Reads a string from a protobuf message.
//
// @param field Field name.
// @param buffer Destination string buffer.
// @param maxlength Maximum length of output string buffer.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void ReadString(const char[] field, char[] buffer, int maxlength, int index = PB_FIELD_NOT_REPEATED);
// Reads an RGBA color value from a protobuf message.
//
// @param field Field name.
// @param buffer Destination color buffer.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void ReadColor(const char[] field, int buffer[4], int index = PB_FIELD_NOT_REPEATED);
// Reads an XYZ angle value from a protobuf message.
//
// @param field Field name.
// @param buffer Destination angle buffer.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void ReadAngle(const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
// Reads an XYZ vector value from a protobuf message.
//
// @param pb protobuf handle.
// @param field Field name.
// @param buffer Destination vector buffer.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void ReadVector(const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
// Reads an XY vector value from a protobuf message.
//
// @param field Field name.
// @param buffer Destination vector buffer.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void ReadVector2D(const char[] field, float buffer[2], int index = PB_FIELD_NOT_REPEATED);
// Gets the number of elements in a repeated field of a protobuf message.
//
// @param field Field name.
// @return Number of elements in the field.
// @error Non-existent field, or non-repeated field.
public native int GetRepeatedFieldCount(const char[] field);
// Returns whether or not the named, non-repeated field has a value set.
//
// @param field Field name.
// @return True if value has been set, else false.
// @error Non-existent field, or repeated field.
public native bool HasField(const char[] field);
// Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message.
//
// @param field Field name.
// @param value Integer value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetInt(const char[] field, int value, int index = PB_FIELD_NOT_REPEATED);
// Sets an int64, uint64, sint64, fixed64, sfixed64 on a protobuf message.
//
// @param field Field name.
// @param value Large integer value to set (0=High bits, 1=Low bits).
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetInt64(const char[] field, int value[2], int index = PB_FIELD_NOT_REPEATED);
// Sets a float or double on a protobuf message.
//
// @param field Field name.
// @param value Float value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetFloat(const char[] field, float value, int index = PB_FIELD_NOT_REPEATED);
// Sets a bool on a protobuf message.
//
// @param field Field name.
// @param value Boolean value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetBool(const char[] field, bool value, int index = PB_FIELD_NOT_REPEATED);
// Sets a string on a protobuf message.
//
// @param field Field name.
// @param value String value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetString(const char[] field, const char[] value, int index = PB_FIELD_NOT_REPEATED);
// Sets an RGBA color on a protobuf message.
//
// @param field Field name.
// @param color Color value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetColor(const char[] field, const int color[4], int index = PB_FIELD_NOT_REPEATED);
// Sets an XYZ angle on a protobuf message.
//
// @param field Field name.
// @param angle Angle value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetAngle(const char[] field, const float angle[3], int index = PB_FIELD_NOT_REPEATED);
// Sets an XYZ vector on a protobuf message.
//
// @param field Field name.
// @param vec Vector value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetVector(const char[] field, const float vec[3], int index = PB_FIELD_NOT_REPEATED);
// Sets an XY vector on a protobuf message.
//
// @param field Field name.
// @param vec Vector value to set.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void SetVector2D(const char[] field, const float vec[2], int index = PB_FIELD_NOT_REPEATED);
// Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field.
//
// @param field Field name.
// @param value Integer value to add.
// @error Non-existent field, or incorrect field type.
public native void AddInt(const char[] field, int value);
// Add an int64, uint64, sint64, fixed64, sfixed64 to a protobuf message repeated field.
//
// @param field Field name.
// @param value Large integer value to add (0=High bits, 1=Low bits).
// @error Non-existent field, or incorrect field type.
public native void AddInt64(const char[] field, int value[2]);
// Add a float or double to a protobuf message repeated field.
//
// @param field Field name.
// @param value Float value to add.
// @error Non-existent field, or incorrect field type.
public native void AddFloat(const char[] field, float value);
// Add a bool to a protobuf message repeated field.
//
// @param field Field name.
// @param value Boolean value to add.
// @error Non-existent field, or incorrect field type.
public native void AddBool(const char[] field, bool value);
// Add a string to a protobuf message repeated field.
//
// @param field Field name.
// @param value String value to add.
// @error Non-existent field, or incorrect field type.
public native void AddString(const char[] field, const char[] value);
// Add an RGBA color to a protobuf message repeated field.
//
// @param field Field name.
// @param color Color value to add.
// @error Non-existent field, or incorrect field type.
public native void AddColor(const char[] field, const int color[4]);
// Add an XYZ angle to a protobuf message repeated field.
//
// @param field Field name.
// @param angle Angle value to add.
// @error Non-existent field, or incorrect field type.
public native void AddAngle(const char[] field, const float angle[3]);
// Add an XYZ vector to a protobuf message repeated field.
//
// @param field Field name.
// @param vec Vector value to add.
// @error Non-existent field, or incorrect field type.
public native void AddVector(const char[] field, const float vec[3]);
// Add an XY vector to a protobuf message repeated field.
//
// @param field Field name.
// @param vec Vector value to add.
// @error Non-existent field, or incorrect field type.
public native void AddVector2D(const char[] field, const float vec[2]);
// Removes a value by index from a protobuf message repeated field.
//
// @param field Field name.
// @param index Index into repeated field.
// @error Non-existent field, or incorrect field type.
public native void RemoveRepeatedFieldValue(const char[] field, int index);
// Retrieve a handle to an embedded protobuf message in a protobuf message.
//
// @param field Field name.
// @return Protobuf handle to embedded message.
// @error Non-existent field, or incorrect field type.
public native Protobuf ReadMessage(const char[] field);
// Retrieve a handle to an embedded protobuf message in a protobuf message
// repeated field.
//
// @param field Field name.
// @param index Index in the repeated field.
// @return Protobuf handle to embedded message.
// @error Non-existent field, or incorrect field type.
public native Protobuf ReadRepeatedMessage(const char[] field, int index);
// Adds an embedded protobuf message to a protobuf message repeated field.
//
// @param field Field name.
// @return Protobuf handle to added, embedded message.
// @error Non-existent field, or incorrect field type.
public native Protobuf AddMessage(const char[] field);
};
/**
* Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param index Index into repeated field.
* @return Integer value read.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native int PbReadInt(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
/**
* Reads a float or downcasted double from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param index Index into repeated field.
* @return Float value read.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native float PbReadFloat(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
/**
* Reads a bool from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param index Index into repeated field.
* @return Boolean value read.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native bool PbReadBool(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
/**
* Reads a string from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbReadString(Handle pb, const char[] field, char[] buffer, int maxlength, int index = PB_FIELD_NOT_REPEATED);
/**
* Reads an RGBA color value from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param buffer Destination color buffer.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbReadColor(Handle pb, const char[] field, int buffer[4], int index = PB_FIELD_NOT_REPEATED);
/**
* Reads an XYZ angle value from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param buffer Destination angle buffer.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbReadAngle(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
/**
* Reads an XYZ vector value from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param buffer Destination vector buffer.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbReadVector(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
/**
* Reads an XY vector value from a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param buffer Destination vector buffer.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbReadVector2D(Handle pb, const char[] field, float buffer[2], int index = PB_FIELD_NOT_REPEATED);
/**
* Gets the number of elements in a repeated field of a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @return Number of elements in the field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native int PbGetRepeatedFieldCount(Handle pb, const char[] field);
/**
* Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value Integer value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetInt(Handle pb, const char[] field, int value, int index = PB_FIELD_NOT_REPEATED);
/**
* Sets a float or double on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value Float value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetFloat(Handle pb, const char[] field, float value, int index = PB_FIELD_NOT_REPEATED);
/**
* Sets a bool on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value Boolean value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetBool(Handle pb, const char[] field, bool value, int index = PB_FIELD_NOT_REPEATED);
/**
* Sets a string on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value String value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetString(Handle pb, const char[] field, const char[] value, int index = PB_FIELD_NOT_REPEATED);
/**
* Sets an RGBA color on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param color Color value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetColor(Handle pb, const char[] field, const int color[4], int index = PB_FIELD_NOT_REPEATED);
/**
* Sets an XYZ angle on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param angle Angle value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetAngle(Handle pb, const char[] field, const float angle[3], int index = PB_FIELD_NOT_REPEATED);
/**
* Sets an XYZ vector on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param vec Vector value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetVector(Handle pb, const char[] field, const float vec[3], int index = PB_FIELD_NOT_REPEATED);
/**
* Sets an XY vector on a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @param vec Vector value to set.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbSetVector2D(Handle pb, const char[] field, const float vec[2], int index = PB_FIELD_NOT_REPEATED);
/**
* Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value Integer value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddInt(Handle pb, const char[] field, int value);
/**
* Add a float or double to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value Float value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddFloat(Handle pb, const char[] field, float value);
/**
* Add a bool to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value Boolean value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddBool(Handle pb, const char[] field, bool value);
/**
* Add a string to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param value String value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddString(Handle pb, const char[] field, const char[] value);
/**
* Add an RGBA color to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param color Color value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddColor(Handle pb, const char[] field, const int color[4]);
/**
* Add an XYZ angle to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param angle Angle value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddAngle(Handle pb, const char[] field, const float angle[3]);
/**
* Add an XYZ vector to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param vec Vector value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddVector(Handle pb, const char[] field, const float vec[3]);
/**
* Add an XY vector to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param vec Vector value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbAddVector2D(Handle pb, const char[] field, const float vec[2]);
/**
* Removes a value by index from a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native void PbRemoveRepeatedFieldValue(Handle pb, const char[] field, int index);
/**
* Retrieve a handle to an embedded protobuf message in a protobuf message.
*
* @param pb protobuf handle.
* @param field Field name.
* @return protobuf handle to embedded message.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native Handle PbReadMessage(Handle pb, const char[] field);
/**
* Retrieve a handle to an embedded protobuf message in a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @param index Index in the repeated field.
* @return protobuf handle to embedded message.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native Handle PbReadRepeatedMessage(Handle pb, const char[] field, int index);
/**
* Adds an embedded protobuf message to a protobuf message repeated field.
*
* @param pb protobuf handle.
* @param field Field name.
* @return protobuf handle to added, embedded message.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/
native Handle PbAddMessage(Handle pb, const char[] field);
|