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 
65 private import glib.Str;
66 private import gda.Transaction;
67 
68 
69 
70 
71 /**
72  *  The GdaCommand structure holds data needed to issue a command to the
73  *  providers.
74  *  Applications usually create a GdaCommand (via gda_command_new), set its
75  *  properties (via the gda_command_set_* functions) and pass it over to the
76  *  database using the GdaConnection functions.
77  *
78  *  One interesting thing about GdaCommand's is that they can be reused over
79  *  and over. That is, applications don't need to create a command every time
80  *  they want to run something on the connected database. Moreover, the ability
81  *  to create command strings with placeholders allows the use of parameters to
82  *  specify the values for those placeholders. Thus, an application can create a
83  *  command of the form:
84  *
85  *  INSERT INTO employees VALUES (id, name, address, salary)
86  *
87  *  and reuse the same command over and over, just using different values for the
88  *  placeholders.
89  *
90  *  The value for the placeholders is specified when sending the GdaCommand to a
91  *  database connection, which is done via the gda_connection_execute function.
92  */
93 public class Command
94 {
95 	
96 	/** the main Gtk struct */
97 	protected GdaCommand* gdaCommand;
98 	
99 	
100 	public GdaCommand* getCommandStruct()
101 	{
102 		return gdaCommand;
103 	}
104 	
105 	
106 	/** the main Gtk struct as a void* */
107 	protected void* getStruct()
108 	{
109 		return cast(void*)gdaCommand;
110 	}
111 	
112 	/**
113 	 * Sets our main struct and passes it to the parent class
114 	 */
115 	public this (GdaCommand* gdaCommand)
116 	{
117 		this.gdaCommand = gdaCommand;
118 	}
119 	
120 	/**
121 	 */
122 	
123 	/**
124 	 * Returns:
125 	 */
126 	public static GType getType()
127 	{
128 		// GType gda_command_get_type (void);
129 		return gda_command_get_type();
130 	}
131 	
132 	/**
133 	 * Creates a new GdaCommand from the parameters that should be freed by
134 	 * calling gda_command_free.
135 	 * If there are conflicting options, this will set options to
136 	 * GDA_COMMAND_OPTION_DEFAULT.
137 	 * Params:
138 	 * text = the text of the command.
139 	 * type = a GdaCommandType value.
140 	 * options = a GdaCommandOptions value.
141 	 * Throws: ConstructionException GTK+ fails to create the object.
142 	 */
143 	public this (string text, GdaCommandType type, GdaCommandOptions options)
144 	{
145 		// GdaCommand* gda_command_new (const gchar *text,  GdaCommandType type,  GdaCommandOptions options);
146 		auto p = gda_command_new(Str.toStringz(text), type, options);
147 		if(p is null)
148 		{
149 			throw new ConstructionException("null returned by gda_command_new(Str.toStringz(text), type, options)");
150 		}
151 		this(cast(GdaCommand*) p);
152 	}
153 	
154 	/**
155 	 * Frees the resources allocated by gda_command_new.
156 	 */
157 	public void free()
158 	{
159 		// void gda_command_free (GdaCommand *cmd);
160 		gda_command_free(gdaCommand);
161 	}
162 	
163 	/**
164 	 * Creates a new GdaCommand from an existing one.
165 	 * Returns: a newly allocated GdaCommand with a copy of the data in cmd.
166 	 */
167 	public Command copy()
168 	{
169 		// GdaCommand* gda_command_copy (GdaCommand *cmd);
170 		auto p = gda_command_copy(gdaCommand);
171 		
172 		if(p is null)
173 		{
174 			return null;
175 		}
176 		
177 		return ObjectG.getDObject!(Command)(cast(GdaCommand*) p);
178 	}
179 	
180 	/**
181 	 * Gets the command text held by cmd.
182 	 * Returns: the command string of cmd.
183 	 */
184 	public string getText()
185 	{
186 		// const gchar* gda_command_get_text (GdaCommand *cmd);
187 		return Str.toString(gda_command_get_text(gdaCommand));
188 	}
189 	
190 	/**
191 	 * Sets the command text of cmd.
192 	 * Params:
193 	 * text = the command text.
194 	 */
195 	public void setText(string text)
196 	{
197 		// void gda_command_set_text (GdaCommand *cmd,  const gchar *text);
198 		gda_command_set_text(gdaCommand, Str.toStringz(text));
199 	}
200 	
201 	/**
202 	 * Gets the command type of cmd.
203 	 * Returns: the command type of cmd.
204 	 */
205 	public GdaCommandType getCommandType()
206 	{
207 		// GdaCommandType gda_command_get_command_type (GdaCommand *cmd);
208 		return gda_command_get_command_type(gdaCommand);
209 	}
210 	
211 	/**
212 	 * Sets the command type of cmd.
213 	 * Params:
214 	 * type = the command type.
215 	 */
216 	public void setCommandType(GdaCommandType type)
217 	{
218 		// void gda_command_set_command_type (GdaCommand *cmd,  GdaCommandType type);
219 		gda_command_set_command_type(gdaCommand, type);
220 	}
221 	
222 	/**
223 	 * Gets the command options of cmd.
224 	 * Returns: the command options of cmd.
225 	 */
226 	public GdaCommandOptions getOptions()
227 	{
228 		// GdaCommandOptions gda_command_get_options (GdaCommand *cmd);
229 		return gda_command_get_options(gdaCommand);
230 	}
231 	
232 	/**
233 	 * Sets the command options of cmd. If there conflicting options, it will just
234 	 * leave the value as before.
235 	 * Params:
236 	 * options = the command options.
237 	 */
238 	public void setOptions(GdaCommandOptions options)
239 	{
240 		// void gda_command_set_options (GdaCommand *cmd,  GdaCommandOptions options);
241 		gda_command_set_options(gdaCommand, options);
242 	}
243 	
244 	/**
245 	 * Gets the GdaTransaction associated with the given GdaCommand.
246 	 * Returns: the transaction for the command.
247 	 */
248 	public Transaction getTransaction()
249 	{
250 		// GdaTransaction* gda_command_get_transaction (GdaCommand *cmd);
251 		auto p = gda_command_get_transaction(gdaCommand);
252 		
253 		if(p is null)
254 		{
255 			return null;
256 		}
257 		
258 		return ObjectG.getDObject!(Transaction)(cast(GdaTransaction*) p);
259 	}
260 	
261 	/**
262 	 * Sets the GdaTransaction associated with the given GdaCommand.
263 	 * Params:
264 	 * xaction = a GdaTransaction object.
265 	 */
266 	public void setTransaction(Transaction xaction)
267 	{
268 		// void gda_command_set_transaction (GdaCommand *cmd,  GdaTransaction *xaction);
269 		gda_command_set_transaction(gdaCommand, (xaction is null) ? null : xaction.getTransactionStruct());
270 	}
271 }