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