plugins/include/datapack.inc
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/datapack.inc	Sun Mar 30 07:00:22 2008 +0000
     1.3 @@ -0,0 +1,142 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     1.8 + * =============================================================================
     1.9 + *
    1.10 + * This file is part of the SourceMod/SourcePawn SDK.
    1.11 + *
    1.12 + * This program is free software; you can redistribute it and/or modify it under
    1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 + * Free Software Foundation.
    1.15 + * 
    1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 + * details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU General Public License along with
    1.22 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 + *
    1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 + * or <http://www.sourcemod.net/license.php>.
    1.32 + *
    1.33 + * Version: $Id$
    1.34 + */
    1.35 +
    1.36 +#if defined _datapack_included
    1.37 + #endinput
    1.38 +#endif
    1.39 +#define _datapack_included
    1.40 +
    1.41 +/**
    1.42 + * Creates a new data pack.
    1.43 + *
    1.44 + * @return			A Handle to the data pack.  Must be closed with CloseHandle().
    1.45 + */
    1.46 +native Handle:CreateDataPack();
    1.47 +
    1.48 +/**
    1.49 + * Packs a normal cell into a data pack.
    1.50 + *
    1.51 + * @param pack		Handle to the data pack.
    1.52 + * @param cell		Cell to add.
    1.53 + * @noreturn
    1.54 + * @error			Invalid handle.
    1.55 + */
    1.56 +native WritePackCell(Handle:pack, cell);
    1.57 +
    1.58 +/**
    1.59 + * Packs a float into a data pack.
    1.60 + *
    1.61 + * @param pack		Handle to the data pack.
    1.62 + * @param val		Float to add.
    1.63 + * @noreturn
    1.64 + * @error			Invalid handle.
    1.65 + */
    1.66 +native WritePackFloat(Handle:pack, Float:val);
    1.67 +
    1.68 +/**
    1.69 + * Packs a string into a data pack.
    1.70 + *
    1.71 + * @param pack		Handle to the data pack.
    1.72 + * @param str		String to add.
    1.73 + * @noreturn
    1.74 + * @error			Invalid handle.
    1.75 + */
    1.76 +native WritePackString(Handle:pack, const String:str[]);
    1.77 +
    1.78 +/**
    1.79 + * Reads a cell from a data pack.
    1.80 + *
    1.81 + * @param pack		Handle to the data pack.
    1.82 + * @return			Cell value.
    1.83 + * @error			Invalid handle, or bounds error.
    1.84 + */
    1.85 +native ReadPackCell(Handle:pack);
    1.86 +
    1.87 +/**
    1.88 + * Reads a float from a data pack.
    1.89 + *
    1.90 + * @param pack		Handle to the data pack.
    1.91 + * @return			Float value.
    1.92 + * @error			Invalid handle, or bounds error.
    1.93 + */
    1.94 +native Float:ReadPackFloat(Handle:pack);
    1.95 +
    1.96 +/**
    1.97 + * Reads a string from a data pack.
    1.98 + *
    1.99 + * @param pack		Handle to the data pack.
   1.100 + * @param buffer	Destination string buffer.
   1.101 + * @param maxlen	Maximum length of output string buffer.
   1.102 + * @noreturn
   1.103 + * @error			Invalid handle, or bounds error.
   1.104 + */
   1.105 +native ReadPackString(Handle:pack, String:buffer[], maxlen);
   1.106 +
   1.107 +/**
   1.108 + * Resets the position in a data pack.
   1.109 + *
   1.110 + * @param pack		Handle to the data pack.
   1.111 + * @param clear		If true, clears the contained data.
   1.112 + * @noreturn
   1.113 + * @error			Invalid handle.
   1.114 + */
   1.115 +native ResetPack(Handle:pack, bool:clear=false);
   1.116 +
   1.117 +/**
   1.118 + * Returns the read or write position in a data pack.
   1.119 + *
   1.120 + * @param pack		Handle to the data pack.
   1.121 + * @return			Numerical position in the data pack.
   1.122 + * @error			Invalid handle.
   1.123 + */
   1.124 +native GetPackPosition(Handle:pack);
   1.125 +
   1.126 +/**
   1.127 + * Sets the read/write position in a data pack.
   1.128 + *
   1.129 + * @param pack		Handle to the data pack.
   1.130 + * @param position	New position to set.
   1.131 + * @noreturn
   1.132 + * @error			Invalid handle, or position is beyond the pack bounds.
   1.133 + */
   1.134 +native SetPackPosition(Handle:pack, position);
   1.135 +
   1.136 +/**
   1.137 + * Returns whether or not a specified number of bytes from the data pack
   1.138 + *  position to the end can be read.
   1.139 + *
   1.140 + * @param pack		Handle to the data pack.
   1.141 + * @param bytes		Number of bytes to simulate reading.
   1.142 + * @return			True if can be read, false otherwise.
   1.143 + * @error			Invalid handle.
   1.144 + */
   1.145 +native bool:IsPackReadable(Handle:pack, bytes);