-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathSqliteRow.hpp
More file actions
204 lines (177 loc) · 6.71 KB
/
SqliteRow.hpp
File metadata and controls
204 lines (177 loc) · 6.71 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#ifndef AREG_AREGEXTEND_DB_SQLITEROW_HPP
#define AREG_AREGEXTEND_DB_SQLITEROW_HPP
/************************************************************************
* This file is part of the AREG SDK core engine.
* AREG SDK is dual-licensed under Free open source (Apache version 2.0
* License) and Commercial (with various pricing models) licenses, depending
* on the nature of the project (commercial, research, academic or free).
* You should have received a copy of the AREG SDK license description in LICENSE.txt.
* If not, please contact to info[at]aregtech.com
*
* \copyright (c) 2017-2023 Aregtech UG. All rights reserved.
* \file aregextend/db/SqliteRow.hpp
* \author Artak Avetyan
* \ingroup AREG platform, extended library, SQLite row object to get results.
************************************************************************/
/************************************************************************
* Include files.
************************************************************************/
#include "areg/base/GEGlobal.h"
#include "areg/base/String.hpp"
/************************************************************************
* Dependencies
************************************************************************/
class SqliteStatement;
//////////////////////////////////////////////////////////////////////////
// SqliteRow class declaration
//////////////////////////////////////////////////////////////////////////
/**
* \brief Represents a single row of results from a SQLite query.
* Provides access to column values and metadata for the current row.
**/
class SqliteRow
{
//////////////////////////////////////////////////////////////////////////
// Constructors / operators.
//////////////////////////////////////////////////////////////////////////
public:
/**
* \brief Default constructor. Initializes an invalid row.
*/
SqliteRow(void);
/**
* \brief Constructs a SqliteRow from a SqliteStatement.
* \param statement Reference to the SqliteStatement object.
*/
SqliteRow(SqliteStatement& statement);
/**
* \brief Constructs a SqliteRow from a raw statement pointer.
* \param statement Pointer to the underlying SQLite statement.
*/
SqliteRow(void* statement);
/**
* \brief Copy constructor.
* \param src The source SqliteRow to copy from.
*/
SqliteRow(const SqliteRow& src);
/**
* \brief Move constructor.
* \param src The source SqliteRow to move from.
*/
SqliteRow(SqliteRow&& src);
/**
* \brief Destructor. Defaulted.
*/
~SqliteRow(void) = default;
/**
* \brief Copy assignment operator.
* \param src The source SqliteRow to copy from.
* \return Reference to this object.
*/
SqliteRow& operator = (const SqliteRow& src);
/**
* \brief Move assignment operator.
* \param src The source SqliteRow to move from.
* \return Reference to this object.
*/
SqliteRow& operator = (SqliteRow&& src);
//////////////////////////////////////////////////////////////////////////
// Attributes and operations
//////////////////////////////////////////////////////////////////////////
public:
/**
* \brief Checks if the row is valid (i.e., associated with a statement).
* \return True if valid, false otherwise.
*/
inline bool isValid(void) const;
/**
* \brief Retrieves the integer value of the specified column.
* \param column The 0-based column index.
* \return The integer value of the column.
*/
int getInt(int column) const;
/**
* \brief Retrieves the 64-bit integer value of the specified column.
* \param column The 0-based column index.
* \return The 64-bit integer value of the column.
*/
int64_t getInt64(int column) const;
/**
* \brief Retrieves the double value of the specified column.
* \param column The 0-based column index.
* \return The double value of the column.
*/
double getDouble(int column) const;
/**
* \brief Retrieves the text value of the specified column.
* \param column The 0-based column index.
* \return The string value of the column.
*/
String getText(int column) const;
/**
* \brief Checks if the specified column is NULL.
* \param column The 0-based column index.
* \return True if the column is NULL, false otherwise.
*/
bool isNull(int column) const;
/**
* \brief Checks if the specified column index is valid.
* \param column The 0-based column index.
* \return True if the column index is valid, false otherwise.
*/
bool isColumnValid(int column) const;
/**
* \brief Checks if the specified column contains a string value.
* \param column The 0-based column index.
* \return True if the column is a string, false otherwise.
*/
bool isString(int column) const;
/**
* \brief Checks if the specified column contains a 32-bit integer value.
* \param column The 0-based column index.
* \return True if the column is a 32-bit integer, false otherwise.
*/
bool isInteger(int column) const;
/**
* \brief Checks if the specified column contains a 64-bit integer value.
* \param column The 0-based column index.
* \return True if the column is a 64-bit integer, false otherwise.
*/
bool isInteger64(int column) const;
/**
* \brief Checks if the specified column contains a double value.
* \param column The 0-based column index.
* \return True if the column is a double, false otherwise.
*/
bool isDouble(int column) const;
/**
* \brief Returns the number of columns in the row.
* \return The number of columns.
*/
int getColumnCount(void) const;
/**
* \brief Returns the name of the specified column.
* \param column The 0-based column index.
* \return The name of the column.
*/
String getColumnName(int column) const;
/**
* \brief Returns the index of the column with the specified name.
* \param columnName The name of the column.
* \return The 0-based index of the column, or -1 if not found.
*/
int getColumnIndex(const String& columnName) const;
//////////////////////////////////////////////////////////////////////////
// Member variables
//////////////////////////////////////////////////////////////////////////
protected:
/**
* \brief Pointer to the underlying SQLite statement.
*/
void* mStatement;
};
inline bool SqliteRow::isValid(void) const
{
return (mStatement != nullptr);
}
#endif // AREG_AREGEXTEND_DB_SQLITEROW_HPP