ds@1952: /** ds@1952: * vim: set ts=4 : ds@1952: * ============================================================================= ds@1952: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. ds@1952: * ============================================================================= ds@1952: * ds@1952: * This file is part of the SourceMod/SourcePawn SDK. ds@1952: * ds@1952: * This program is free software; you can redistribute it and/or modify it under ds@1952: * the terms of the GNU General Public License, version 3.0, as published by the ds@1952: * Free Software Foundation. ds@1952: * ds@1952: * This program is distributed in the hope that it will be useful, but WITHOUT ds@1952: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ds@1952: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ds@1952: * details. ds@1952: * ds@1952: * You should have received a copy of the GNU General Public License along with ds@1952: * this program. If not, see . ds@1952: * ds@1952: * As a special exception, AlliedModders LLC gives you permission to link the ds@1952: * code of this program (as well as its derivative works) to "Half-Life 2," the ds@1952: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software ds@1952: * by the Valve Corporation. You must obey the GNU General Public License in ds@1952: * all respects for all other code used. Additionally, AlliedModders LLC grants ds@1952: * this exception to all derivative works. AlliedModders LLC defines further ds@1952: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), ds@1952: * or . ds@1952: * ds@1952: * Version: $Id$ ds@1952: */ ds@1952: ds@1952: #if defined _datapack_included ds@1952: #endinput ds@1952: #endif ds@1952: #define _datapack_included ds@1952: ds@1952: /** ds@1952: * Creates a new data pack. ds@1952: * ds@1952: * @return A Handle to the data pack. Must be closed with CloseHandle(). ds@1952: */ ds@1952: native Handle:CreateDataPack(); ds@1952: ds@1952: /** ds@1952: * Packs a normal cell into a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @param cell Cell to add. ds@1952: * @noreturn ds@1952: * @error Invalid handle. ds@1952: */ ds@1952: native WritePackCell(Handle:pack, cell); ds@1952: ds@1952: /** ds@1952: * Packs a float into a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @param val Float to add. ds@1952: * @noreturn ds@1952: * @error Invalid handle. ds@1952: */ ds@1952: native WritePackFloat(Handle:pack, Float:val); ds@1952: ds@1952: /** ds@1952: * Packs a string into a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @param str String to add. ds@1952: * @noreturn ds@1952: * @error Invalid handle. ds@1952: */ ds@1952: native WritePackString(Handle:pack, const String:str[]); ds@1952: ds@1952: /** ds@1952: * Reads a cell from a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @return Cell value. ds@1952: * @error Invalid handle, or bounds error. ds@1952: */ ds@1952: native ReadPackCell(Handle:pack); ds@1952: ds@1952: /** ds@1952: * Reads a float from a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @return Float value. ds@1952: * @error Invalid handle, or bounds error. ds@1952: */ ds@1952: native Float:ReadPackFloat(Handle:pack); ds@1952: ds@1952: /** ds@1952: * Reads a string from a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @param buffer Destination string buffer. ds@1952: * @param maxlen Maximum length of output string buffer. ds@1952: * @noreturn ds@1952: * @error Invalid handle, or bounds error. ds@1952: */ ds@1952: native ReadPackString(Handle:pack, String:buffer[], maxlen); ds@1952: ds@1952: /** ds@1952: * Resets the position in a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @param clear If true, clears the contained data. ds@1952: * @noreturn ds@1952: * @error Invalid handle. ds@1952: */ ds@1952: native ResetPack(Handle:pack, bool:clear=false); ds@1952: ds@1952: /** ds@1952: * Returns the read or write position in a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @return Numerical position in the data pack. ds@1952: * @error Invalid handle. ds@1952: */ ds@1952: native GetPackPosition(Handle:pack); ds@1952: ds@1952: /** ds@1952: * Sets the read/write position in a data pack. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @param position New position to set. ds@1952: * @noreturn ds@1952: * @error Invalid handle, or position is beyond the pack bounds. ds@1952: */ ds@1952: native SetPackPosition(Handle:pack, position); ds@1952: ds@1952: /** ds@1952: * Returns whether or not a specified number of bytes from the data pack ds@1952: * position to the end can be read. ds@1952: * ds@1952: * @param pack Handle to the data pack. ds@1952: * @param bytes Number of bytes to simulate reading. ds@1952: * @return True if can be read, false otherwise. ds@1952: * @error Invalid handle. ds@1952: */ ds@1952: native bool:IsPackReadable(Handle:pack, bytes);