alternative to assert
[gtkD.git] / gtkD / srcgda / gda / Command.d
blobf06e575bdf146a5674e524622fba2e9dba1ef12f
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = libgda-gda-command.html
26 * outPack = gda
27 * outFile = Command
28 * strct = GdaCommand
29 * realStrct=
30 * ctorStrct=
31 * clss = Command
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gda_command_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gda.Transaction
45 * structWrap:
46 * - GdaCommand* -> Command
47 * - GdaTransaction* -> Transaction
48 * module aliases:
49 * local aliases:
52 module gda.Command;
54 version(noAssert)
56 version(Tango)
58 import tango.io.Stdout; // use the tango loging?
62 private import gdac.gdatypes;
64 private import gdac.gda;
67 private import gda.Transaction;
72 /**
73 * Description
74 * The GdaCommand structure holds data needed to issue a command to the
75 * providers.
76 * Applications usually create a GdaCommand (via gda_command_new), set its
77 * properties (via the gda_command_set_* functions) and pass it over to the
78 * database using the GdaConnection functions.
79 * One interesting thing about GdaCommand's is that they can be reused over
80 * and over. That is, applications don't need to create a command every time
81 * they want to run something on the connected database. Moreover, the ability
82 * to create command strings with placeholders allows the use of parameters to
83 * specify the values for those placeholders. Thus, an application can create a
84 * command of the form:
85 * INSERT INTO employees VALUES (id, name, address, salary)
86 * and reuse the same command over and over, just using different values for the
87 * placeholders.
88 * The value for the placeholders is specified when sending the GdaCommand to a
89 * database connection, which is done via the gda_connection_execute function.
91 public class Command
94 /** the main Gtk struct */
95 protected GdaCommand* gdaCommand;
98 public GdaCommand* getCommandStruct()
100 return gdaCommand;
104 /** the main Gtk struct as a void* */
105 protected void* getStruct()
107 return cast(void*)gdaCommand;
111 * Sets our main struct and passes it to the parent class
113 public this (GdaCommand* gdaCommand)
115 version(noAssert)
117 if ( gdaCommand is null )
119 int zero = 0;
120 version(Tango)
122 Stdout("struct gdaCommand is null on constructor").newline;
124 else
126 printf("struct gdaCommand is null on constructor");
128 zero = zero / zero;
131 else
133 assert(gdaCommand !is null, "struct gdaCommand is null on constructor");
135 this.gdaCommand = gdaCommand;
147 * Returns :
149 public static GType getType()
151 // GType gda_command_get_type (void);
152 return gda_command_get_type();
156 * Creates a new GdaCommand from the parameters that should be freed by
157 * calling gda_command_free.
158 * If there are conflicting options, this will set options to
159 * GDA_COMMAND_OPTION_DEFAULT.
160 * text :
161 * the text of the command.
162 * type :
163 * a GdaCommandType value.
164 * options :
165 * a GdaCommandOptions value.
166 * Returns :
167 * a newly allocated GdaCommand.
169 public this (char[] text, GdaCommandType type, GdaCommandOptions options)
171 // GdaCommand* gda_command_new (const gchar *text, GdaCommandType type, GdaCommandOptions options);
172 this(cast(GdaCommand*)gda_command_new(Str.toStringz(text), type, options) );
176 * Frees the resources allocated by gda_command_new.
177 * cmd :
178 * a GdaCommand.
180 public void free()
182 // void gda_command_free (GdaCommand *cmd);
183 gda_command_free(gdaCommand);
187 * Creates a new GdaCommand from an existing one.
188 * cmd :
189 * command to get a copy from.
190 * Returns :
191 * a newly allocated GdaCommand with a copy of the data in cmd.
193 public Command copy()
195 // GdaCommand* gda_command_copy (GdaCommand *cmd);
196 return new Command( gda_command_copy(gdaCommand) );
200 * Gets the command text held by cmd.
201 * cmd :
202 * a GdaCommand.
203 * Returns :
204 * the command string of cmd.
206 public char[] getText()
208 // const gchar* gda_command_get_text (GdaCommand *cmd);
209 return Str.toString(gda_command_get_text(gdaCommand) );
213 * Sets the command text of cmd.
214 * cmd :
215 * a GdaCommand
216 * text :
217 * the command text.
219 public void setText(char[] text)
221 // void gda_command_set_text (GdaCommand *cmd, const gchar *text);
222 gda_command_set_text(gdaCommand, Str.toStringz(text));
226 * Gets the command type of cmd.
227 * cmd :
228 * a GdaCommand.
229 * Returns :
230 * the command type of cmd.
232 public GdaCommandType getCommandType()
234 // GdaCommandType gda_command_get_command_type (GdaCommand *cmd);
235 return gda_command_get_command_type(gdaCommand);
239 * Sets the command type of cmd.
240 * cmd :
241 * a GdaCommand
242 * type :
243 * the command type.
245 public void setCommandType(GdaCommandType type)
247 // void gda_command_set_command_type (GdaCommand *cmd, GdaCommandType type);
248 gda_command_set_command_type(gdaCommand, type);
252 * Gets the command options of cmd.
253 * cmd :
254 * a GdaCommand.
255 * Returns :
256 * the command options of cmd.
258 public GdaCommandOptions getOptions()
260 // GdaCommandOptions gda_command_get_options (GdaCommand *cmd);
261 return gda_command_get_options(gdaCommand);
265 * Sets the command options of cmd. If there conflicting options, it will just
266 * leave the value as before.
267 * cmd :
268 * a GdaCommand
269 * options :
270 * the command options.
272 public void setOptions(GdaCommandOptions options)
274 // void gda_command_set_options (GdaCommand *cmd, GdaCommandOptions options);
275 gda_command_set_options(gdaCommand, options);
279 * Gets the GdaTransaction associated with the given GdaCommand.
280 * cmd :
281 * a GdaCommand.
282 * Returns :
283 * the transaction for the command.
285 public Transaction getTransaction()
287 // GdaTransaction* gda_command_get_transaction (GdaCommand *cmd);
288 return new Transaction( gda_command_get_transaction(gdaCommand) );
292 * Sets the GdaTransaction associated with the given GdaCommand.
293 * cmd :
294 * a GdaCommand.
295 * xaction :
296 * a GdaTransaction object.
298 public void setTransaction(Transaction xaction)
300 // void gda_command_set_transaction (GdaCommand *cmd, GdaTransaction *xaction);
301 gda_command_set_transaction(gdaCommand, (xaction is null) ? null : xaction.getTransactionStruct());