core/CDataPack.h
author Matt Woodrow <pred@alliedmods.net>
Tue Mar 11 23:52:56 2008 +0000 (2008-03-11)
changeset 1921 f993e100e5a3
parent 1330 ab94316bb52b
child 1947 e73a1e51833b
permissions -rw-r--r--
Fixed bug in GetAdjustedTime()
faluco@484
     1
/**
ds@653
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
dvander@1231
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
ds@653
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@1231
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1231
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1231
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
ds@653
    28
 *
ds@653
    29
 * Version: $Id$
ds@653
    30
 */
faluco@484
    31
faluco@484
    32
#ifndef _INCLUDE_SOURCEMOD_CDATAPACK_H_
faluco@484
    33
#define _INCLUDE_SOURCEMOD_CDATAPACK_H_
faluco@484
    34
faluco@484
    35
#include <IDataPack.h>
faluco@484
    36
faluco@484
    37
using namespace SourceMod;
faluco@484
    38
faluco@484
    39
class CDataPack : public IDataPack
faluco@484
    40
{
faluco@484
    41
public:
faluco@484
    42
	CDataPack();
faluco@484
    43
	~CDataPack();
faluco@484
    44
public: //IDataReader
faluco@484
    45
	void Reset() const;
faluco@484
    46
	size_t GetPosition() const;
faluco@484
    47
	bool SetPosition(size_t pos) const;
faluco@484
    48
	cell_t ReadCell() const;
faluco@484
    49
	float ReadFloat() const;
faluco@484
    50
	bool IsReadable(size_t bytes) const;
faluco@484
    51
	const char *ReadString(size_t *len) const;
faluco@484
    52
	void *GetMemory() const;
faluco@488
    53
	void *ReadMemory(size_t *size) const;
faluco@484
    54
public: //IDataPack
faluco@484
    55
	void ResetSize();
faluco@484
    56
	void PackCell(cell_t cell);
faluco@484
    57
	void PackFloat(float val);
faluco@484
    58
	void PackString(const char *string);
faluco@484
    59
	size_t CreateMemory(size_t size, void **addr);
faluco@484
    60
public:
faluco@484
    61
	void Initialize();
faluco@484
    62
private:
faluco@484
    63
	void CheckSize(size_t sizetype);
faluco@484
    64
private:
faluco@484
    65
	char *m_pBase;
faluco@484
    66
	mutable char *m_curptr;
faluco@484
    67
	size_t m_capacity;
faluco@484
    68
	size_t m_size;
faluco@484
    69
};
faluco@484
    70
faluco@485
    71
#endif //_INCLUDE_SOURCEMOD_CDATAPACK_H_