void TestMarshal( const Seperator& cmd ) { const char* cmdName = cmd.arg( 0 ).c_str(); DBRowDescriptor *header = new DBRowDescriptor; // Fill header: header->AddColumn( "historyDate", DBTYPE_FILETIME ); header->AddColumn( "lowPrice", DBTYPE_CY ); header->AddColumn( "highPrice", DBTYPE_CY ); header->AddColumn( "avgPrice", DBTYPE_CY ); header->AddColumn( "volume", DBTYPE_I8 ); header->AddColumn( "orders", DBTYPE_I4 ); CRowSet* rs = new CRowSet( &header ); PyPackedRow* row = rs->NewRow(); row->SetField( "historyDate", new PyLong( Win32TimeNow() ) ); row->SetField( "lowPrice", new PyLong( 18000 ) ); row->SetField( "highPrice", new PyLong( 19000 ) ); row->SetField( "avgPrice", new PyLong( 18400 ) ); row->SetField( "volume", new PyLong( 5463586 ) ); row->SetField( "orders", new PyInt( 254 ) ); sLog.Log( cmdName, "Marshaling..." ); Buffer marshaled; bool res = MarshalDeflate( rs, marshaled ); PyDecRef( rs ); if( !res ) { sLog.Error( cmdName, "Failed to marshal Python object." ); return; } sLog.Log( cmdName, "Unmarshaling..." ); PyRep* rep = InflateUnmarshal( marshaled ); if( NULL == rep ) { sLog.Error( cmdName, "Failed to unmarshal Python object." ); return; } sLog.Success( cmdName, "Final:" ); rep->Dump( stdout, " " ); PyDecRef( rep ); }
void EVETCPConnection::QueueRep( const PyRep* rep ) { Buffer* buf = new Buffer; // make room for length const Buffer::iterator<uint32> bufLen = buf->end<uint32>(); buf->ResizeAt( bufLen, 1 ); if( !MarshalDeflate( rep, *buf ) ) sLog.Error( "Network", "Failed to marshal new packet." ); else if( PACKET_SIZE_LIMIT < buf->size() ) sLog.Error( "Network", "Packet length %u exceeds hardcoded packet length limit %lu.", buf->size(), PACKET_SIZE_LIMIT ); else { // write length *bufLen = ( buf->size() - sizeof( uint32 ) ); Send( &buf ); } SafeDelete( buf ); }
void CachedObjectMgr::UpdateCache(const PyRep *objectID, PyRep **in_cached_data) { PyRep *cached_data = *in_cached_data; *in_cached_data = NULL; //if(is_log_enabled(SERVICE__CACHE_DUMP)) { // PyLogsysDump dumper(SERVICE__CACHE_DUMP, SERVICE__CACHE_DUMP, false, true); //cached_data->visit(&dumper, 0); //} Buffer* data = new Buffer; bool res = MarshalDeflate( cached_data, *data ); PyDecRef( cached_data ); if( res ) { PyBuffer* buf = new PyBuffer( &data ); _UpdateCache( objectID, &buf ); } else { sLog.Error( "Cached Obj Mgr", "Failed to marshal or deflate new cache object." ); } SafeDelete( data ); }