~ubuntu-branches/ubuntu/trusty/libgdamm5.0/trusty

« back to all changes in this revision

Viewing changes to libgda/libgdamm/connection.h

  • Committer: Package Import Robot
  • Author(s): Daniel Holbach
  • Date: 2012-02-07 16:44:36 UTC
  • Revision ID: package-import@ubuntu.com-20120207164436-j1odzs6zz6gz2vae
Tags: upstream-4.99.6
ImportĀ upstreamĀ versionĀ 4.99.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
// Generated by gtkmmproc -- DO NOT MODIFY!
 
3
#ifndef _LIBGDAMM_CONNECTION_H
 
4
#define _LIBGDAMM_CONNECTION_H
 
5
 
 
6
 
 
7
#include <glibmm/ustring.h>
 
8
#include <sigc++/sigc++.h>
 
9
 
 
10
/* $Id: connection.hg,v 1.35 2006/11/30 06:58:55 murrayc Exp $ */
 
11
// -*- C++ -*- //
 
12
 
 
13
/* connection.h
 
14
 *
 
15
 * Copyright 2003 libgdamm Development Team
 
16
 *
 
17
 * This library is free software; you can redistribute it and/or
 
18
 * modify it under the terms of the GNU Lesser General Public
 
19
 * License as published by the Free Software Foundation; either
 
20
 * version 2.1 of the License, or (at your option) any later version.
 
21
 *
 
22
 * This library is distributed in the hope that it will be useful,
 
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
25
 * Lesser General Public License for more details.
 
26
 *
 
27
 * You should have received a copy of the GNU Lesser General Public
 
28
 * License along with this library; if not, write to the Free
 
29
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
30
 */
 
31
 
 
32
#include <libgdamm/transactionstatus.h>
 
33
#include <libgdamm/connectionevent.h>
 
34
#include <libgdamm/datamodel.h>
 
35
#include <libgdamm/statement.h>
 
36
#include <libgdamm/sqlbuilder.h>
 
37
#include <libgdamm/sqlparser.h>
 
38
#include <libgdamm/serveroperation.h>
 
39
#include <libgdamm/serverprovider.h> //For ServerProviderError, sometimes thrown by *execute*().
 
40
#include <libgdamm/value.h>
 
41
 
 
42
 
 
43
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
44
typedef struct _GdaConnection GdaConnection;
 
45
typedef struct _GdaConnectionClass GdaConnectionClass;
 
46
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
47
 
 
48
 
 
49
namespace Gnome
 
50
{
 
51
 
 
52
namespace Gda
 
53
{ class Connection_Class; } // namespace Gda
 
54
 
 
55
} // namespace Gnome
 
56
namespace Gnome
 
57
{
 
58
 
 
59
namespace Gda
 
60
{
 
61
 
 
62
class ServerProvider;
 
63
class MetaStore;
 
64
typedef GdaServerProviderInfo ServerProviderInfo;
 
65
 
 
66
/** Exception class for Gda connection errors.
 
67
 */
 
68
class ConnectionError : public Glib::Error
 
69
{
 
70
public:
 
71
  enum Code
 
72
  {
 
73
    CONNECTION_DSN_NOT_FOUND_ERROR,
 
74
    CONNECTION_PROVIDER_NOT_FOUND_ERROR,
 
75
    CONNECTION_PROVIDER_ERROR,
 
76
    CONNECTION_NO_CNC_SPEC_ERROR,
 
77
    CONNECTION_NO_PROVIDER_SPEC_ERROR,
 
78
    CONNECTION_OPEN_ERROR,
 
79
    CONNECTION_STATEMENT_TYPE_ERROR,
 
80
    CONNECTION_CANT_LOCK_ERROR,
 
81
    CONNECTION_TASK_NOT_FOUND_ERROR,
 
82
    CONNECTION_UNSUPPORTED_THREADS_ERROR,
 
83
    CONNECTION_CLOSED_ERROR,
 
84
    CONNECTION_META_DATA_CONTEXT_ERROR
 
85
  };
 
86
 
 
87
  ConnectionError(Code error_code, const Glib::ustring& error_message);
 
88
  explicit ConnectionError(GError* gobject);
 
89
  Code code() const;
 
90
 
 
91
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
92
private:
 
93
 
 
94
  static void throw_func(GError* gobject);
 
95
 
 
96
  friend void wrap_init(); // uses throw_func()
 
97
 
 
98
  #endif //DOXYGEN_SHOULD_SKIP_THIS
 
99
};
 
100
 
 
101
} // namespace Gda
 
102
 
 
103
} // namespace Gnome
 
104
 
 
105
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
106
namespace Glib
 
107
{
 
108
 
 
109
template <>
 
110
class Value<Gnome::Gda::ConnectionError::Code> : public Glib::Value_Enum<Gnome::Gda::ConnectionError::Code>
 
111
{
 
112
public:
 
113
  static GType value_type() G_GNUC_CONST;
 
114
};
 
115
 
 
116
} // namespace Glib
 
117
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
118
 
 
119
 
 
120
namespace Gnome
 
121
{
 
122
 
 
123
namespace Gda
 
124
{
 
125
 
 
126
 
 
127
/** @addtogroup libgdammEnums libgdamm Enums and Flags */
 
128
 
 
129
/**
 
130
 * @ingroup libgdammEnums
 
131
 * @par Bitwise operators:
 
132
 * <tt>%ConnectionOptions operator|(ConnectionOptions, ConnectionOptions)</tt><br>
 
133
 * <tt>%ConnectionOptions operator&(ConnectionOptions, ConnectionOptions)</tt><br>
 
134
 * <tt>%ConnectionOptions operator^(ConnectionOptions, ConnectionOptions)</tt><br>
 
135
 * <tt>%ConnectionOptions operator~(ConnectionOptions)</tt><br>
 
136
 * <tt>%ConnectionOptions& operator|=(ConnectionOptions&, ConnectionOptions)</tt><br>
 
137
 * <tt>%ConnectionOptions& operator&=(ConnectionOptions&, ConnectionOptions)</tt><br>
 
138
 * <tt>%ConnectionOptions& operator^=(ConnectionOptions&, ConnectionOptions)</tt><br>
 
139
 */
 
140
enum ConnectionOptions
 
141
{
 
142
  CONNECTION_OPTIONS_NONE = 0x0,
 
143
  CONNECTION_OPTIONS_READ_ONLY = 1 << 0,
 
144
  CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE = 1 << 1,
 
145
  CONNECTION_OPTIONS_THREAD_SAFE = 1 << 2,
 
146
  CONNECTION_OPTIONS_THREAD_ISOLATED = 1 << 3,
 
147
  CONNECTION_OPTIONS_AUTO_META_DATA = 1 << 4
 
148
};
 
149
 
 
150
/** @ingroup libgdammEnums */
 
151
inline ConnectionOptions operator|(ConnectionOptions lhs, ConnectionOptions rhs)
 
152
  { return static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
 
153
 
 
154
/** @ingroup libgdammEnums */
 
155
inline ConnectionOptions operator&(ConnectionOptions lhs, ConnectionOptions rhs)
 
156
  { return static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
 
157
 
 
158
/** @ingroup libgdammEnums */
 
159
inline ConnectionOptions operator^(ConnectionOptions lhs, ConnectionOptions rhs)
 
160
  { return static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
 
161
 
 
162
/** @ingroup libgdammEnums */
 
163
inline ConnectionOptions operator~(ConnectionOptions flags)
 
164
  { return static_cast<ConnectionOptions>(~static_cast<unsigned>(flags)); }
 
165
 
 
166
/** @ingroup libgdammEnums */
 
167
inline ConnectionOptions& operator|=(ConnectionOptions& lhs, ConnectionOptions rhs)
 
168
  { return (lhs = static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
 
169
 
 
170
/** @ingroup libgdammEnums */
 
171
inline ConnectionOptions& operator&=(ConnectionOptions& lhs, ConnectionOptions rhs)
 
172
  { return (lhs = static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
 
173
 
 
174
/** @ingroup libgdammEnums */
 
175
inline ConnectionOptions& operator^=(ConnectionOptions& lhs, ConnectionOptions rhs)
 
176
  { return (lhs = static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
 
177
 
 
178
} // namespace Gda
 
179
 
 
180
} // namespace Gnome
 
181
 
 
182
 
 
183
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
184
namespace Glib
 
185
{
 
186
 
 
187
template <>
 
188
class Value<Gnome::Gda::ConnectionOptions> : public Glib::Value_Flags<Gnome::Gda::ConnectionOptions>
 
189
{
 
190
public:
 
191
  static GType value_type() G_GNUC_CONST;
 
192
};
 
193
 
 
194
} // namespace Glib
 
195
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
196
 
 
197
 
 
198
namespace Gnome
 
199
{
 
200
 
 
201
namespace Gda
 
202
{
 
203
 
 
204
/**
 
205
 * @ingroup libgdammEnums
 
206
 */
 
207
enum ConnectionMetaType
 
208
{
 
209
  CONNECTION_META_NAMESPACES,
 
210
  CONNECTION_META_TYPES,
 
211
  CONNECTION_META_TABLES,
 
212
  CONNECTION_META_VIEWS,
 
213
  CONNECTION_META_FIELDS,
 
214
  CONNECTION_META_INDEXES
 
215
};
 
216
 
 
217
} // namespace Gda
 
218
 
 
219
} // namespace Gnome
 
220
 
 
221
 
 
222
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
223
namespace Glib
 
224
{
 
225
 
 
226
template <>
 
227
class Value<Gnome::Gda::ConnectionMetaType> : public Glib::Value_Enum<Gnome::Gda::ConnectionMetaType>
 
228
{
 
229
public:
 
230
  static GType value_type() G_GNUC_CONST;
 
231
};
 
232
 
 
233
} // namespace Glib
 
234
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
235
 
 
236
 
 
237
namespace Gnome
 
238
{
 
239
 
 
240
namespace Gda
 
241
{
 
242
 
 
243
 
 
244
/** Manages a connection to a data source.
 
245
 * This class offers access to all operations involving an opened connection to a database.
 
246
 * Connection objects are obtained via the Client class.
 
247
 *
 
248
 * Once obtained, applications can use a Connection to execute commands, run transactions, and get information about all
 
249
 * objects stored in the underlying database.
 
250
 *
 
251
 * @ingroup Connections
 
252
 */
 
253
 
 
254
class Connection : public Glib::Object
 
255
{
 
256
  
 
257
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
258
 
 
259
public:
 
260
  typedef Connection CppObjectType;
 
261
  typedef Connection_Class CppClassType;
 
262
  typedef GdaConnection BaseObjectType;
 
263
  typedef GdaConnectionClass BaseClassType;
 
264
 
 
265
private:  friend class Connection_Class;
 
266
  static CppClassType connection_class_;
 
267
 
 
268
private:
 
269
  // noncopyable
 
270
  Connection(const Connection&);
 
271
  Connection& operator=(const Connection&);
 
272
 
 
273
protected:
 
274
  explicit Connection(const Glib::ConstructParams& construct_params);
 
275
  explicit Connection(GdaConnection* castitem);
 
276
 
 
277
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
278
 
 
279
public:
 
280
  virtual ~Connection();
 
281
 
 
282
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
283
  static GType get_type()      G_GNUC_CONST;
 
284
 
 
285
 
 
286
  static GType get_base_type() G_GNUC_CONST;
 
287
#endif
 
288
 
 
289
  ///Provides access to the underlying C GObject.
 
290
  GdaConnection*       gobj()       { return reinterpret_cast<GdaConnection*>(gobject_); }
 
291
 
 
292
  ///Provides access to the underlying C GObject.
 
293
  const GdaConnection* gobj() const { return reinterpret_cast<GdaConnection*>(gobject_); }
 
294
 
 
295
  ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
296
  GdaConnection* gobj_copy();
 
297
 
 
298
private:
 
299
 
 
300
protected:
 
301
 
 
302
  Connection();
 
303
  
 
304
 
 
305
public:
 
306
  
 
307
  static Glib::RefPtr<Connection> create();
 
308
 
 
309
 
 
310
  static Glib::RefPtr<Connection> create_from_string(const Glib::ustring& provider_name, const Glib::ustring& cnc_string, const Glib::ustring& auth_string =  Glib::ustring(), ConnectionOptions options =  CONNECTION_OPTIONS_NONE);
 
311
 
 
312
  /* This throws an error which we don't want to do in a constructor */
 
313
  
 
314
  /** Opens a connection given a provider ID and a connection string. This
 
315
   * allows applications to open connections without having to create
 
316
   * a data source (DSN) in the configuration. The format of @a cnc_string is
 
317
   * similar to PostgreSQL and MySQL connection strings. It is a semicolumn-separated
 
318
   * series of <key>=<value> pairs, where each key and value are encoded as per RFC 1738, 
 
319
   * see gda_rfc1738_encode() for more information.
 
320
   * 
 
321
   * The possible keys depend on the provider, the "gda-sql-4.0 -L" command
 
322
   * can be used to list the actual keys for each installed database provider.
 
323
   * 
 
324
   * For example the connection string to open an SQLite connection to a database
 
325
   * file named "my_data.db" in the current directory would be <tt>"DB_DIR=.;DB_NAME=my_data"</tt>.
 
326
   * 
 
327
   * The @a cnc_string string must have the following format: 
 
328
   * "[<provider>://][<username>[:<password>]@]<connection_params>"
 
329
   * (if <username> and/or <password> are provided, and @a auth_string is <tt>0</tt>, then these username
 
330
   * and passwords will be used, and if <provider> is provided and @a provider_name is <tt>0</tt> then this
 
331
   * provider will be used). Note that if provided, <username>, <password> and  <provider>
 
332
   * must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.
 
333
   * 
 
334
   * The @a auth_string must contain the authentication information for the server
 
335
   * to accept the connection. It is a string containing semi-colon seperated named values, usually 
 
336
   * like "USERNAME=...;PASSWORD=..." where the ... are replaced by actual values. Note that each
 
337
   * name and value must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.
 
338
   * 
 
339
   * The actual named parameters required depend on the provider being used, and that list is available
 
340
   * as the <parameter>auth_params</parameter> member of the Gda::ProviderInfo structure for each installed
 
341
   * provider (use Gda::Config::get_provider_info() to get it). Similarly to the format of the connection
 
342
   * string, use the "gda-sql-4.0 -L" command to list the possible named parameters.
 
343
   * 
 
344
   * Additionally, it is possible to have the connection string
 
345
   * respect the "<provider_name>://<real cnc string>" format, in which case the provider name
 
346
   * and the real connection string will be extracted from that string (note that if @a provider_name
 
347
   * is not <tt>0</tt> then it will still be used as the provider ID).\
 
348
   * 
 
349
   * This method may fail with a GDA_CONNECTION_ERROR domain error (see the Gda::ConnectionError error codes) 
 
350
   * or a Gda::CONFIG_ERROR domain error (see the Gda::ConfigError error codes).
 
351
   * @param provider_name Provider ID to connect to, or <tt>0</tt>.
 
352
   * @param cnc_string Connection string.
 
353
   * @param auth_string Authentication string, or <tt>0</tt>.
 
354
   * @param options Options for the connection (see Gda::ConnectionOptions).
 
355
   * @return A new Gda::Connection if connection opening was sucessfull or <tt>0</tt> if there was an error.
 
356
   */
 
357
 
 
358
  static Glib::RefPtr<Connection> open_from_string(const Glib::ustring& provider_name,
 
359
                                                    const Glib::ustring& cnc_string,
 
360
                                                    const Glib::ustring& auth_string = Glib::ustring(),
 
361
                                                    ConnectionOptions options = CONNECTION_OPTIONS_NONE);
 
362
 
 
363
  
 
364
  /** Tries to open the connection.
 
365
   * @return <tt>true</tt> if the connection is opened, and <tt>false</tt> otherwise.
 
366
   */
 
367
  bool open();
 
368
 
 
369
  /** Closes the connection to the underlying data source, but first emits the "conn_to_close" signal.
 
370
   */
 
371
  void close();
 
372
  
 
373
 
 
374
  /** Checks whether a connection is open or not.
 
375
   * @return <tt>true</tt> if the connection is open, <tt>false</tt> if it's not.
 
376
   */
 
377
  bool is_opened() const;
 
378
 
 
379
  
 
380
  /** Gets the Gda::ConnectionOptions used to open this connection.
 
381
   * @return The connection options.
 
382
   */
 
383
  ConnectionOptions get_options() const;
 
384
 
 
385
  
 
386
  /** 
 
387
   * @return The data source name the connection object is connected
 
388
   * to.
 
389
   */
 
390
  Glib::ustring get_dsn() const;
 
391
  
 
392
  /** Gets the connection string used to open this connection.
 
393
   * 
 
394
   * The connection string is the string sent over to the underlying
 
395
   * database provider, which describes the parameters to be used
 
396
   * to open a connection on the underlying data source.
 
397
   * @return The connection string used when opening the connection.
 
398
   */
 
399
  Glib::ustring get_cnc_string() const;
 
400
 
 
401
  
 
402
  /** This function lets you clear the list of Gda::ConnectionEvent's of the
 
403
   * given connection.
 
404
   */
 
405
  void clear_events_list();
 
406
 
 
407
  
 
408
  /** Executes @a stmt. 
 
409
   * 
 
410
   * As @a stmt can, by desing (and if not abused), contain only one SQL statement, the
 
411
   * return object will either be:
 
412
   * <itemizedlist>
 
413
   * <listitem>a Gda::DataSelect object (which is also a Gda::DataModel) if @a stmt is a SELECT statement 
 
414
   * (usually a GDA_SQL_STATEMENT_SELECT, see Gda::SqlStatementType)
 
415
   * containing the results of the SELECT. The resulting data model is by default read only, but
 
416
   * modifications can be enabled, see the Gda::DataSelect's documentation for more information.</listitem>
 
417
   * <listitem>a Gda::Set for any other SQL statement which correctly executed. In this case
 
418
   * (if the provider supports it), then the Gda::Set may contain value holders named:
 
419
   * <itemizedlist>
 
420
   * <listitem>a (<tt>int</tt>) Gda::Holder named "IMPACTED_ROWS"</listitem>
 
421
   * <listitem>a (GObject) Gda::Holder named "EVENT" which contains a Gda::ConnectionEvent</listitem>
 
422
   * </itemizedlist></listitem>
 
423
   * </itemizedlist>
 
424
   * 
 
425
   * If @a last_insert_row is not <tt>0</tt> and @a stmt is an INSERT statement, then it will contain (if the
 
426
   * provider used by @a cnc supports it) a new Gda::Set object composed of value holders named "+<column number>"
 
427
   * starting at column 0 which contain the actual inserted values. For example if a table is composed of an 'id' column
 
428
   * which is auto incremented and a 'name' column then the execution of a "INSERT INTO mytable (name) VALUES ('joe')"
 
429
   * query will return a Gda::Set with two holders:
 
430
   * <itemizedlist>
 
431
   * <listitem>one with the '+0' ID which may for example contain 1 (note that its "name" property should be "id")</listitem>
 
432
   * <listitem>one with the '+1' ID which will contain 'joe' (note that its "name" property should be "name")</listitem>
 
433
   * </itemizedlist>
 
434
   * 
 
435
   * This method may fail with a Gda::SERVER_PROVIDER_ERROR domain error (see the Gda::ServerProviderError error codes).
 
436
   * 
 
437
   * @note If @a stmt is a SELECT statement which has some parameters and  if @params is <tt>0</tt>, then the statement can't
 
438
   * be executed and this method will return <tt>0</tt>.
 
439
   * 
 
440
   * @note If @a stmt is a SELECT statement which has some parameters and  if @params is not <tt>0</tt> but contains some
 
441
   * invalid parameters, then the statement can't be executed and this method will return <tt>0</tt>, unless the
 
442
   *  @a model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag.
 
443
   * 
 
444
   * @note If @a stmt is a SELECT statement which has some parameters and  if @params is not <tt>0</tt> but contains some
 
445
   * invalid parameters and if @a model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag, then the returned
 
446
   * data model will contain no row but will have all the correct columns (even though some of the columns might
 
447
   * report as GDA_TYPE_<tt>0</tt>). In this case, if (after this method call) any of @params' parameters change
 
448
   * then the resulting data model will re-run itself, see the GdaDataSelect's 
 
449
   * auto-reset property for more information.
 
450
   * 
 
451
   * @note if @a model_usage does not contain the GDA_STATEMENT_MODEL_RANDOM_ACCESS or
 
452
   * GDA_STATEMENT_MODEL_CURSOR_FORWARD flags, then the default will be to return a random access data model
 
453
   * 
 
454
   * @note If @a stmt is a SELECT statement which returns blob values (of type Gda::TYPE_BLOB), then an implicit
 
455
   * transaction will have been started by the database provider, and it's up to the caller to close the transaction
 
456
   * (which will then be locked) once all the blob ressources have been
 
457
   * liberated (when the returned data model is destroyed). See the section about
 
458
   * Binary large objects (BLOBs) for more information.
 
459
   * 
 
460
   * Also see the provider's limitations, and the
 
461
   * Advanced GdaDataSelect usage sections.
 
462
   * @param stmt A Gda::Statement object.
 
463
   * @param params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or <tt>0</tt>.
 
464
   * @param model_usage In the case where @a stmt is a SELECT statement, specifies how the returned data model will be used.
 
465
   * @param last_insert_row A place to store a new Gda::Set object which contains the values of the last inserted row, or <tt>0</tt>.
 
466
   * @return A Object, or <tt>0</tt> if an error occurred.
 
467
   */
 
468
 
 
469
  Glib::RefPtr<Glib::Object> statement_execute(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage, Glib::RefPtr<const Set>& last_insert_row);
 
470
 
 
471
//TODO: Documentation:
 
472
  Glib::RefPtr<Glib::Object> statement_execute(const Glib::RefPtr<const Statement>& stmt, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
473
 
 
474
 
 
475
  Glib::RefPtr<Glib::Object> statement_execute(const Glib::ustring& sql, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
476
 
 
477
  //_WRAP_METHOD(Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params), gda_connection_statement_execute_select, errthrow)
 
478
   //We instead create a version that can take an optional usage parameter too.
 
479
 
 
480
 
 
481
  /** Executes a selection command on the given connection.
 
482
   * 
 
483
   * This function returns a Gda::DataModel resulting from the SELECT statement, or <tt>0</tt>
 
484
   * if an error occurred.
 
485
   * 
 
486
   * This function is just a convenience function around the statement_execute()
 
487
   * function.
 
488
   * 
 
489
   * See the documentation of the statement_execute() for information
 
490
   * about the @params list of parameters.
 
491
   * @param stmt A Gda::Statement object.
 
492
   * @param params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or <tt>0</tt>.
 
493
   * @param model_usage Specifies how the returned data model will be used as a Gda::StatementModelUsage enum.
 
494
   * @param col_types An array of GType to request each returned Gda::DataModel's column's GType, terminated with the G_TYPE_NONE
 
495
   * value. Any value left to 0 will make the database provider determine the real GType. @a col_types can also be <tt>0</tt> if no
 
496
   * column type is specified.
 
497
   * @return A Gda::DataModel containing the data returned by the
 
498
   * data source, or <tt>0</tt> if an error occurred.
 
499
   */
 
500
  Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage, const std::vector<GType>& col_types);
 
501
  
 
502
 
 
503
//This custom-written method has more optional methods than gda_connection_execute_select_command().
 
504
//TODO: Documentation:
 
505
  Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<const Statement>& stmt, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
506
  Glib::RefPtr<DataModel> statement_execute_select(const Glib::ustring& sql, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
507
 
 
508
//This custom-written method has more optional methods than gda_connection_execute_select_command().
 
509
//TODO: Documentation:
 
510
  Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
511
  Glib::RefPtr<DataModel> statement_execute_select(const Glib::ustring& sql, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
512
  
 
513
 
 
514
//TODO: Documentation:
 
515
//Note that we add the prefix _builder() because overloading on different RefPtr<> types seems to be ambiguous.
 
516
  Glib::RefPtr<DataModel> statement_execute_select_builder(const Glib::RefPtr<const SqlBuilder>& stmt, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
517
 
 
518
//TODO: Documentation:
 
519
//Note that we add the prefix _builder() because overloading on different RefPtr<> types seems to be ambiguous.
 
520
  Glib::RefPtr<DataModel> statement_execute_select_builder(const Glib::RefPtr<const SqlBuilder>& stmt, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 
521
 
 
522
 
 
523
  /** Executes a non-selection statement on the given connection. The gda_execute_non_select_command() method can be easier
 
524
   * to use if one prefers to use some SQL directly.
 
525
   * 
 
526
   * This function returns the number of rows affected by the execution of @a stmt, or -1
 
527
   * if an error occurred, or -2 if the connection's provider does not return the number of rows affected.
 
528
   * 
 
529
   * This function is just a convenience function around the statement_execute()
 
530
   * function. 
 
531
   * See the documentation of the statement_execute() for information
 
532
   * about the @params list of parameters.
 
533
   * 
 
534
   * See statement_execute() form more information about @a last_insert_row.
 
535
   * @param stmt A Gda::Statement object.
 
536
   * @param params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or <tt>0</tt>.
 
537
   * @param last_insert_row A place to store a new Gda::Set object which contains the values of the last inserted row, or <tt>0</tt>.
 
538
   * @return The number of rows affected (>=0) or -1 or -2.
 
539
   */
 
540
 
 
541
//TODO: Documentation:
 
542
//TODO: It's not nice that these two method overloads differ only by the constness of the set.
 
543
  int statement_execute_non_select(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, Glib::RefPtr<const Set>& last_insert_row);
 
544
 
 
545
//TODO: Documentation:
 
546
  int statement_execute_non_select(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params);
 
547
 
 
548
//TODO: Documentation:
 
549
  int statement_execute_non_select(const Glib::RefPtr<const Statement>& stmt);
 
550
 
 
551
  
 
552
  int statement_execute_non_select(const Glib::ustring& sql);
 
553
 
 
554
//TODO: Documentation:
 
555
  int statement_execute_non_select_builder(const Glib::RefPtr<const SqlBuilder>& builder);
 
556
 
 
557
//TODO: Documentation:
 
558
  int statement_execute_non_select_builder(const Glib::RefPtr<const SqlBuilder>& builder, const Glib::RefPtr<const Set>& params);
 
559
 
 
560
  
 
561
  /** This method is similar to statement_execute() but is asynchronous as it method returns
 
562
   * immediately with a task ID. It's up to the caller to use async_fetch_result() regularly to check
 
563
   * if the statement's execution is finished.
 
564
   * 
 
565
   * It is possible to call the method several times to request several statements to be executed asynchronously, the
 
566
   * statements will be executed in the order in which they were requested.
 
567
   * 
 
568
   * The parameters, if present, are copied and can be discarded or modified before the statement is actually executed.
 
569
   * The @a stmt object is not copied but simply referenced (for performance reasons), and if it is modified before
 
570
   * it is actually executed, then its execution will not occur. It is however safe to call Glib::object_unref() on it if
 
571
   * it's not needed anymore.
 
572
   * 
 
573
   * The execution failure of any statement has no impact on the execution of other statements except for example if
 
574
   * the connection has a transaction started and the failure invalidates the transaction (as decided by the database
 
575
   * server).
 
576
   * 
 
577
   * @newin{4,2}
 
578
   * @param stmt A Gda::Statement object.
 
579
   * @param params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or <tt>0</tt>.
 
580
   * @param model_usage In the case where @a stmt is a SELECT statement, specifies how the returned data model will be used.
 
581
   * @param col_types An array of GType to request each returned Gda::DataModel's column's GType, terminated with the G_TYPE_NONE.
 
582
   * @param need_last_insert_row <tt>true</tt> if the values of the last interted row must be computed.
 
583
   * @return A task ID, or 0 if an error occurred (not an error regarding @a stmt itself as its execution has not yet started
 
584
   * but any other error).
 
585
   */
 
586
  guint async_statement_execute(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage, const std::vector<GType>& col_types, bool need_last_insert_row =  false);
 
587
 
 
588
  //TODO: Wrap the last_insert_row parameter properly and add an overload without it:
 
589
  
 
590
  /** Use this method to obtain the result of the execution of a statement which has been executed asynchronously by
 
591
   * calling async_statement_execute(). This function is non locking and will return <tt>0</tt> (and no
 
592
   * error will be set) if the statement has not been executed yet.
 
593
   * 
 
594
   * If the statement has been executed, this method returns the same value as statement_execute()
 
595
   * would have if the statement had been
 
596
   * executed synchronously.
 
597
   * 
 
598
   * @newin{4,2}
 
599
   * @param task_id A task ID returned by async_statement_execute().
 
600
   * @param last_insert_row A place to store a new Gda::Set object which contains the values of the last inserted row, or <tt>0</tt>.
 
601
   * @return A Object, or <tt>0</tt> if an error occurred.
 
602
   */
 
603
  Glib::RefPtr<Glib::Object> async_fetch_result(guint task_id, GdaSet ** last_insert_row);
 
604
  
 
605
  /** Requests that a task be cancelled. This operation may of may not have any effect
 
606
   * depending on the task's status, even if it returns <tt>true</tt>. If it returns <tt>false</tt>,
 
607
   * then the task has not been cancelled.
 
608
   * 
 
609
   * @newin{4,2}
 
610
   * @param task_id A task ID returned by async_statement_execute().
 
611
   * @return <tt>true</tt> if no error occurred.
 
612
   */
 
613
  bool async_cancel(guint task_id);
 
614
 
 
615
//TODO: #m4 __CONVERSION(`GSList*',`std::vector<Glib::Object>',`$2(Glib::SListHandler<Glib::RefPtr<const Statement> >::slist_to_vector((GSList*)$3, Glib::OWNERSHIP_DEEP))')
 
616
//  _WRAP_METHOD(std::vector<Glib::Object> repetitive_statement_execute(GdaRepetitiveStatement *rstmt, StatementModelUsage model_usage, const std::vector<GType>& col_types, gboolean stop_on_error = true), gda_connection_repetitive_statement_execute, errthrow)
 
617
 
 
618
  //Note that we do not add a non-const version of this because the documentation says that it should not be modified:
 
619
  
 
620
  /** Get the status of @a cnc regarding transactions. The returned object should not be modified
 
621
   * or destroyed; however it may be modified or destroyed by the connection itself.
 
622
   * 
 
623
   * If <tt>0</tt> is returned, then no transaction has been associated with @a cnc
 
624
   * @return A Gda::TransactionStatus object, or <tt>0</tt>.
 
625
   */
 
626
  Glib::RefPtr<const TransactionStatus> get_transaction_status() const;
 
627
 
 
628
  
 
629
  /** Starts a transaction on the data source, identified by the
 
630
   *  @a name parameter.
 
631
   * 
 
632
   * Before starting a transaction, you can check whether the underlying
 
633
   * provider does support transactions or not by using the
 
634
   * supports_feature() function.
 
635
   * @param name The name of the transation to start, or <tt>0</tt>.
 
636
   * @param level The requested transaction level (Gda::TRANSACTION_ISOLATION_UNKNOWN if not specified).
 
637
   * @return <tt>true</tt> if the transaction was started successfully, <tt>false</tt>
 
638
   * otherwise.
 
639
   */
 
640
  bool begin_transaction(const Glib::ustring& name, TransactionIsolation level);
 
641
  
 
642
  /** Commits the given transaction to the backend database. You need to call
 
643
   * begin_transaction() first.
 
644
   * @param name The name of the transation to commit, or <tt>0</tt>.
 
645
   * @return <tt>true</tt> if the transaction was finished successfully,
 
646
   * <tt>false</tt> otherwise.
 
647
   */
 
648
  bool commit_transaction(const Glib::ustring& name);
 
649
  
 
650
  /** Rollbacks the given transaction. This means that all changes
 
651
   * made to the underlying data source since the last call to
 
652
   * #begin_transaction() or #commit_transaction()
 
653
   * will be discarded.
 
654
   * @param name The name of the transation to commit, or <tt>0</tt>.
 
655
   * @return <tt>true</tt> if the operation was successful, <tt>false</tt> otherwise.
 
656
   */
 
657
  bool rollback_transaction(const Glib::ustring& name);
 
658
 
 
659
  
 
660
  /** Adds a SAVEPOINT named @a name.
 
661
   * @param name Name of the savepoint to add.
 
662
   * @return <tt>true</tt> if no error occurred.
 
663
   */
 
664
  bool add_savepoint(const Glib::ustring& name);
 
665
  
 
666
  /** Rollback all the modifications made after the SAVEPOINT named @a name.
 
667
   * @param name Name of the savepoint to rollback to.
 
668
   * @return <tt>true</tt> if no error occurred.
 
669
   */
 
670
  bool rollback_savepoint(const Glib::ustring& name);
 
671
  
 
672
  /** Delete the SAVEPOINT named @a name when not used anymore.
 
673
   * @param name Name of the savepoint to delete.
 
674
   * @return <tt>true</tt> if no error occurred.
 
675
   */
 
676
  bool delete_savepoint(const Glib::ustring& name);
 
677
 
 
678
 
 
679
   //Use a special conversion here, because we should not own any part of the returned GList,
 
680
   //according to the documentation for gda_connection_get_events(),
 
681
   //and because we need to unconst the GList.:
 
682
    
 
683
 
 
684
  /** Retrieves a list of the last errors occurred during the connection. The returned list is
 
685
   * chronologically ordered such as that the most recent event is the Gda::ConnectionEvent of the first node.
 
686
   * 
 
687
   * Warning: the @a cnc object may change the list if connection events occur
 
688
   * @return A List of Gda::ConnectionEvent objects (the list should not be modified).
 
689
   */
 
690
  std::vector< Glib::RefPtr<ConnectionEvent> > get_events();
 
691
  
 
692
  /** Retrieves a list of the last errors occurred during the connection. The returned list is
 
693
   * chronologically ordered such as that the most recent event is the Gda::ConnectionEvent of the first node.
 
694
   * 
 
695
   * Warning: the @a cnc object may change the list if connection events occur
 
696
   * @return A List of Gda::ConnectionEvent objects (the list should not be modified).
 
697
   */
 
698
  std::vector< Glib::RefPtr<const ConnectionEvent> > get_events() const;
 
699
 
 
700
 
 
701
  bool insert_row_into_table(const Glib::ustring& table, const std::vector<Glib::ustring>& col_names, const std::vector<Value>& values);
 
702
  
 
703
 
 
704
  bool update_row_in_table(const Glib::ustring& table, const Glib::ustring& condition_column_name, const Value& condition_value, const std::vector<Glib::ustring>& col_names, const std::vector<Value>& values);
 
705
 
 
706
  
 
707
  bool delete_row_from_table(const Glib::ustring& table, const Glib::ustring& condition_column_name, const Value& condition_value);
 
708
  
 
709
 
 
710
  /** Produces a fully quoted and escaped string from a GValue
 
711
   * @param from Value to convert from.
 
712
   * @return Escaped and quoted value or <tt>0</tt> if not supported.
 
713
   */
 
714
  Glib::ustring value_to_sql_string(const Value& from) const;
 
715
 
 
716
  
 
717
  /** Asks the underlying provider for if a specific feature is supported.
 
718
   * @param feature Feature to ask for.
 
719
   * @return <tt>true</tt> if the provider supports it, <tt>false</tt> if not.
 
720
   */
 
721
  bool supports_feature(ConnectionFeature feature) const;
 
722
 
 
723
  
 
724
  /** Gets the user name used to open this connection.
 
725
   * @return The user name.
 
726
   */
 
727
  Glib::ustring get_authentication() const;
 
728
 
 
729
  //TODO: Wrap the GdaSet** output parameter:
 
730
  //_WRAP_METHOD(Glib::RefPtr<Statement> parse_sql_string(const Glib::ustring& sql, GdaSet** params), gda_connection_parse_sql_string, errthrow)
 
731
 
 
732
  /** This helps to parse a SQL string.
 
733
   *
 
734
   * @param sql An SQL command to parse.
 
735
   * @result A Statement representing the SQL command or an empty RefPtr if an error occurred.
 
736
   */
 
737
  Glib::RefPtr<Statement> parse_sql_string(const Glib::ustring& sql);
 
738
  
 
739
 
 
740
  /** Creates a new parser object able to parse the SQL dialect understood by @a cnc. 
 
741
   * If the Gda::ServerProvider object internally used by @a cnc does not have its own parser, 
 
742
   * then <tt>0</tt> is returned, and a general SQL parser can be obtained
 
743
   * using Gda::SqlParser::new().
 
744
   * @return A new Gda::SqlParser object, or <tt>0</tt>.
 
745
   */
 
746
  Glib::RefPtr<SqlParser> create_parser();
 
747
 
 
748
  
 
749
  /** Gets the name (identifier) of the database provider used by @a cnc
 
750
   * @return A non modifiable string.
 
751
   */
 
752
  Glib::ustring get_provider_name() const;
 
753
 
 
754
  /** Update the full meta store information.
 
755
   *
 
756
   * Note that this may take some time for big databases
 
757
   * @return <tt>true</tt> if no error occurred.
 
758
   */
 
759
  bool update_meta_store();
 
760
 
 
761
  /** Update the meta store information @a id
 
762
   *
 
763
   * This can speed up the update of the meta store if you only need a
 
764
   * specific information
 
765
   * @param id An id for the information to update (see http://library.gnome.org/devel/libgda/unstable/information_schema.html)
 
766
   * @return <tt>true</tt> if no error occurred.
 
767
   */
 
768
  bool update_meta_store(const Glib::ustring& id);
 
769
  
 
770
 
 
771
  /** Update the meta store information for the table named @a table_name
 
772
   *
 
773
   * This can speed up the update of the meta store if you only need the information
 
774
   * for a specific table
 
775
   * @param table_name Name of the table where the information is needed
 
776
   * @param schema_name Name of the schema @table_name is in, or "" to update
 
777
   * all tables with the given name. As with update_meta_store_table_names(),
 
778
   * specifying a non-empty schema_name speeds up the operation, just not as
 
779
   * significantly as with update_meta_store_table_names() because the
 
780
   * operation itself is already pretty quick.
 
781
   * @return <tt>true</tt> if no error occurred.
 
782
   */
 
783
  bool update_meta_store_table(const Glib::ustring& table_name, const Glib::ustring& schema_name = Glib::ustring());
 
784
 
 
785
  /** Update the meta store information for the table names.
 
786
   *
 
787
   * This can speed up the update of the meta store if you only need the list of table names.
 
788
   *
 
789
   * @param schema_name Name of the schema whose tables to update, or "" to
 
790
   * update all tables. For example, for postgresql this function takes a
 
791
   * considerable amount of time when doing this. If you don't need
 
792
   * information about internal postgresql tables, then you can speed up the
 
793
   * process by only updating the tables for the "public" schema.
 
794
   * Unfortunately, schema names are not common between different database
 
795
   * systems.
 
796
   * @return <tt>true</tt> if no error occurred.
 
797
   */
 
798
  bool update_meta_store_table_names(const Glib::ustring& schema_name = Glib::ustring());
 
799
 
 
800
  /** Update the meta store information for the data types.
 
801
   *
 
802
   * This can speed up the update of the meta store if you only need the data types.
 
803
   *
 
804
   * @return <tt>true</tt> if no error occurred.
 
805
   */
 
806
  bool update_meta_store_data_types();
 
807
 
 
808
  
 
809
  /** Ask the database accessed through the @a cnc connection to prepare the usage of @a stmt. This is only useful
 
810
   * if @a stmt will be used more than once (however some database providers may always prepare statements 
 
811
   * before executing them).
 
812
   * 
 
813
   * This function is also useful to make sure @a stmt is fully understood by the database before actually executing it.
 
814
   * 
 
815
   * Note however that it is also possible that statement_prepare() fails when
 
816
   * statement_execute() does not fail (this will usually be the case with statements such as
 
817
   * <![CDATA["SELECT * FROM ##tablename::string"]]> because database usually don't allow variables to be used in place of a 
 
818
   * table name).
 
819
   * @param stmt A Gda::Statement object.
 
820
   * @return <tt>true</tt> if no error occurred.
 
821
   */
 
822
  bool statement_prepare(const Glib::RefPtr<const Statement>& stmt);
 
823
 
 
824
 
 
825
  /** see #gda_connection_get_meta_store_data
 
826
   * @param meta_type Describes which data to get.
 
827
   * @param filters A List of Gda::Holder objects.
 
828
   * @return A Gda::DataModel containing the data required. The caller is responsible
 
829
   * for freeing the returned model using Glib::object_unref().
 
830
   */
 
831
  Glib::RefPtr<DataModel> get_meta_store_data(ConnectionMetaType meta_type, const std::vector< Glib::RefPtr<Holder> >& filters);
 
832
  
 
833
 
 
834
  Glib::RefPtr<DataModel> get_meta_store_data(ConnectionMetaType meta_type);
 
835
 
 
836
  
 
837
  /** Get or initializes the Gda::MetaStore associated to @a cnc
 
838
   * @return A Gda::MetaStore object.
 
839
   */
 
840
  Glib::RefPtr<MetaStore> get_meta_store();
 
841
  
 
842
  /** Get or initializes the Gda::MetaStore associated to @a cnc
 
843
   * @return A Gda::MetaStore object.
 
844
   */
 
845
  Glib::RefPtr<const MetaStore> get_meta_store() const;
 
846
 
 
847
   
 
848
  /** Executes all the statements contained in @a batch (in the order in which they were added to @a batch), and
 
849
   * returns a list of Object objects, at most one Object for each statement; see statement_execute()
 
850
   * for details about the returned objects.
 
851
   * 
 
852
   * If one of the statement fails, then none of the subsequent statement will be executed, and the method returns
 
853
   * the list of Object created by the correct execution of the previous statements. If a transaction is required,
 
854
   * then it should be started before calling this method.
 
855
   * @param batch A Gda::Batch object which contains all the statements to execute.
 
856
   * @param params A Gda::Set object (which can be obtained using Gda::Batch::get_parameters()), or <tt>0</tt>.
 
857
   * @param model_usage Specifies how the returned data model(s) will be used, as a Gda::StatementModelUsage enum.
 
858
   * @return A new list of Object objects.
 
859
   */
 
860
  std::vector< Glib::RefPtr<Glib::Object> > batch_execute(const Glib::RefPtr<Batch>& batch, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage);
 
861
 
 
862
  
 
863
  /** Creates a new Gda::ServerOperation object which can be modified in order 
 
864
   * to perform the type type of action. It is a wrapper around the Gda::ServerProvider::create_operation()
 
865
   * method.
 
866
   * @param type The type of operation requested.
 
867
   * @param options An optional list of parameters.
 
868
   * @return A new Gda::ServerOperation object, or <tt>0</tt> in the connection's provider does not support the @a type type
 
869
   * of operation or if an error occurred.
 
870
   */
 
871
  Glib::RefPtr<ServerOperation> create_operation(ServerOperationType type, const Glib::RefPtr<const Set>& options);
 
872
  
 
873
  /** Performs the operation described by @a op (which should have been created using
 
874
   * create_operation()). It is a wrapper around the Gda::ServerProvider::perform_operation()
 
875
   * method.
 
876
   * @param op A Gda::ServerOperation object.
 
877
   * @return <tt>true</tt> if no error occurred.
 
878
   */
 
879
  bool perform_operation(const Glib::RefPtr<ServerOperation>& op);
 
880
 
 
881
  
 
882
  /** Gets a pointer to the Gda::ServerProvider object used to access the database
 
883
   * @return The Gda::ServerProvider (NEVER <tt>0</tt>).
 
884
   */
 
885
  Glib::RefPtr<ServerProvider> get_provider();
 
886
  
 
887
  /** Gets a pointer to the Gda::ServerProvider object used to access the database
 
888
   * @return The Gda::ServerProvider (NEVER <tt>0</tt>).
 
889
   */
 
890
  Glib::RefPtr<const ServerProvider> get_provider() const;
 
891
 
 
892
  
 
893
  /** Use this method to get a correctly quoted (if necessary) SQL identifier which can be used
 
894
   * in SQL statements, from @a id. If @a id is already correctly quoted for @a cnc, then a copy of @a id
 
895
   * may be returned.
 
896
   * 
 
897
   * This method may add double quotes (or other characters) around @a id:
 
898
   * <itemizedlist>
 
899
   * <listitem>if @a id is a reserved SQL keyword (such as SELECT, INSERT, ...)</listitem>
 
900
   * <listitem>if @a id contains non allowed characters such as spaces, or if it starts with a digit</listitem>
 
901
   * <listitem>in any other event as necessary for @a cnc, depending on the the options passed when opening the @a cnc
 
902
   * connection, and specifically the 
 
903
   * GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE option.</listitem>
 
904
   * </itemizedlist>
 
905
   * 
 
906
   * One can safely pass an already quoted @a id to this method, either with quoting characters allowed by @a cnc or using the
 
907
   * double quote (") character.
 
908
   * 
 
909
   * @newin{4,0}.3
 
910
   * @param id An SQL identifier.
 
911
   * @return A new string, to free with Glib::free() once not needed anymore.
 
912
   */
 
913
  Glib::ustring quote_sql_identifier(const Glib::ustring& id) const;
 
914
 
 
915
  
 
916
  /** Renders @a stmt as an SQL statement, adapted to the SQL dialect used by @a cnc
 
917
   * @param stmt A Gda::Statement object.
 
918
   * @param params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or <tt>0</tt>.
 
919
   * @param flags SQL rendering flags, as Gda::StatementSqlFlag OR'ed values.
 
920
   * @param params_used A place to store the list of individual Gda::Holder objects within @params which have been used.
 
921
   * @return A new string, or <tt>0</tt> if an error occurred.
 
922
   */
 
923
 
 
924
 
 
925
  //TODO: What errors does this really throw? Document that in libgda.
 
926
  //TODO: Add an overload without the params_used.
 
927
  /** Renders a Statement as a SQL statement string, adapted to the SQL dialect used by the connection.
 
928
   *
 
929
   * @param stmt A Statement object.
 
930
   * @param A Set object (which can be obtained using Statement::get_parameters()).
 
931
   * @param flags SQL rendering flags, as StatementSqlFlag OR'ed values
 
932
   * @param params_used A place to store the list of individual Holder objects within @a params which have been used.
 
933
   * @throws ConnectionError
 
934
   */
 
935
  Glib::ustring statement_to_sql(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementSqlFlag flags, std::vector< Glib::RefPtr<Holder> >& params_used) const;
 
936
 
 
937
  /** Renders a Statement as a SQL statement string, adapted to the SQL dialect used by the connection.
 
938
   *
 
939
   * @param stmt A Statement object.
 
940
   * @param A Set object (which can be obtained using Statement::get_parameters()).
 
941
   * @param flags SQL rendering flags, as StatementSqlFlag OR'ed values
 
942
   * @throws ConnectionError
 
943
   */
 
944
  Glib::ustring statement_to_sql(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementSqlFlag flags = STATEMENT_SQL_PARAMS_AS_VALUES) const;
 
945
  
 
946
  /** Renders a Statement as a SQL statement string, adapted to the SQL dialect used by the connection.
 
947
   *
 
948
   * @param stmt A Statement object..
 
949
   * @param flags SQL rendering flags, as StatementSqlFlag OR'ed values
 
950
   * @throws ConnectionError
 
951
   */
 
952
  Glib::ustring statement_to_sql(const Glib::RefPtr<const Statement>& stmt, StatementSqlFlag flags = STATEMENT_SQL_PARAMS_AS_VALUES) const;
 
953
 
 
954
 
 
955
  /**
 
956
   * @par Prototype:
 
957
   * <tt>void on_my_%error(const Glib::RefPtr<ConnectionEvent>& error)</tt>
 
958
   */
 
959
 
 
960
  Glib::SignalProxy1< void,const Glib::RefPtr<ConnectionEvent>& > signal_error();
 
961
 
 
962
 
 
963
  /**
 
964
   * @par Prototype:
 
965
   * <tt>void on_my_%conn_opened()</tt>
 
966
   */
 
967
 
 
968
  Glib::SignalProxy0< void > signal_conn_opened();
 
969
 
 
970
  
 
971
  /**
 
972
   * @par Prototype:
 
973
   * <tt>void on_my_%conn_to_close()</tt>
 
974
   */
 
975
 
 
976
  Glib::SignalProxy0< void > signal_conn_to_close();
 
977
 
 
978
  
 
979
  /**
 
980
   * @par Prototype:
 
981
   * <tt>void on_my_%conn_closed()</tt>
 
982
   */
 
983
 
 
984
  Glib::SignalProxy0< void > signal_conn_closed();
 
985
 
 
986
  
 
987
  /**
 
988
   * @par Prototype:
 
989
   * <tt>void on_my_%dsn_changed()</tt>
 
990
   */
 
991
 
 
992
  Glib::SignalProxy0< void > signal_dsn_changed();
 
993
 
 
994
  
 
995
  /**
 
996
   * @par Prototype:
 
997
   * <tt>void on_my_%transaction_status_changed()</tt>
 
998
   */
 
999
 
 
1000
  Glib::SignalProxy0< void > signal_transaction_status_changed();
 
1001
 
 
1002
 
 
1003
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1004
/** Provider to use.
 
1005
   *
 
1006
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1007
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1008
   * the value of the property changes.
 
1009
   */
 
1010
  Glib::PropertyProxy< Glib::RefPtr<ServerProvider> > property_provider() ;
 
1011
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1012
 
 
1013
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1014
/** Provider to use.
 
1015
   *
 
1016
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1017
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1018
   * the value of the property changes.
 
1019
   */
 
1020
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<ServerProvider> > property_provider() const;
 
1021
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1022
 
 
1023
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1024
/** Authentication string to use.
 
1025
   *
 
1026
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1027
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1028
   * the value of the property changes.
 
1029
   */
 
1030
  Glib::PropertyProxy<Glib::ustring> property_auth_string() ;
 
1031
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1032
 
 
1033
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1034
/** Authentication string to use.
 
1035
   *
 
1036
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1037
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1038
   * the value of the property changes.
 
1039
   */
 
1040
  Glib::PropertyProxy_ReadOnly<Glib::ustring> property_auth_string() const;
 
1041
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1042
 
 
1043
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1044
/** Connection string to use.
 
1045
   *
 
1046
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1047
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1048
   * the value of the property changes.
 
1049
   */
 
1050
  Glib::PropertyProxy<Glib::ustring> property_cnc_string() ;
 
1051
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1052
 
 
1053
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1054
/** Connection string to use.
 
1055
   *
 
1056
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1057
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1058
   * the value of the property changes.
 
1059
   */
 
1060
  Glib::PropertyProxy_ReadOnly<Glib::ustring> property_cnc_string() const;
 
1061
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1062
 
 
1063
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1064
/** DSN to use.
 
1065
   *
 
1066
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1067
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1068
   * the value of the property changes.
 
1069
   */
 
1070
  Glib::PropertyProxy<Glib::ustring> property_dsn() ;
 
1071
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1072
 
 
1073
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1074
/** DSN to use.
 
1075
   *
 
1076
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1077
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1078
   * the value of the property changes.
 
1079
   */
 
1080
  Glib::PropertyProxy_ReadOnly<Glib::ustring> property_dsn() const;
 
1081
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1082
 
 
1083
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1084
/** GdaMetaStore used by the connection.
 
1085
   *
 
1086
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1087
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1088
   * the value of the property changes.
 
1089
   */
 
1090
  Glib::PropertyProxy< Glib::RefPtr<MetaStore> > property_meta_store() ;
 
1091
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1092
 
 
1093
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1094
/** GdaMetaStore used by the connection.
 
1095
   *
 
1096
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1097
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1098
   * the value of the property changes.
 
1099
   */
 
1100
  Glib::PropertyProxy_ReadOnly< Glib::RefPtr<MetaStore> > property_meta_store() const;
 
1101
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1102
 
 
1103
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1104
/** Options.
 
1105
   *
 
1106
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1107
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1108
   * the value of the property changes.
 
1109
   */
 
1110
  Glib::PropertyProxy<ConnectionOptions> property_options() ;
 
1111
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1112
 
 
1113
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1114
/** Options.
 
1115
   *
 
1116
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1117
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1118
   * the value of the property changes.
 
1119
   */
 
1120
  Glib::PropertyProxy_ReadOnly<ConnectionOptions> property_options() const;
 
1121
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1122
 
 
1123
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1124
/** Tells if the connection acts as a thread wrapper around another connection, making it completely thread safe.
 
1125
   *
 
1126
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1127
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1128
   * the value of the property changes.
 
1129
   */
 
1130
  Glib::PropertyProxy_ReadOnly<bool> property_is_wrapper() const;
 
1131
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1132
 
 
1133
 
 
1134
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1135
/** Make the connection set up a monitoring function in the mainloop to monitor the wrapped connection.
 
1136
   *
 
1137
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1138
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1139
   * the value of the property changes.
 
1140
   */
 
1141
  Glib::PropertyProxy<bool> property_monitor_wrapped_in_mainloop() ;
 
1142
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1143
 
 
1144
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1145
/** Make the connection set up a monitoring function in the mainloop to monitor the wrapped connection.
 
1146
   *
 
1147
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1148
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1149
   * the value of the property changes.
 
1150
   */
 
1151
  Glib::PropertyProxy_ReadOnly<bool> property_monitor_wrapped_in_mainloop() const;
 
1152
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1153
 
 
1154
  //We ignore the thread-owner property because it is strange and should only be used (well, modified) by provider implementations.
 
1155
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
1156
/** 
 
1157
   *
 
1158
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1159
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1160
   * the value of the property changes.
 
1161
   */
 
1162
  Glib::PropertyProxy<int> property_events_history_size() ;
 
1163
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1164
 
 
1165
#ifdef GLIBMM_PROPERTIES_ENABLED
 
1166
/** 
 
1167
   *
 
1168
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
 
1169
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
 
1170
   * the value of the property changes.
 
1171
   */
 
1172
  Glib::PropertyProxy_ReadOnly<int> property_events_history_size() const;
 
1173
#endif //#GLIBMM_PROPERTIES_ENABLED
 
1174
 
 
1175
 
 
1176
public:
 
1177
 
 
1178
public:
 
1179
  //C++ methods used to invoke GTK+ virtual functions:
 
1180
 
 
1181
protected:
 
1182
  //GTK+ Virtual Functions (override these to change behaviour):
 
1183
 
 
1184
  //Default Signal Handlers::
 
1185
  virtual void on_error(const Glib::RefPtr<ConnectionEvent>& error);
 
1186
  virtual void on_conn_opened();
 
1187
  virtual void on_conn_to_close();
 
1188
  virtual void on_conn_closed();
 
1189
  virtual void on_dsn_changed();
 
1190
  virtual void on_transaction_status_changed();
 
1191
 
 
1192
 
 
1193
};
 
1194
 
 
1195
} // namespace Gda
 
1196
} // namespace Gnome
 
1197
 
 
1198
 
 
1199
namespace Glib
 
1200
{
 
1201
  /** A Glib::wrap() method for this object.
 
1202
   * 
 
1203
   * @param object The C instance.
 
1204
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
 
1205
   * @result A C++ instance that wraps this C instance.
 
1206
   *
 
1207
   * @relates Gnome::Gda::Connection
 
1208
   */
 
1209
  Glib::RefPtr<Gnome::Gda::Connection> wrap(GdaConnection* object, bool take_copy = false);
 
1210
}
 
1211
 
 
1212
 
 
1213
#endif /* _LIBGDAMM_CONNECTION_H */
 
1214