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 * Description 74 */ 75 public class Select : DataModelArray 76 { 77 78 /** the main Gtk struct */ 79 protected GdaSelect* gdaSelect; 80 81 82 public GdaSelect* getSelectStruct() 83 { 84 return gdaSelect; 85 } 86 87 88 /** the main Gtk struct as a void* */ 89 protected override void* getStruct() 90 { 91 return cast(void*)gdaSelect; 92 } 93 94 /** 95 * Sets our main struct and passes it to the parent class 96 */ 97 public this (GdaSelect* gdaSelect) 98 { 99 super(cast(GdaDataModelArray*)gdaSelect); 100 this.gdaSelect = gdaSelect; 101 } 102 103 protected override void setStruct(GObject* obj) 104 { 105 super.setStruct(obj); 106 gdaSelect = cast(GdaSelect*)obj; 107 } 108 109 /** 110 */ 111 112 /** 113 * Creates a new GdaSelect object, which allows programs to filter 114 * GdaDataModel's based on a given SQL SELECT command. 115 * A GdaSelect is just another GdaDataModel-based class, so it 116 * can be used in the same way any other data model class is. 117 * Throws: ConstructionException GTK+ fails to create the object. 118 */ 119 public this () 120 { 121 // GdaDataModel* gda_select_new (void); 122 auto p = gda_select_new(); 123 if(p is null) 124 { 125 throw new ConstructionException("null returned by gda_select_new()"); 126 } 127 this(cast(GdaSelect*) p); 128 } 129 130 /** 131 * Adds a data model as a source of data for the GdaSelect object. When 132 * the select object is run (via gda_select_run), it will parse the SQL 133 * and get the required data from the source data models. 134 * Params: 135 * name = name to identify the data model (usually a table name). 136 * source = a GdaDataModel from which to get data. 137 */ 138 public void addSource(string name, DataModel source) 139 { 140 // void gda_select_add_source (GdaSelect *sel, const gchar *name, GdaDataModel *source); 141 gda_select_add_source(gdaSelect, Str.toStringz(name), (source is null) ? null : source.getDataModelStruct()); 142 } 143 144 /** 145 * Sets the SQL command to be used on the given GdaSelect object 146 * for filtering rows from the source data model (which is 147 * set with gda_select_set_source). 148 * Params: 149 * sql = the SQL command to be used for filtering rows. 150 */ 151 public void setSql(string sql) 152 { 153 // void gda_select_set_sql (GdaSelect *sel, const gchar *sql); 154 gda_select_set_sql(gdaSelect, Str.toStringz(sql)); 155 } 156 157 /** 158 * Runs the query and fills in the GdaSelect object with the 159 * rows that matched the SQL command (which can be set with 160 * gda_select_set_sql) associated with this GdaSelect 161 * object. 162 * After calling this function, if everything is successful, 163 * the GdaSelect object will contain the matched rows, which 164 * can then be accessed like a normal GdaDataModel. 165 * Returns: TRUE if successful, FALSE if there was an error. 166 */ 167 public int run() 168 { 169 // gboolean gda_select_run (GdaSelect *sel); 170 return gda_select_run(gdaSelect); 171 } 172 }