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