EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LiveUpdateDB Class Reference

#include "LiveUpdateDB.h"

Inheritance diagram for LiveUpdateDB:
Collaboration diagram for LiveUpdateDB:

Public Member Functions

PyListGetUpdates ()
 
- Public Member Functions inherited from Singleton< LiveUpdateDB >
 Singleton ()
 Primary constructor. More...
 

Private Member Functions

PyListGenerateUpdates ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< LiveUpdateDB >
static LiveUpdateDBget ()
 
- Static Protected Attributes inherited from Singleton< LiveUpdateDB >
static std::shared_ptr
< LiveUpdateDB
mInstance
 

Detailed Description

Definition at line 33 of file LiveUpdateDB.h.

Member Function Documentation

PyList * LiveUpdateDB::GenerateUpdates ( )
private

Definition at line 30 of file LiveUpdateDB.cpp.

References DBRowDescriptor::AddColumn(), DBerror::c_str(), codelog, DBResultRow::ColumnLength(), DBColumnToPyRep(), DBTYPE_I4, DBTYPE_STR, DBTYPE_WSTR, PyRep::Dump(), DBQueryResult::error, DBQueryResult::GetRow(), DBQueryResult::GetRowCount(), DBResultRow::GetText(), sDatabase, PyPackedRow::SetField(), and PyList::SetItem().

Referenced by GetUpdates().

31 {
32  const char* query = "SELECT"
33  " updateID,"
34  " updateName,"
35  " description,"
36  " machoVersionMin,"
37  " machoVersionMax,"
38  " buildNumberMin," //5
39  " buildNumberMax,"
40  " methodName,"
41  " objectID,"
42  " codeType,"
43  " code" //10
44  " FROM liveupdates";
45  DBQueryResult res;
46 
47  if (!sDatabase.RunQuery(res, query))
48  {
49  codelog(DATABASE__ERROR, "Couldn't get live updates from database: %s", res.error.c_str());
50  return nullptr;
51  }
52 
53  // setup the descriptor
54  DBRowDescriptor* header = new DBRowDescriptor();
55  header->AddColumn("updateID", DBTYPE_I4);
56  header->AddColumn("updateName", DBTYPE_WSTR);
57  header->AddColumn("description", DBTYPE_WSTR);
58  header->AddColumn("machoVersionMin", DBTYPE_I4);
59  header->AddColumn("machoVersionMax", DBTYPE_I4);
60  header->AddColumn("buildNumberMin", DBTYPE_I4);
61  header->AddColumn("buildNumberMax", DBTYPE_I4);
62  header->AddColumn("code", DBTYPE_STR);
63 
64  // we need to manually create PyPackedRows since we don't want everything from the query in them
65  PyList* list = new PyList(res.GetRowCount());
66  int listIndex = 0;
67  DBResultRow row;
68  while (res.GetRow(row))
69  {
70  PyPackedRow* packedRow = new PyPackedRow(header);
71  for (int i = 0; i < 7; i++)
72  packedRow->SetField(i, DBColumnToPyRep(row, i));
73 
74  LiveUpdateInner inner;
75  // binary data so we can't expect strlen to get it right
76  inner.code = std::string(row.GetText(10), row.ColumnLength(10));
77  inner.codeType = row.GetText(9);
78  inner.objectID = row.GetText(8);
79  inner.methodName = row.GetText(7);
80  packedRow->SetField(static_cast<uint32>(7) /* code */, inner.Encode());
81 
82  list->SetItem(listIndex++, packedRow);
83  }
84  list->Dump(NET__PRES_DEBUG, " ");
85 
86  return list;
87 }
#define sDatabase
Definition: dbcore.h:199
uint32 ColumnLength(uint32 index) const
Definition: dbcore.cpp:624
const char * GetText(uint32 index) const
Definition: dbcore.h:104
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
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
Python object "blue.DBRowDescriptor".
Definition: PyDatabase.h:41
#define codelog(type, fmt,...)
Definition: logsys.h:128
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:682
DBerror error
Definition: dbcore.h:69
bool SetField(uint32 index, PyRep *value)
Definition: PyRep.cpp:1031
size_t GetRowCount()
Definition: dbcore.h:72
Packed row.
Definition: PyRep.h:961
Python list.
Definition: PyRep.h:639
PyRep * DBColumnToPyRep(const DBResultRow &row, uint32 index)
Definition: EVEDBUtils.cpp:36

Here is the call graph for this function:

Here is the caller graph for this function:

PyList* LiveUpdateDB::GetUpdates ( )
inline

Definition at line 41 of file LiveUpdateDB.h.

References GenerateUpdates().

42  {
43  return GenerateUpdates();
44  }
PyList * GenerateUpdates()

Here is the call graph for this function:


The documentation for this class was generated from the following files: