1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = libgda-gda-command.html
27  * outPack = gda
28  * outFile = Command
29  * strct   = GdaCommand
30  * realStrct=
31  * ctorStrct=
32  * clss    = Command
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gda_command_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gda.Transaction
48  * structWrap:
49  * 	- GdaCommand* -> Command
50  * 	- GdaTransaction* -> Transaction
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gda.Command;
57 
58 public  import gdac.gdatypes;
59 
60 private import gdac.gda;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 private import glib.Str;
65 private import gda.Transaction;
66 
67 
68 
69 /**
70  *  The GdaCommand structure holds data needed to issue a command to the
71  *  providers.
72  *  Applications usually create a GdaCommand (via gda_command_new), set its
73  *  properties (via the gda_command_set_* functions) and pass it over to the
74  *  database using the GdaConnection functions.
75  *
76  *  One interesting thing about GdaCommand's is that they can be reused over
77  *  and over. That is, applications don't need to create a command every time
78  *  they want to run something on the connected database. Moreover, the ability
79  *  to create command strings with placeholders allows the use of parameters to
80  *  specify the values for those placeholders. Thus, an application can create a
81  *  command of the form:
82  *
83  *  INSERT INTO employees VALUES (id, name, address, salary)
84  *
85  *  and reuse the same command over and over, just using different values for the
86  *  placeholders.
87  *
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.
90  */
91 public class Command
92 {
93 	
94 	/** the main Gtk struct */
95 	protected GdaCommand* gdaCommand;
96 	
97 	
98 	/** Get the main Gtk struct */
99 	public GdaCommand* getCommandStruct()
100 	{
101 		return gdaCommand;
102 	}
103 	
104 	
105 	/** the main Gtk struct as a void* */
106 	protected void* getStruct()
107 	{
108 		return cast(void*)gdaCommand;
109 	}
110 	
111 	/**
112 	 * Sets our main struct and passes it to the parent class
113 	 */
114 	public this (GdaCommand* gdaCommand)
115 	{
116 		this.gdaCommand = gdaCommand;
117 	}
118 	
119 	/**
120 	 */
121 	
122 	/**
123 	 * Returns:
124 	 */
125 	public static GType getType()
126 	{
127 		// GType gda_command_get_type (void);
128 		return gda_command_get_type();
129 	}
130 	
131 	/**
132 	 * Creates a new GdaCommand from the parameters that should be freed by
133 	 * calling gda_command_free.
134 	 * If there are conflicting options, this will set options to
135 	 * GDA_COMMAND_OPTION_DEFAULT.
136 	 * Params:
137 	 * text = the text of the command.
138 	 * type = a GdaCommandType value.
139 	 * options = a GdaCommandOptions value.
140 	 * Throws: ConstructionException GTK+ fails to create the object.
141 	 */
142 	public this (string text, GdaCommandType type, GdaCommandOptions options)
143 	{
144 		// GdaCommand* gda_command_new (const gchar *text,  GdaCommandType type,  GdaCommandOptions options);
145 		auto p = gda_command_new(Str.toStringz(text), type, options);
146 		if(p is null)
147 		{
148 			throw new ConstructionException("null returned by gda_command_new(Str.toStringz(text), type, options)");
149 		}
150 		this(cast(GdaCommand*) p);
151 	}
152 	
153 	/**
154 	 * Frees the resources allocated by gda_command_new.
155 	 */
156 	public void free()
157 	{
158 		// void gda_command_free (GdaCommand *cmd);
159 		gda_command_free(gdaCommand);
160 	}
161 	
162 	/**
163 	 * Creates a new GdaCommand from an existing one.
164 	 * Returns: a newly allocated GdaCommand with a copy of the data in cmd.
165 	 */
166 	public Command copy()
167 	{
168 		// GdaCommand* gda_command_copy (GdaCommand *cmd);
169 		auto p = gda_command_copy(gdaCommand);
170 		
171 		if(p is null)
172 		{
173 			return null;
174 		}
175 		
176 		return ObjectG.getDObject!(Command)(cast(GdaCommand*) p);
177 	}
178 	
179 	/**
180 	 * Gets the command text held by cmd.
181 	 * Returns: the command string of cmd.
182 	 */
183 	public string getText()
184 	{
185 		// const gchar* gda_command_get_text (GdaCommand *cmd);
186 		return Str.toString(gda_command_get_text(gdaCommand));
187 	}
188 	
189 	/**
190 	 * Sets the command text of cmd.
191 	 * Params:
192 	 * text = the command text.
193 	 */
194 	public void setText(string text)
195 	{
196 		// void gda_command_set_text (GdaCommand *cmd,  const gchar *text);
197 		gda_command_set_text(gdaCommand, Str.toStringz(text));
198 	}
199 	
200 	/**
201 	 * Gets the command type of cmd.
202 	 * Returns: the command type of cmd.
203 	 */
204 	public GdaCommandType getCommandType()
205 	{
206 		// GdaCommandType gda_command_get_command_type (GdaCommand *cmd);
207 		return gda_command_get_command_type(gdaCommand);
208 	}
209 	
210 	/**
211 	 * Sets the command type of cmd.
212 	 * Params:
213 	 * type = the command type.
214 	 */
215 	public void setCommandType(GdaCommandType type)
216 	{
217 		// void gda_command_set_command_type (GdaCommand *cmd,  GdaCommandType type);
218 		gda_command_set_command_type(gdaCommand, type);
219 	}
220 	
221 	/**
222 	 * Gets the command options of cmd.
223 	 * Returns: the command options of cmd.
224 	 */
225 	public GdaCommandOptions getOptions()
226 	{
227 		// GdaCommandOptions gda_command_get_options (GdaCommand *cmd);
228 		return gda_command_get_options(gdaCommand);
229 	}
230 	
231 	/**
232 	 * Sets the command options of cmd. If there conflicting options, it will just
233 	 * leave the value as before.
234 	 * Params:
235 	 * options = the command options.
236 	 */
237 	public void setOptions(GdaCommandOptions options)
238 	{
239 		// void gda_command_set_options (GdaCommand *cmd,  GdaCommandOptions options);
240 		gda_command_set_options(gdaCommand, options);
241 	}
242 	
243 	/**
244 	 * Gets the GdaTransaction associated with the given GdaCommand.
245 	 * Returns: the transaction for the command.
246 	 */
247 	public Transaction getTransaction()
248 	{
249 		// GdaTransaction* gda_command_get_transaction (GdaCommand *cmd);
250 		auto p = gda_command_get_transaction(gdaCommand);
251 		
252 		if(p is null)
253 		{
254 			return null;
255 		}
256 		
257 		return ObjectG.getDObject!(Transaction)(cast(GdaTransaction*) p);
258 	}
259 	
260 	/**
261 	 * Sets the GdaTransaction associated with the given GdaCommand.
262 	 * Params:
263 	 * xaction = a GdaTransaction object.
264 	 */
265 	public void setTransaction(Transaction xaction)
266 	{
267 		// void gda_command_set_transaction (GdaCommand *cmd,  GdaTransaction *xaction);
268 		gda_command_set_transaction(gdaCommand, (xaction is null) ? null : xaction.getTransactionStruct());
269 	}
270 }