plugins/include/datapack.inc
author Scott Ehlert <ds@alliedmods.net>
Mon Mar 19 18:07:15 2007 +0000 (2007-03-19)
changeset 650 ab919035c173
parent 475 bb11d7eaae0f
child 873 a2136b3be10d
permissions -rw-r--r--
Guess I forgot to close this.
     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.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 #if defined _datapack_included
    17  #endinput
    18 #endif
    19 #define _datapack_included
    20 
    21 
    22 /**
    23  * Creates a new data pack.
    24  *
    25  * @return			A Handle to the data pack.  Must be closed with CloseHandle().
    26  */
    27 native Handle:CreateDataPack();
    28 
    29 /**
    30  * Packs a normal cell into a data pack.
    31  *
    32  * @param pack		Handle to the data pack.
    33  * @param cell		Cell to add.
    34  * @noreturn
    35  * @error			Invalid handle.
    36  */
    37 native WritePackCell(Handle:pack, cell);
    38 
    39 /**
    40  * Packs a float into a data pack.
    41  *
    42  * @param pack		Handle to the data pack.
    43  * @param val		Float to add.
    44  * @noreturn
    45  * @error			Invalid handle.
    46  */
    47 native WritePackFloat(Handle:pack, Float:val);
    48 
    49 /**
    50  * Packs a string into a data pack.
    51  *
    52  * @param pack		Handle to the data pack.
    53  * @param str		String to add.
    54  * @noreturn
    55  * @error			Invalid handle.
    56  */
    57 native WritePackString(Handle:pack, String:str[]);
    58 
    59 /**
    60  * Reads a cell from a data pack.
    61  *
    62  * @param pack		Handle to the data pack.
    63  * @return			Cell value.
    64  * @error			Invalid handle, or bounds error.
    65  */
    66 native ReadPackCell(Handle:pack);
    67 
    68 /**
    69  * Reads a float from a data pack.
    70  *
    71  * @param pack		Handle to the data pack.
    72  * @return			Float value.
    73  * @error			Invalid handle, or bounds error.
    74  */
    75 native Float:ReadPackFloat(Handle:pack);
    76 
    77 /**
    78  * Reads a string from a data pack.
    79  *
    80  * @param pack		Handle to the data pack.
    81  * @param buffer	Destination string buffer.
    82  * @param maxlen	Maximum length of output string buffer.
    83  * @noreturn
    84  * @error			Invalid handle, or bounds error.
    85  */
    86 native ReadPackString(Handle:pack, String:buffer[], maxlen);
    87 
    88 /**
    89  * Resets the position in a data pack.
    90  *
    91  * @param pack		Handle to the data pack.
    92  * @param clear		If true, clears the contained data.
    93  * @noreturn
    94  * @error			Invalid handle.
    95  */
    96 native ResetPack(Handle:pack, bool:clear=false);
    97 
    98 /**
    99  * Returns the read or write position in a data pack.
   100  *
   101  * @param pack		Handle to the data pack.
   102  * @return			Numerical position in the data pack.
   103  * @error			Invalid handle.
   104  */
   105 native GetPackPosition(Handle:pack);
   106 
   107 /**
   108  * Sets the read/write position in a data pack.
   109  *
   110  * @param pack		Handle to the data pack.
   111  * @param position	New position to set.
   112  * @noreturn
   113  * @error			Invalid handle, or position is beyond the pack bounds.
   114  */
   115 native SetPackPosition(Handle:pack, position);
   116 
   117 /**
   118  * Returns whether or not a specified number of bytes from the data pack
   119  *  position to the end can be read.
   120  *
   121  * @param pack		Handle to the data pack.
   122  * @param bytes		Number of bytes to simulate reading.
   123  * @return			True if can be read, false otherwise.
   124  * @error			Invalid handle.
   125  */
   126 native bool:IsPackReadable(Handle:pack, bytes);