3 * =============================================================================
4 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
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.
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
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/>.
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>.
33 #if defined _datapack_included
36 #define _datapack_included
39 * Creates a new data pack.
41 * @return A Handle to the data pack. Must be closed with CloseHandle().
43 native Handle:CreateDataPack();
46 * Packs a normal cell into a data pack.
48 * @param pack Handle to the data pack.
49 * @param cell Cell to add.
51 * @error Invalid handle.
53 native WritePackCell(Handle:pack, cell);
56 * Packs a float into a data pack.
58 * @param pack Handle to the data pack.
59 * @param val Float to add.
61 * @error Invalid handle.
63 native WritePackFloat(Handle:pack, Float:val);
66 * Packs a string into a data pack.
68 * @param pack Handle to the data pack.
69 * @param str String to add.
71 * @error Invalid handle.
73 native WritePackString(Handle:pack, const String:str[]);
76 * Reads a cell from a data pack.
78 * @param pack Handle to the data pack.
80 * @error Invalid handle, or bounds error.
82 native ReadPackCell(Handle:pack);
85 * Reads a float from a data pack.
87 * @param pack Handle to the data pack.
88 * @return Float value.
89 * @error Invalid handle, or bounds error.
91 native Float:ReadPackFloat(Handle:pack);
94 * Reads a string from a data pack.
96 * @param pack Handle to the data pack.
97 * @param buffer Destination string buffer.
98 * @param maxlen Maximum length of output string buffer.
100 * @error Invalid handle, or bounds error.
102 native ReadPackString(Handle:pack, String:buffer[], maxlen);
105 * Resets the position in a data pack.
107 * @param pack Handle to the data pack.
108 * @param clear If true, clears the contained data.
110 * @error Invalid handle.
112 native ResetPack(Handle:pack, bool:clear=false);
115 * Returns the read or write position in a data pack.
117 * @param pack Handle to the data pack.
118 * @return Numerical position in the data pack.
119 * @error Invalid handle.
121 native GetPackPosition(Handle:pack);
124 * Sets the read/write position in a data pack.
126 * @param pack Handle to the data pack.
127 * @param position New position to set.
129 * @error Invalid handle, or position is beyond the pack bounds.
131 native SetPackPosition(Handle:pack, position);
134 * Returns whether or not a specified number of bytes from the data pack
135 * position to the end can be read.
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.
142 native bool:IsPackReadable(Handle:pack, bytes);