EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyDatabase.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Bloody.Rabbit
24  Updates: Allan
25 */
26 
27 #ifndef __PY_DATABASE_H__INCL__
28 #define __PY_DATABASE_H__INCL__
29 
30 #include "database/dbcore.h"
31 #include "python/PyRep.h"
32 
42 : public PyObjectEx_Type1
43 {
44 public:
46 
50  DBRowDescriptor(PyList* keywords);
51 
55  DBRowDescriptor( const DBQueryResult& res );
59  DBRowDescriptor( const DBResultRow& row );
60 
64  uint32 ColumnCount() const;
70  PyString* GetColumnName( uint32 index ) const;
76  DBTYPE GetColumnType( uint32 index ) const;
82  uint32 FindColumn( const char* name ) const;
92  bool VerifyValue( uint32 index, PyRep* value );
93 
100  void AddColumn( const char* name, DBTYPE type );
101 
102 protected:
103  virtual ~DBRowDescriptor() { /* do we need to do anything here? */ }
104  // Helper functions:
105  PyTuple* _GetColumnList() const;
106  PyTuple* _GetColumn(size_t index) const;
107 
108  static PyTuple* _CreateArgs();
109 };
110 
124 class CRowSet
125 : public PyObjectEx_Type2
126 {
127 public:
131  CRowSet( DBRowDescriptor** rowDesc );
132 
136  size_t GetRowCount() const { return list().size(); }
137 
143  PyPackedRow* GetRow( uint32 index ) const { return list().GetItem( index )->AsPackedRow(); }
144 
148  PyPackedRow* NewRow();
149 
150 protected:
151  virtual ~CRowSet() { /* do we need to do anything here? */ }
152  DBRowDescriptor* _GetRowDesc() const;
153  //PyList* _GetColumnList() const;
154 
155  static PyTuple* _CreateArgs();
156  static PyDict* _CreateKeywords(DBRowDescriptor* rowDesc);
157 };
158 
173 : public PyObjectEx_Type2
174 {
175 public:
179  CIndexedRowSet( DBRowDescriptor** rowDesc );
180 
184  size_t GetRowCount() const { return list().size(); }
185 
191  PyPackedRow* GetRow( PyRep* index ) const { return dict().GetItem( index )->AsPackedRow(); }
192 
197 
198 protected:
199  virtual ~CIndexedRowSet() { /* do we need to do anything here? */ }
200  DBRowDescriptor* _GetRowDesc() const;
201  //PyList* _GetColumnList() const;
202 
203  static PyTuple* _CreateArgs();
204  static PyDict* _CreateKeywords(DBRowDescriptor* rowDesc);
205 };
206 
207 
217 : public PyObjectEx_Type2
218 {
219 public:
223  CFilterRowSet( DBRowDescriptor** rowDesc );
224 
228  size_t GetKeyCount() const { return dict().size(); }
229 
230  CRowSet* GetRowset( PyRep *key) const { return (CRowSet*)(dict().GetItem( key )); }
231 
238  const { return GetRowset(key)->GetRow( index )->AsPackedRow(); }
239 
243  CRowSet* NewRowset( PyRep* key );
244 
245 protected:
246  virtual ~CFilterRowSet() { /* do we need to do anything here? */ }
247  DBRowDescriptor* _GetRowDesc() const;
248  //PyList* _GetColumnList() const;
249 
250  static PyTuple* _CreateArgs();
251  static PyDict* _CreateKeywords(DBRowDescriptor* rowDesc);
252 };
253 
254 #endif /* !__PY_DATABASE_H__INCL__ */
Base Python wire object.
Definition: PyRep.h:66
list_type & list()
Definition: PyRep.h:889
DBRowDescriptor * _GetRowDesc() const
Definition: PyDatabase.cpp:245
static PyTuple * _CreateArgs()
Definition: PyDatabase.cpp:158
Python string.
Definition: PyRep.h:430
PyPackedRow * GetRow(PyRep *index) const
Definition: PyDatabase.h:191
Python object "dbutil.CFilterRowset".
Definition: PyDatabase.h:216
Python's dictionary.
Definition: PyRep.h:719
PyPackedRow * GetRow(PyRep *key, uint32 index) const
Definition: PyDatabase.h:237
void AddColumn(const char *name, DBTYPE type)
Definition: PyDatabase.cpp:96
PyTuple * _GetColumn(size_t index) const
Definition: PyDatabase.cpp:109
CRowSet(DBRowDescriptor **rowDesc)
Definition: PyDatabase.cpp:126
CIndexedRowSet(DBRowDescriptor **rowDesc)
Definition: PyDatabase.cpp:185
CRowSet * NewRowset(PyRep *key)
Definition: PyDatabase.cpp:236
CFilterRowSet(DBRowDescriptor **rowDesc)
Definition: PyDatabase.cpp:230
Python tuple.
Definition: PyRep.h:567
PyTuple * _GetColumnList() const
Definition: PyDatabase.cpp:104
PyString * GetColumnName(uint32 index) const
Definition: PyDatabase.cpp:65
static PyTuple * _CreateArgs()
Definition: PyDatabase.cpp:114
PyRep * GetItem(size_t index) const
Returns Python object.
Definition: PyRep.h:674
bool VerifyValue(uint32 index, PyRep *value)
Verifies value for certain column.
Definition: PyDatabase.cpp:91
DBTYPE GetColumnType(uint32 index) const
Definition: PyDatabase.cpp:70
Python object "blue.DBRowDescriptor".
Definition: PyDatabase.h:41
uint32 ColumnCount() const
Definition: PyDatabase.cpp:60
PyRep * GetItem(PyRep *key) const
Obtains a database entry based on given key object.
Definition: PyRep.cpp:691
size_t size() const
Definition: PyRep.h:769
Python object "dbutil.CRowset".
Definition: PyDatabase.h:124
DBTYPE
Definition: dbtype.h:67
PyPackedRow * NewRow(PyRep *key)
Definition: PyDatabase.cpp:191
DBRowDescriptor * _GetRowDesc() const
Definition: PyDatabase.cpp:200
virtual ~CRowSet()
Definition: PyDatabase.h:151
PyPackedRow * AsPackedRow()
Definition: PyRep.h:156
dict_type & dict()
Definition: PyRep.h:892
PyPackedRow * GetRow(uint32 index) const
Definition: PyDatabase.h:143
static PyTuple * _CreateArgs()
Definition: PyDatabase.cpp:208
virtual ~CIndexedRowSet()
Definition: PyDatabase.h:199
unsigned __int32 uint32
Definition: eve-compat.h:50
static PyTuple * _CreateArgs()
Definition: PyDatabase.cpp:253
size_t GetKeyCount() const
Definition: PyDatabase.h:228
CRowSet * GetRowset(PyRep *key) const
Definition: PyDatabase.h:230
Wrapper class for PyObjectEx of type 1.
Definition: PyRep.h:911
virtual ~DBRowDescriptor()
Definition: PyDatabase.h:103
DBRowDescriptor * _GetRowDesc() const
Definition: PyDatabase.cpp:141
static PyDict * _CreateKeywords(DBRowDescriptor *rowDesc)
Definition: PyDatabase.cpp:165
Python object "dbutil.CIndexedRowset".
Definition: PyDatabase.h:172
PyPackedRow * NewRow()
Definition: PyDatabase.cpp:132
static PyDict * _CreateKeywords(DBRowDescriptor *rowDesc)
Definition: PyDatabase.cpp:215
virtual ~CFilterRowSet()
Definition: PyDatabase.h:246
size_t size() const
Definition: PyRep.h:663
Packed row.
Definition: PyRep.h:961
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
uint32 FindColumn(const char *name) const
Definition: PyDatabase.cpp:75
size_t GetRowCount() const
Definition: PyDatabase.h:136
size_t GetRowCount() const
Definition: PyDatabase.h:184
Wrapper class for PyObjectEx of type 2.
Definition: PyRep.h:938
static PyDict * _CreateKeywords(DBRowDescriptor *rowDesc)
Definition: PyDatabase.cpp:260
Python list.
Definition: PyRep.h:639