plugins/include/datapack.inc
author David Anderson <dvander@alliedmods.net>
Sun Jul 08 17:43:40 2007 +0000 (2007-07-08)
changeset 1071 d15a3e83a3d4
parent 1015 6b27b8e57f47
child 1330 ab94316bb52b
permissions -rw-r--r--
added amb577
     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  * Creates a new data pack.
    23  *
    24  * @return			A Handle to the data pack.  Must be closed with CloseHandle().
    25  */
    26 native Handle:CreateDataPack();
    27 
    28 /**
    29  * Packs a normal cell into a data pack.
    30  *
    31  * @param pack		Handle to the data pack.
    32  * @param cell		Cell to add.
    33  * @noreturn
    34  * @error			Invalid handle.
    35  */
    36 native WritePackCell(Handle:pack, cell);
    37 
    38 /**
    39  * Packs a float into a data pack.
    40  *
    41  * @param pack		Handle to the data pack.
    42  * @param val		Float to add.
    43  * @noreturn
    44  * @error			Invalid handle.
    45  */
    46 native WritePackFloat(Handle:pack, Float:val);
    47 
    48 /**
    49  * Packs a string into a data pack.
    50  *
    51  * @param pack		Handle to the data pack.
    52  * @param str		String to add.
    53  * @noreturn
    54  * @error			Invalid handle.
    55  */
    56 native WritePackString(Handle:pack, const String:str[]);
    57 
    58 /**
    59  * Reads a cell from a data pack.
    60  *
    61  * @param pack		Handle to the data pack.
    62  * @return			Cell value.
    63  * @error			Invalid handle, or bounds error.
    64  */
    65 native ReadPackCell(Handle:pack);
    66 
    67 /**
    68  * Reads a float from a data pack.
    69  *
    70  * @param pack		Handle to the data pack.
    71  * @return			Float value.
    72  * @error			Invalid handle, or bounds error.
    73  */
    74 native Float:ReadPackFloat(Handle:pack);
    75 
    76 /**
    77  * Reads a string from a data pack.
    78  *
    79  * @param pack		Handle to the data pack.
    80  * @param buffer	Destination string buffer.
    81  * @param maxlen	Maximum length of output string buffer.
    82  * @noreturn
    83  * @error			Invalid handle, or bounds error.
    84  */
    85 native ReadPackString(Handle:pack, String:buffer[], maxlen);
    86 
    87 /**
    88  * Resets the position in a data pack.
    89  *
    90  * @param pack		Handle to the data pack.
    91  * @param clear		If true, clears the contained data.
    92  * @noreturn
    93  * @error			Invalid handle.
    94  */
    95 native ResetPack(Handle:pack, bool:clear=false);
    96 
    97 /**
    98  * Returns the read or write position in a data pack.
    99  *
   100  * @param pack		Handle to the data pack.
   101  * @return			Numerical position in the data pack.
   102  * @error			Invalid handle.
   103  */
   104 native GetPackPosition(Handle:pack);
   105 
   106 /**
   107  * Sets the read/write position in a data pack.
   108  *
   109  * @param pack		Handle to the data pack.
   110  * @param position	New position to set.
   111  * @noreturn
   112  * @error			Invalid handle, or position is beyond the pack bounds.
   113  */
   114 native SetPackPosition(Handle:pack, position);
   115 
   116 /**
   117  * Returns whether or not a specified number of bytes from the data pack
   118  *  position to the end can be read.
   119  *
   120  * @param pack		Handle to the data pack.
   121  * @param bytes		Number of bytes to simulate reading.
   122  * @return			True if can be read, false otherwise.
   123  * @error			Invalid handle.
   124  */
   125 native bool:IsPackReadable(Handle:pack, bytes);