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