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-GdaSelect.html
27  * outPack = gda
28  * outFile = Select
29  * strct   = GdaSelect
30  * realStrct=
31  * ctorStrct=GdaDataModel
32  * clss    = Select
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GdaDataModelArray
38  * implements:
39  * prefixes:
40  * 	- gda_select_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gda.DataModel
48  * structWrap:
49  * 	- GdaDataModel* -> DataModel
50  * 	- GdaSelect* -> Select
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gda.Select;
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.DataModel;
67 
68 
69 
70 private import gda.DataModelArray;
71 
72 /**
73  */
74 public class Select : DataModelArray
75 {
76 	
77 	/** the main Gtk struct */
78 	protected GdaSelect* gdaSelect;
79 	
80 	
81 	public GdaSelect* getSelectStruct()
82 	{
83 		return gdaSelect;
84 	}
85 	
86 	
87 	/** the main Gtk struct as a void* */
88 	protected override void* getStruct()
89 	{
90 		return cast(void*)gdaSelect;
91 	}
92 	
93 	/**
94 	 * Sets our main struct and passes it to the parent class
95 	 */
96 	public this (GdaSelect* gdaSelect)
97 	{
98 		super(cast(GdaDataModelArray*)gdaSelect);
99 		this.gdaSelect = gdaSelect;
100 	}
101 	
102 	protected override void setStruct(GObject* obj)
103 	{
104 		super.setStruct(obj);
105 		gdaSelect = cast(GdaSelect*)obj;
106 	}
107 	
108 	/**
109 	 */
110 	
111 	/**
112 	 * Creates a new GdaSelect object, which allows programs to filter
113 	 * GdaDataModel's based on a given SQL SELECT command.
114 	 * A GdaSelect is just another GdaDataModel-based class, so it
115 	 * can be used in the same way any other data model class is.
116 	 * Throws: ConstructionException GTK+ fails to create the object.
117 	 */
118 	public this ()
119 	{
120 		// GdaDataModel* gda_select_new (void);
121 		auto p = gda_select_new();
122 		if(p is null)
123 		{
124 			throw new ConstructionException("null returned by gda_select_new()");
125 		}
126 		this(cast(GdaSelect*) p);
127 	}
128 	
129 	/**
130 	 * Adds a data model as a source of data for the GdaSelect object. When
131 	 * the select object is run (via gda_select_run), it will parse the SQL
132 	 * and get the required data from the source data models.
133 	 * Params:
134 	 * name = name to identify the data model (usually a table name).
135 	 * source = a GdaDataModel from which to get data.
136 	 */
137 	public void addSource(string name, DataModel source)
138 	{
139 		// void gda_select_add_source (GdaSelect *sel,  const gchar *name,  GdaDataModel *source);
140 		gda_select_add_source(gdaSelect, Str.toStringz(name), (source is null) ? null : source.getDataModelStruct());
141 	}
142 	
143 	/**
144 	 * Sets the SQL command to be used on the given GdaSelect object
145 	 * for filtering rows from the source data model (which is
146 	 * set with gda_select_set_source).
147 	 * Params:
148 	 * sql = the SQL command to be used for filtering rows.
149 	 */
150 	public void setSql(string sql)
151 	{
152 		// void gda_select_set_sql (GdaSelect *sel,  const gchar *sql);
153 		gda_select_set_sql(gdaSelect, Str.toStringz(sql));
154 	}
155 	
156 	/**
157 	 * Runs the query and fills in the GdaSelect object with the
158 	 * rows that matched the SQL command (which can be set with
159 	 * gda_select_set_sql) associated with this GdaSelect
160 	 * object.
161 	 * After calling this function, if everything is successful,
162 	 * the GdaSelect object will contain the matched rows, which
163 	 * can then be accessed like a normal GdaDataModel.
164 	 * Returns: TRUE if successful, FALSE if there was an error.
165 	 */
166 	public int run()
167 	{
168 		// gboolean gda_select_run (GdaSelect *sel);
169 		return gda_select_run(gdaSelect);
170 	}
171 }