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