plugins/include/protobuf.inc
author Nicholas Hastings <skamonkey@gmail.com>
Tue Apr 23 07:11:49 2013 -0400 (2013-04-23)
changeset 3898 6b8333229344
parent 3896 cb7537c1da4d
child 3967 ceafb87d38a7
permissions -rw-r--r--
Remove deprecated PbReadRepeated natives.
skamonkey@3743
     1
/**
skamonkey@3743
     2
 * vim: set ts=4 :
skamonkey@3743
     3
 * =============================================================================
skamonkey@3743
     4
 * SourceMod (C)2013 AlliedModders LLC.  All rights reserved.
skamonkey@3743
     5
 * =============================================================================
skamonkey@3743
     6
 *
skamonkey@3743
     7
 * This file is part of the SourceMod/SourcePawn SDK.
skamonkey@3743
     8
 *
skamonkey@3743
     9
 * This program is free software; you can redistribute it and/or modify it under
skamonkey@3743
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
skamonkey@3743
    11
 * Free Software Foundation.
skamonkey@3743
    12
 * 
skamonkey@3743
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
skamonkey@3743
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
skamonkey@3743
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
skamonkey@3743
    16
 * details.
skamonkey@3743
    17
 *
skamonkey@3743
    18
 * You should have received a copy of the GNU General Public License along with
skamonkey@3743
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
skamonkey@3743
    20
 *
skamonkey@3743
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
skamonkey@3743
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
skamonkey@3743
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
skamonkey@3743
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
skamonkey@3743
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
skamonkey@3743
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
skamonkey@3743
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
skamonkey@3743
    28
 * or <http://www.sourcemod.net/license.php>.
skamonkey@3743
    29
 *
skamonkey@3743
    30
 * Version: $Id$
skamonkey@3743
    31
 */
skamonkey@3743
    32
 
skamonkey@3743
    33
#if defined _protobuf_included
skamonkey@3743
    34
#endinput
skamonkey@3743
    35
#endif
skamonkey@3743
    36
#define _protobuf_included
skamonkey@3743
    37
skamonkey@3813
    38
#define PB_FIELD_NOT_REPEATED -1
skamonkey@3813
    39
skamonkey@3743
    40
/**
skamonkey@3896
    41
 * Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message.
skamonkey@3743
    42
 *
skamonkey@3743
    43
 * @param pb			protobuf handle.
skamonkey@3743
    44
 * @param field			Field name.
skamonkey@3813
    45
 * @param index			Index into repeated field.
skamonkey@3743
    46
 * @return				Integer value read.
skamonkey@3743
    47
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
    48
 */
skamonkey@3813
    49
native PbReadInt(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
    50
skamonkey@3743
    51
/**
skamonkey@3743
    52
 * Reads a float or downcasted double from a protobuf message.
skamonkey@3743
    53
 *
skamonkey@3743
    54
 * @param pb			protobuf handle.
skamonkey@3743
    55
 * @param field			Field name.
skamonkey@3813
    56
 * @param index			Index into repeated field.
skamonkey@3743
    57
 * @return				Float value read.
skamonkey@3743
    58
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
    59
 */
skamonkey@3813
    60
native Float:PbReadFloat(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
    61
skamonkey@3743
    62
/**
skamonkey@3743
    63
 * Reads a bool from a protobuf message.
skamonkey@3743
    64
 *
skamonkey@3743
    65
 * @param pb			protobuf handle.
skamonkey@3743
    66
 * @param field			Field name.
skamonkey@3813
    67
 * @param index			Index into repeated field.
skamonkey@3743
    68
 * @return				Boolean value read.
skamonkey@3743
    69
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
    70
 */
skamonkey@3813
    71
native bool:PbReadBool(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
    72
skamonkey@3743
    73
/**
skamonkey@3743
    74
 * Reads a string from a protobuf message.
skamonkey@3743
    75
 *
skamonkey@3743
    76
 * @param pb			protobuf handle.
skamonkey@3743
    77
 * @param field			Field name.
skamonkey@3743
    78
 * @param buffer		Destination string buffer.
skamonkey@3743
    79
 * @param maxlength		Maximum length of output string buffer.
skamonkey@3813
    80
 * @param index			Index into repeated field.
skamonkey@3743
    81
 * @noreturn
skamonkey@3743
    82
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
    83
 */
skamonkey@3813
    84
native PbReadString(Handle:pb, const String:field[], String:buffer[], maxlength, index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
    85
skamonkey@3743
    86
/**
skamonkey@3743
    87
 * Reads an RGBA color value from a protobuf message.
skamonkey@3743
    88
 *
skamonkey@3743
    89
 * @param pb			protobuf handle.
skamonkey@3743
    90
 * @param field			Field name.
skamonkey@3743
    91
 * @param buffer		Destination color buffer.
skamonkey@3813
    92
 * @param index			Index into repeated field.
skamonkey@3743
    93
 * @noreturn
skamonkey@3743
    94
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
    95
 */
skamonkey@3813
    96
native PbReadColor(Handle:pb, const String:field[], buffer[4], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
    97
skamonkey@3743
    98
/**
skamonkey@3743
    99
 * Reads an XYZ angle value from a protobuf message.
skamonkey@3743
   100
 *
skamonkey@3743
   101
 * @param pb			protobuf handle.
skamonkey@3743
   102
 * @param field			Field name.
skamonkey@3743
   103
 * @param buffer		Destination angle buffer.
skamonkey@3813
   104
 * @param index			Index into repeated field.
skamonkey@3743
   105
 * @noreturn
skamonkey@3743
   106
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   107
 */
skamonkey@3813
   108
native PbReadAngle(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   109
skamonkey@3743
   110
/**
skamonkey@3743
   111
 * Reads an XYZ vector value from a protobuf message.
skamonkey@3743
   112
 *
skamonkey@3743
   113
 * @param pb			protobuf handle.
skamonkey@3743
   114
 * @param field			Field name.
skamonkey@3743
   115
 * @param buffer		Destination vector buffer.
skamonkey@3813
   116
 * @param index			Index into repeated field.
skamonkey@3743
   117
 * @noreturn
skamonkey@3743
   118
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   119
 */
skamonkey@3813
   120
native PbReadVector(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   121
skamonkey@3743
   122
/**
skamonkey@3743
   123
 * Reads an XY vector value from a protobuf message.
skamonkey@3743
   124
 *
skamonkey@3743
   125
 * @param pb			protobuf handle.
skamonkey@3743
   126
 * @param field			Field name.
skamonkey@3743
   127
 * @param buffer		Destination vector buffer.
skamonkey@3813
   128
 * @param index			Index into repeated field.
skamonkey@3743
   129
 * @noreturn
skamonkey@3743
   130
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   131
 */
skamonkey@3813
   132
native PbReadVector2D(Handle:pb, const String:field[], Float:buffer[2], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   133
skamonkey@3743
   134
/**
skamonkey@3743
   135
 * Gets the number of elements in a repeated field of a protobuf message.
skamonkey@3743
   136
 *
skamonkey@3743
   137
 * @param pb			protobuf handle.
skamonkey@3743
   138
 * @param field			Field name.
skamonkey@3743
   139
 * @return				Number of elements in the field.
skamonkey@3743
   140
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   141
 */
skamonkey@3743
   142
native PbGetRepeatedFieldCount(Handle:pb, const String:field[]);
skamonkey@3743
   143
skamonkey@3743
   144
/**
skamonkey@3896
   145
 * Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message.
skamonkey@3743
   146
 *
skamonkey@3743
   147
 * @param pb			protobuf handle.
skamonkey@3743
   148
 * @param field			Field name.
skamonkey@3743
   149
 * @param value			Integer value to set.
skamonkey@3814
   150
 * @param index			Index into repeated field.
skamonkey@3743
   151
 * @noreturn
skamonkey@3743
   152
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   153
 */
skamonkey@3814
   154
native PbSetInt(Handle:pb, const String:field[], value, index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   155
skamonkey@3743
   156
/**
skamonkey@3743
   157
 * Sets a float or double on a protobuf message.
skamonkey@3743
   158
 *
skamonkey@3743
   159
 * @param pb			protobuf handle.
skamonkey@3743
   160
 * @param field			Field name.
skamonkey@3743
   161
 * @param value			Float value to set.
skamonkey@3814
   162
 * @param index			Index into repeated field.
skamonkey@3743
   163
 * @noreturn
skamonkey@3743
   164
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   165
 */
skamonkey@3814
   166
native PbSetFloat(Handle:pb, const String:field[], Float:value, index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   167
skamonkey@3743
   168
/**
skamonkey@3743
   169
 * Sets a bool on a protobuf message.
skamonkey@3743
   170
 *
skamonkey@3743
   171
 * @param pb			protobuf handle.
skamonkey@3743
   172
 * @param field			Field name.
skamonkey@3743
   173
 * @param value			Boolean value to set.
skamonkey@3814
   174
 * @param index			Index into repeated field.
skamonkey@3743
   175
 * @noreturn
skamonkey@3743
   176
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   177
 */
skamonkey@3814
   178
native PbSetBool(Handle:pb, const String:field[], bool:value, index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   179
skamonkey@3743
   180
/**
skamonkey@3743
   181
 * Sets a string on a protobuf message.
skamonkey@3743
   182
 *
skamonkey@3743
   183
 * @param pb			protobuf handle.
skamonkey@3743
   184
 * @param field			Field name.
skamonkey@3743
   185
 * @param value			String value to set.
skamonkey@3814
   186
 * @param index			Index into repeated field.
skamonkey@3743
   187
 * @noreturn
skamonkey@3743
   188
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   189
 */
skamonkey@3814
   190
native PbSetString(Handle:pb, const String:field[], const String:value[], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   191
skamonkey@3743
   192
/**
skamonkey@3743
   193
 * Sets an RGBA color on a protobuf message.
skamonkey@3743
   194
 *
skamonkey@3743
   195
 * @param pb			protobuf handle.
skamonkey@3743
   196
 * @param field			Field name.
skamonkey@3743
   197
 * @param value			Color value to set.
skamonkey@3814
   198
 * @param index			Index into repeated field.
skamonkey@3743
   199
 * @noreturn
skamonkey@3743
   200
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   201
 */
skamonkey@3814
   202
native PbSetColor(Handle:pb, const String:field[], const color[4], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   203
skamonkey@3743
   204
/**
skamonkey@3743
   205
 * Sets an XYZ angle on a protobuf message.
skamonkey@3743
   206
 *
skamonkey@3743
   207
 * @param pb			protobuf handle.
skamonkey@3743
   208
 * @param field			Field name.
skamonkey@3743
   209
 * @param value			Angle value to set.
skamonkey@3814
   210
 * @param index			Index into repeated field.
skamonkey@3743
   211
 * @noreturn
skamonkey@3743
   212
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   213
 */
skamonkey@3814
   214
native PbSetAngle(Handle:pb, const String:field[], const Float:angle[3], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   215
skamonkey@3743
   216
/**
skamonkey@3743
   217
 * Sets an XYZ vector on a protobuf message.
skamonkey@3743
   218
 *
skamonkey@3743
   219
 * @param pb			protobuf handle.
skamonkey@3743
   220
 * @param field			Field name.
skamonkey@3743
   221
 * @param value			Vector value to set.
skamonkey@3814
   222
 * @param index			Index into repeated field.
skamonkey@3743
   223
 * @noreturn
skamonkey@3743
   224
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   225
 */
skamonkey@3814
   226
native PbSetVector(Handle:pb, const String:field[], const Float:vec[3], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   227
skamonkey@3743
   228
/**
skamonkey@3743
   229
 * Sets an XY vector on a protobuf message.
skamonkey@3743
   230
 *
skamonkey@3743
   231
 * @param pb			protobuf handle.
skamonkey@3743
   232
 * @param field			Field name.
skamonkey@3743
   233
 * @param value			Vector value to set.
skamonkey@3814
   234
 * @param index			Index into repeated field.
skamonkey@3743
   235
 * @noreturn
skamonkey@3743
   236
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   237
 */
skamonkey@3814
   238
native PbSetVector2D(Handle:pb, const String:field[], const Float:vec[2], index=PB_FIELD_NOT_REPEATED);
skamonkey@3743
   239
skamonkey@3743
   240
/**
skamonkey@3896
   241
 * Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field.
skamonkey@3743
   242
 *
skamonkey@3743
   243
 * @param pb			protobuf handle.
skamonkey@3743
   244
 * @param field			Field name.
skamonkey@3743
   245
 * @param value			Integer value to add.
skamonkey@3743
   246
 * @noreturn
skamonkey@3743
   247
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   248
 */
skamonkey@3743
   249
native PbAddInt(Handle:pb, const String:field[], value);
skamonkey@3743
   250
skamonkey@3743
   251
/**
skamonkey@3743
   252
 * Add a float or double to a protobuf message repeated field.
skamonkey@3743
   253
 *
skamonkey@3743
   254
 * @param pb			protobuf handle.
skamonkey@3743
   255
 * @param field			Field name.
skamonkey@3743
   256
 * @param value			Float value to add.
skamonkey@3743
   257
 * @noreturn
skamonkey@3743
   258
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   259
 */
skamonkey@3743
   260
native PbAddFloat(Handle:pb, const String:field[], Float:value);
skamonkey@3743
   261
skamonkey@3743
   262
/**
skamonkey@3743
   263
 * Add a bool to a protobuf message repeated field.
skamonkey@3743
   264
 *
skamonkey@3743
   265
 * @param pb			protobuf handle.
skamonkey@3743
   266
 * @param field			Field name.
skamonkey@3743
   267
 * @param value			Boolean value to add.
skamonkey@3743
   268
 * @noreturn
skamonkey@3743
   269
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   270
 */
skamonkey@3743
   271
native PbAddBool(Handle:pb, const String:field[], bool:value);
skamonkey@3743
   272
skamonkey@3743
   273
/**
skamonkey@3743
   274
 * Add a string to a protobuf message repeated field.
skamonkey@3743
   275
 *
skamonkey@3743
   276
 * @param pb			protobuf handle.
skamonkey@3743
   277
 * @param field			Field name.
skamonkey@3743
   278
 * @param value			String value to add.
skamonkey@3743
   279
 * @noreturn
skamonkey@3743
   280
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   281
 */
skamonkey@3743
   282
native PbAddString(Handle:pb, const String:field[], const String:value[]);
skamonkey@3743
   283
skamonkey@3743
   284
/**
skamonkey@3743
   285
 * Add an RGBA color to a protobuf message repeated field.
skamonkey@3743
   286
 *
skamonkey@3743
   287
 * @param pb			protobuf handle.
skamonkey@3743
   288
 * @param field			Field name.
skamonkey@3743
   289
 * @param value			Color value to add.
skamonkey@3743
   290
 * @noreturn
skamonkey@3743
   291
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   292
 */
skamonkey@3743
   293
native PbAddColor(Handle:pb, const String:field[], const color[4]);
skamonkey@3743
   294
skamonkey@3743
   295
/**
skamonkey@3743
   296
 * Add an XYZ angle to a protobuf message repeated field.
skamonkey@3743
   297
 *
skamonkey@3743
   298
 * @param pb			protobuf handle.
skamonkey@3743
   299
 * @param field			Field name.
skamonkey@3743
   300
 * @param value			Angle value to add.
skamonkey@3743
   301
 * @noreturn
skamonkey@3743
   302
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   303
 */
skamonkey@3743
   304
native PbAddAngle(Handle:pb, const String:field[], const Float:angle[3]);
skamonkey@3743
   305
skamonkey@3743
   306
/**
skamonkey@3743
   307
 * Add an XYZ vector to a protobuf message repeated field.
skamonkey@3743
   308
 *
skamonkey@3743
   309
 * @param pb			protobuf handle.
skamonkey@3743
   310
 * @param field			Field name.
skamonkey@3743
   311
 * @param value			Vector value to add.
skamonkey@3743
   312
 * @noreturn
skamonkey@3743
   313
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   314
 */
skamonkey@3743
   315
native PbAddVector(Handle:pb, const String:field[], const Float:vec[3]);
skamonkey@3743
   316
skamonkey@3743
   317
/**
skamonkey@3743
   318
 * Add an XY vector to a protobuf message repeated field.
skamonkey@3743
   319
 *
skamonkey@3743
   320
 * @param pb			protobuf handle.
skamonkey@3743
   321
 * @param field			Field name.
skamonkey@3743
   322
 * @param value			Vector value to add.
skamonkey@3743
   323
 * @noreturn
skamonkey@3743
   324
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   325
 */
skamonkey@3743
   326
native PbAddVector2D(Handle:pb, const String:field[], const Float:vec[2]);
skamonkey@3743
   327
skamonkey@3743
   328
/**
skamonkey@3743
   329
 * Retrieve a handle to an embedded protobuf message in a protobuf message.
skamonkey@3743
   330
 *
skamonkey@3743
   331
 * @param pb			protobuf handle.
skamonkey@3743
   332
 * @param field			Field name.
skamonkey@3743
   333
 * @return				protobuf handle to embedded message.
skamonkey@3743
   334
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   335
 */ 
skamonkey@3743
   336
native Handle:PbReadMessage(Handle:pb, const String:field[]);
skamonkey@3743
   337
skamonkey@3743
   338
/**
skamonkey@3743
   339
 * Retrieve a handle to an embedded protobuf message in a protobuf message repeated field.
skamonkey@3743
   340
 *
skamonkey@3743
   341
 * @param pb			protobuf handle.
skamonkey@3743
   342
 * @param field			Field name.
skamonkey@3743
   343
 * @param index			Index in the repeated field.
skamonkey@3743
   344
 * @return				protobuf handle to embedded message.
skamonkey@3743
   345
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   346
 */ 
skamonkey@3743
   347
native Handle:PbReadRepeatedMessage(Handle:pb, const String:field[], index);
skamonkey@3743
   348
skamonkey@3743
   349
/**
skamonkey@3743
   350
 * Adds an embedded protobuf message to a protobuf message repeated field.
skamonkey@3743
   351
 *
skamonkey@3743
   352
 * @param pb			protobuf handle.
skamonkey@3743
   353
 * @param field			Field name.
skamonkey@3743
   354
 * @return				protobuf handle to added, embedded message.
skamonkey@3743
   355
 * @error				Invalid or incorrect Handle, non-existant field, or incorrect field type.
skamonkey@3743
   356
 */ 
skamonkey@3743
   357
native Handle:PbAddMessage(Handle:pb, const String:field[]);