131 &UnmarshalStream::LoadError
145 const uint8 header = Read<uint8>();
147 sLog.Error(
"Unmarshal",
"Invalid stream received (header byte 0x%X).", header );
151 const uint32 saveCount = Read<uint32>();
162 const uint8 header = Read<uint8>();
169 sLog.Warning(
"Unmarshal",
"Encountered flagUnknown in header 0x%X.", header );
175 if( 0 != storageIndex )
226 if(
sizeof(
int32 ) >= len )
229 memcpy( &intval, &*data, len );
231 return new PyInt( intval );
233 else if(
sizeof(
int64 ) >= len )
236 memcpy( &intval, &*data, len );
238 return new PyLong( intval );
244 return new PyBuffer( data, data + len );
252 return new PyString( str, str + 1 );
257 const uint8 len = Read<uint8>();
260 return new PyString( str, str + len );
268 return new PyString( str, str + len );
273 const uint8 index = Read<uint8>();
279 sLog.Error(
"Unmarshal",
"String Table Item %u is out of range!", index );
282 snprintf( ebuf, 64,
"Invalid String Table Item %u", index );
317 return new PyWString( wstr, wstr + len );
322 const uint8 len = Read<uint8>();
325 return new PyToken( str, str + len );
333 return new PyBuffer( data, data + len );
341 for (
uint32 i(0); i < count; ++i ) {
343 if (rep ==
nullptr) {
391 for (
uint32 i(0); i < count; i++ )
423 for (
uint32 i(0); i < count; i++ )
450 sLog.Error(
"Unmarshal",
"Object: Expected 'String' as type, got '%s'.", type->
TypeString() );
457 if( NULL == arguments )
497 const uint32 sum = Read<uint32>();
511 if( NULL == header_element )
519 std::multimap< uint8, uint32, std::greater< uint8 > > sizeMap;
520 std::map<uint8,uint8> booleanColumns;
523 size_t byteDataBitLength = 0;
524 size_t booleansBitLength = 0;
525 size_t nullsBitLength = 0;
527 for (
uint32 i(0); i < columnCount; i++ )
535 booleanColumns.insert (std::make_pair (i, booleansBitLength));
545 byteDataBitLength += size;
548 sizeMap.insert (std::make_pair (size, i));
551 size_t expectedByteSize = (byteDataBitLength >> 3) + ((booleansBitLength + nullsBitLength) >> 3) + 1;
554 Buffer unpacked (expectedByteSize, 0);
565 std::multimap< uint8, uint32, std::greater< uint8 > >::iterator cur, end;
566 cur = sizeMap.begin();
568 for (; cur != end; ++cur)
570 const uint32 index = cur->second;
573 unsigned long nullBit = byteDataBitLength + booleansBitLength + cur->second;
574 unsigned long nullByte = nullBit >> 3;
577 bitIterator = unpacked.
begin<
uint8>() + nullByte;
579 if ((*bitIterator & (1 << (nullBit & 0x7))) == (1 << (nullBit & 0x7)))
659 unsigned long boolBit = byteDataBitLength + booleanColumns.find (index)->second;
660 unsigned long boolByte = boolBit >> 3;
662 bitIterator = unpacked.
begin<
uint8>() + boolByte;
664 row->
SetField (index,
new PyBool ((*bitIterator & (1 << (boolBit & 0x7))) == (1 << (boolBit & 0x7))));
694 sLog.Error(
"Unmarshal",
"Invalid opcode encountered." );
706 sLog.Error(
"Unmarshal",
"SavedStreamElement: Got invalid stored object." );
765 cur = Read<uint8>(in_size );
778 run = (
unsigned char)*in_ix++;
779 count = (run & 0x0f) - 8;
782 count = (run >> 4) - 8;
786 if (out_ix + count + 1 > out.
size())
794 if (out_ix - count > out.
size())
797 while(count++ && in_ix < end)
798 out[out_ix++] = *in_ix++;
PyRep * Load(const Buffer &data)
Loads Python object from given bytecode.
void StoreObject(uint32 index, PyRep *object)
Stores object.
PyRep * LoadStringShort()
PyRep * InflateUnmarshal(const Buffer &data)
Turns possibly inflated marshal stream into Python object.
PyRep * LoadIntegerMinusOne()
DBRowDescriptor * header() const
virtual PyRep * Clone() const =0
Clones object.
uint32 GetStorageIndex()
Obtains storage index for StoreObject.
Buffer::const_iterator< uint8 > mInItr
#define sMarshalStringTable
Python floating point number.
PyRep * GetStoredObject(uint32 index)
Obtains previously stored object.
PyRep * LoadWStringUCS2Char()
static const uint8 PyRepSaveMask
PyRep * LoadIntegerLongLong()
const_iterator< T2 > As() const
Converts const_iterator to another const_iterator with different type.
PyRep * LoadIntegerByte()
PyRep * LoadIntegerZero()
PyRep * LoadStringTable()
PyRep * LoadStringEmpty()
static const uint8 PyRepUnknownMask
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
PyRep * GetItem(size_t index) const
Returns Python object.
#define sLog
Evaluates to a NewLog instance.
DBTYPE GetColumnType(uint32 index) const
Generic class for buffers.
Python object "blue.DBRowDescriptor".
uint32 ColumnCount() const
PyRep * LoadIntegerLong()
void SetItem(size_t index, PyRep *object)
Stores Python object.
bool IsDeflated(const Buffer &data)
Checks whether given data is deflated.
void SetItem(size_t index, PyRep *object)
Stores Python object.
PyRep * LoadWStringUCS2()
PyRep * LoadIntegerSignedShort()
PyRep * LoadWStringEmpty()
PyRep * LoadSavedStreamElement()
PyRep * Unmarshal(const Buffer &data)
Turns marshal stream into Python object.
uint8 DBTYPE_GetSizeBits(DBTYPE type)
bool InflateData(Buffer &data)
Inflates given data.
PyRep * LoadChecksumedStream()
Python token (eg. class name).
Buffer::const_iterator< uint32 > mStoreIndexItr
static const uint8 MarshalHeaderByte
PyObjectEx * LoadObjectEx(bool is_type_2)
void CreateObjectStore(size_t streamLength, uint32 saveCount)
Initializes object store.
bool SetField(uint32 index, PyRep *value)
Class which turns marshal bytecode into Python object.
void DestroyObjectStore()
Destroys object store.
PyRep * LoadStream(size_t streamLength)
static PyRep *(UnmarshalStream::*const s_mLoadMap[])()
PyRep * LoadWStringUTF8()
bool LoadRLE(Buffer &out)
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
std::string utf16to8(std::u16string &str)
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
const char * TypeString() const