libcommonc++  0.7
SQLQuery.h++
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------
2  commonc++ - A C++ Common Class Library
3  Copyright (C) 2005-2014 Mark A Lindner
4 
5  This file is part of commonc++.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public
18  License along with this library; if not, write to the Free
19  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  ---------------------------------------------------------------------------
21 */
22 
23 #ifndef __ccxx_SQLQuery_hxx
24 #define __ccxx_SQLQuery_hxx
25 
26 #include <commonc++/Common.h++>
27 #include <commonc++/Blob.h++>
30 #include <commonc++/String.h++>
31 #include <commonc++/Variant.h++>
32 
33 namespace ccxx {
34 
35 class SQLDatabase; // fwd decl
36 class SQLPrivate; // fwd decl
37 
58 {
59  friend class SQLDatabase;
60 
61  public:
62 
64  ~SQLQuery();
65 
71  void reset();
72 
79  String toSQL();
80 
88  void bind(uint_t index);
89 
96  void bind(const String& name);
97 
106  void bind(uint_t index, int value);
107 
115  void bind(const String& name, int value);
116 
126  void bind(uint_t index, const int64_t& value);
127 
136  void bind(const String& name, const int64_t& value);
137 
147  void bind(uint_t index, const double& value);
148 
157  void bind(const String& name, const double& value);
158 
167  void bind(uint_t index, const String& value);
168 
176  void bind(const String& name, const String& value);
177 
186  void bind(uint_t index, const char* value);
187 
195  void bind(const String& name, const char* value);
196 
205  void bind(uint_t index, const Blob& value);
206 
214  void bind(const String& name, const Blob& value);
215 
221  void clear();
222 
228  uint_t getParameterCount();
229 
237  void execute();
238 
250  bool next();
251 
258  uint_t getColumnCount();
259 
268  Variant getColumnValue(uint_t column);
269 
277  String getColumnName(uint_t column);
278 
286  String getAliasedColumnName(uint_t column);
287 
295  String getTableName(uint_t column);
296 
305  int getInt(uint_t column);
306 
315  int64_t getInt64(uint_t column);
316 
325  double getDouble(uint_t column);
326 
335  String getString(uint_t column);
336 
345  Blob getBlob(uint_t column);
346 
347  private:
348 
349  SQLQuery(const SQLPrivate& private_);
350 
351  void prime();
352  void _next();
353 
354  String _getString(uint_t column);
355  Blob _getBlob(uint_t column);
356 
357  SQLPrivate* _private;
358  int _result;
359  bool _primed;
360  bool _hasData;
361 
363 };
364 
365 } // namespace ccxx
366 
367 #endif // __ccxx_SQLQuery_hxx
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
An SQL prepared statement that can be efficiently executed multiple times.
Definition: SQLQuery.h++:57
A class representing a session with an embedded SQL database.
Definition: SQLDatabase.h++:43
A general-purpose variant type.
Definition: Variant.h++:46
A reference-counting, copy-on-write, threadsafe container for arbitrary binary data.
Definition: Blob.h++:45
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
#define CCXX_COPY_DECLS(CLASS)
Inlines declarations of a copy constructor and assignment operator for the class CLASS.
Definition: Common.h++:295
Definition: AllocationMap.c++:25
#define COMMONCPPDB_API
Definition: Common.h++:127