2010-08-11 15:23:10 +02:00
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Reality - The Matrix Online Server Emulator
|
2009-08-18 22:25:37 +00:00
|
|
|
// Copyright (C) 2006-2010 Rajko Stojadinovic
|
2010-08-11 15:23:10 +02:00
|
|
|
// http://mxoemu.info
|
2009-08-18 22:25:37 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
2009-08-18 22:25:37 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
2009-08-18 22:25:37 +00:00
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-08-11 15:23:10 +02:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-08-18 22:25:37 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
2009-08-18 22:25:37 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// ***************************************************************************
|
2009-08-18 22:25:37 +00:00
|
|
|
|
|
|
|
|
#ifndef MXOSIM_BITVARSTREAM_H
|
|
|
|
|
#define MXOSIM_BITVARSTREAM_H
|
|
|
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
|
|
|
|
|
class BitVarStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
class NotEnoughBits : public exception {};
|
|
|
|
|
class DataOverflow : public exception {};
|
|
|
|
|
class InvalidVar : public exception {};
|
|
|
|
|
|
|
|
|
|
BitVarStream();
|
|
|
|
|
~BitVarStream() {}
|
2010-08-12 20:52:47 +02:00
|
|
|
void FromBytes(const byte* dataBuf,const size_t dataLen);
|
|
|
|
|
uint8 ToBytes(byte *rsiDataBytes,const size_t maxLen) const;
|
2009-08-18 22:25:37 +00:00
|
|
|
uint8& operator[] (const string& nameIndex);
|
|
|
|
|
void ClearData();
|
|
|
|
|
protected:
|
|
|
|
|
void ClearVariableDefs();
|
|
|
|
|
void AddVariableDef(const string& name,uint8 numBits);
|
|
|
|
|
void AddSkipBitsDef(uint8 numBits);
|
|
|
|
|
private:
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
string name;
|
|
|
|
|
uint8 numBits;
|
|
|
|
|
} varDef;
|
|
|
|
|
typedef vector<varDef> vectVarDefs;
|
|
|
|
|
vectVarDefs varDefs;
|
|
|
|
|
typedef map<string,uint8> varData;
|
|
|
|
|
varData varValues;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|