plugins/include/datapack.inc
author David Anderson <dvander@alliedmods.net>
Tue Jan 22 16:47:10 2008 +0000 (2008-01-22)
changeset 1853 b046cf080755
parent 1330 ab94316bb52b
child 1947 e73a1e51833b
permissions -rw-r--r--
fire requires timebomb
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2007 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 _datapack_included
    34  #endinput
    35 #endif
    36 #define _datapack_included
    37 
    38 /**
    39  * Creates a new data pack.
    40  *
    41  * @return			A Handle to the data pack.  Must be closed with CloseHandle().
    42  */
    43 native Handle:CreateDataPack();
    44 
    45 /**
    46  * Packs a normal cell into a data pack.
    47  *
    48  * @param pack		Handle to the data pack.
    49  * @param cell		Cell to add.
    50  * @noreturn
    51  * @error			Invalid handle.
    52  */
    53 native WritePackCell(Handle:pack, cell);
    54 
    55 /**
    56  * Packs a float into a data pack.
    57  *
    58  * @param pack		Handle to the data pack.
    59  * @param val		Float to add.
    60  * @noreturn
    61  * @error			Invalid handle.
    62  */
    63 native WritePackFloat(Handle:pack, Float:val);
    64 
    65 /**
    66  * Packs a string into a data pack.
    67  *
    68  * @param pack		Handle to the data pack.
    69  * @param str		String to add.
    70  * @noreturn
    71  * @error			Invalid handle.
    72  */
    73 native WritePackString(Handle:pack, const String:str[]);
    74 
    75 /**
    76  * Reads a cell from a data pack.
    77  *
    78  * @param pack		Handle to the data pack.
    79  * @return			Cell value.
    80  * @error			Invalid handle, or bounds error.
    81  */
    82 native ReadPackCell(Handle:pack);
    83 
    84 /**
    85  * Reads a float from a data pack.
    86  *
    87  * @param pack		Handle to the data pack.
    88  * @return			Float value.
    89  * @error			Invalid handle, or bounds error.
    90  */
    91 native Float:ReadPackFloat(Handle:pack);
    92 
    93 /**
    94  * Reads a string from a data pack.
    95  *
    96  * @param pack		Handle to the data pack.
    97  * @param buffer	Destination string buffer.
    98  * @param maxlen	Maximum length of output string buffer.
    99  * @noreturn
   100  * @error			Invalid handle, or bounds error.
   101  */
   102 native ReadPackString(Handle:pack, String:buffer[], maxlen);
   103 
   104 /**
   105  * Resets the position in a data pack.
   106  *
   107  * @param pack		Handle to the data pack.
   108  * @param clear		If true, clears the contained data.
   109  * @noreturn
   110  * @error			Invalid handle.
   111  */
   112 native ResetPack(Handle:pack, bool:clear=false);
   113 
   114 /**
   115  * Returns the read or write position in a data pack.
   116  *
   117  * @param pack		Handle to the data pack.
   118  * @return			Numerical position in the data pack.
   119  * @error			Invalid handle.
   120  */
   121 native GetPackPosition(Handle:pack);
   122 
   123 /**
   124  * Sets the read/write position in a data pack.
   125  *
   126  * @param pack		Handle to the data pack.
   127  * @param position	New position to set.
   128  * @noreturn
   129  * @error			Invalid handle, or position is beyond the pack bounds.
   130  */
   131 native SetPackPosition(Handle:pack, position);
   132 
   133 /**
   134  * Returns whether or not a specified number of bytes from the data pack
   135  *  position to the end can be read.
   136  *
   137  * @param pack		Handle to the data pack.
   138  * @param bytes		Number of bytes to simulate reading.
   139  * @return			True if can be read, false otherwise.
   140  * @error			Invalid handle.
   141  */
   142 native bool:IsPackReadable(Handle:pack, bytes);