-
Notifications
You must be signed in to change notification settings - Fork 0
/
LLightResultSet.h
99 lines (85 loc) · 2.42 KB
/
LLightResultSet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* File: LLightResultSet.h
* Author: Saleem Edah-Tally - [email protected]
* License : LGPL version 2.1
* Copyright Saleem Edah-Tally, M. D. - © 2014
*
* Created on 28 mai 2014, 14:40
*/
#ifndef LLIGHTRESULTSET_H
#define LLIGHTRESULTSET_H
/* Added to be able to use derived classes independantly
* If xConnection and xResultSet classes are included in some project,
* the compiler would complain ofan undeclared wxWeakRef.
*/
#include <wx/wx.h>
#include <wx/weakref.h>
#include "LConnection.h"
/**
* An abstract class to scroll through data obtained after running an SQL query.
* Does not interact with GUI controls.
*
* Does not output any messages.
*
* Does not modify data.
*/
class LLightResultSet : public wxTrackable
{
public:
LLightResultSet();
LLightResultSet(LConnection * newConnection);
virtual ~LLightResultSet();
virtual bool SetSQL(const wxString& newSql) = 0;
/**
* Updates the SQL statement without running it.
* @param newSql
*/
void UpdateSQL(const wxString& newSql)
{
m_curSql = newSql;
}
const wxString& GetSQL() const
{
return m_curSql;
}
void SetConnection(LConnection * newConnection)
{
m_conn = newConnection;
}
const LConnection * GetConnection() const
{
return m_conn;
}
virtual bool HasData() const = 0;
virtual bool Absolute(const unsigned int newRowIndex) = 0;
virtual bool IsFirst() const = 0;
virtual bool IsLast() const = 0;
virtual bool First() = 0;
virtual bool Next() = 0;
virtual bool Previous() = 0;
virtual bool Last() = 0;
/**
* Returns the cursor position from 0 to (GetRowCount() - 1).
*
* Returns -1 if there's no data.
*/
const int GetRow() const
{
return m_cursor;
}
virtual const unsigned int GetRowCount() const = 0;
virtual const unsigned int GetColumnCount() const = 0;
virtual const wxString GetColumnName(const unsigned int colIndex) const = 0;
virtual const int GetColumnIndex(const wxString& colName) const = 0;
virtual const wxAny GetData(const wxString& colName) const = 0;
virtual const wxAny GetData(const unsigned int rowIdx, const unsigned int colIdx) const = 0;
protected:
bool m_initialised;
wxString m_curSql;
void * m_rs;
wxWeakRef<LConnection> m_conn;
int m_cursor;
virtual bool RunSQL() = 0;
private:
};
#endif /* LLIGHTRESULTSET_H */