EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EVEMarshalTest.cpp File Reference
#include "eve-test.h"
Include dependency graph for EVEMarshalTest.cpp:

Go to the source code of this file.

Functions

int marshal_EVEMarshalTest (int argc, char *argv[])
 

Function Documentation

int marshal_EVEMarshalTest ( int  argc,
char *  argv[] 
)

Definition at line 28 of file EVEMarshalTest.cpp.

References DBRowDescriptor::AddColumn(), DBTYPE_CY, DBTYPE_FILETIME, DBTYPE_I4, DBTYPE_I8, PyRep::Dump(), InflateUnmarshal(), MarshalDeflate(), CRowSet::NewRow(), PyDecRef, PyPackedRow::SetField(), and Win32TimeNow().

29 {
30  DBRowDescriptor *header = new DBRowDescriptor;
31  // Fill header:
32  header->AddColumn( "historyDate", DBTYPE_FILETIME );
33  header->AddColumn( "lowPrice", DBTYPE_CY );
34  header->AddColumn( "highPrice", DBTYPE_CY );
35  header->AddColumn( "avgPrice", DBTYPE_CY );
36  header->AddColumn( "volume", DBTYPE_I8 );
37  header->AddColumn( "orders", DBTYPE_I4 );
38 
39  CRowSet* rs = new CRowSet( &header );
40 
41  PyPackedRow* row = rs->NewRow();
42  row->SetField( "historyDate", new PyLong( Win32TimeNow() ) );
43  row->SetField( "lowPrice", new PyLong( 18000 ) );
44  row->SetField( "highPrice", new PyLong( 19000 ) );
45  row->SetField( "avgPrice", new PyLong( 18400 ) );
46  row->SetField( "volume", new PyLong( 5463586 ) );
47  row->SetField( "orders", new PyInt( 254 ) );
48 
49  ::puts( "Marshaling..." );
50 
51  Buffer marshaled;
52  bool res = MarshalDeflate( rs, marshaled );
53  PyDecRef( rs );
54 
55  if( !res )
56  {
57  ::puts( "Failed to marshal Python object." );
58  return EXIT_FAILURE;
59  }
60 
61  ::puts( "Unmarshaling..." );
62 
63  PyRep* rep = InflateUnmarshal( marshaled );
64  if( NULL == rep )
65  {
66  ::puts( "Failed to unmarshal Python object." );
67  return EXIT_FAILURE;
68  }
69 
70  ::puts( "Final:" );
71  rep->Dump( stdout, " " );
72  PyDecRef( rep );
73 
74  return EXIT_SUCCESS;
75 }
Base Python wire object.
Definition: PyRep.h:66
bool MarshalDeflate(const PyRep *rep, Buffer &into, const uint32 deflationLimit)
Definition: EVEMarshal.cpp:44
PyRep * InflateUnmarshal(const Buffer &data)
Turns possibly inflated marshal stream into Python object.
void AddColumn(const char *name, DBTYPE type)
Definition: PyDatabase.cpp:96
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
Generic class for buffers.
Definition: Buffer.h:40
Python object "blue.DBRowDescriptor".
Definition: PyDatabase.h:41
Python object "dbutil.CRowset".
Definition: PyDatabase.h:124
Python integer.
Definition: PyRep.h:231
int64 Win32TimeNow()
Definition: utils_time.cpp:70
#define PyDecRef(op)
Definition: PyRep.h:57
bool SetField(uint32 index, PyRep *value)
Definition: PyRep.cpp:1031
PyPackedRow * NewRow()
Definition: PyDatabase.cpp:132
Packed row.
Definition: PyRep.h:961
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function: