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-row.html
27  * outPack = gda
28  * outFile = Row
29  * strct   = GdaRow
30  * realStrct=
31  * ctorStrct=
32  * clss    = Row
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gda_row_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gda.Value
48  * 	- gda.DataModel
49  * structWrap:
50  * 	- GdaDataModel* -> DataModel
51  * 	- GdaRow* -> Row
52  * 	- GdaValue* -> Value
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gda.Row;
59 
60 public  import gdac.gdatypes;
61 
62 private import gdac.gda;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 
67 private import glib.Str;
68 private import gda.Value;
69 private import gda.DataModel;
70 
71 
72 
73 
74 /**
75  */
76 public class Row
77 {
78 	
79 	/** the main Gtk struct */
80 	protected GdaRow* gdaRow;
81 	
82 	
83 	public GdaRow* getRowStruct()
84 	{
85 		return gdaRow;
86 	}
87 	
88 	
89 	/** the main Gtk struct as a void* */
90 	protected void* getStruct()
91 	{
92 		return cast(void*)gdaRow;
93 	}
94 	
95 	/**
96 	 * Sets our main struct and passes it to the parent class
97 	 */
98 	public this (GdaRow* gdaRow)
99 	{
100 		this.gdaRow = gdaRow;
101 	}
102 	
103 	/**
104 	 */
105 	
106 	/**
107 	 * Returns:
108 	 */
109 	public static GType getType()
110 	{
111 		// GType gda_row_get_type (void);
112 		return gda_row_get_type();
113 	}
114 	
115 	/**
116 	 * Creates a GdaRow which can hold count GdaValue.
117 	 * Params:
118 	 * model = the GdaDataModel this row belongs to.
119 	 * count = number of GdaValue in the new GdaRow.
120 	 * Throws: ConstructionException GTK+ fails to create the object.
121 	 */
122 	public this (DataModel model, int count)
123 	{
124 		// GdaRow* gda_row_new (GdaDataModel *model,  gint count);
125 		auto p = gda_row_new((model is null) ? null : model.getDataModelStruct(), count);
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by gda_row_new((model is null) ? null : model.getDataModelStruct(), count)");
129 		}
130 		this(cast(GdaRow*) p);
131 	}
132 	
133 	/**
134 	 * Creates a GdaRow from a list of GdaValue's. These GdaValue's are
135 	 * value-copied and the user are still resposible for freeing them.
136 	 * Params:
137 	 * model = a GdaDataModel.
138 	 * values = a list of GdaValue's.
139 	 * Throws: ConstructionException GTK+ fails to create the object.
140 	 */
141 	public this (DataModel model, GList* values)
142 	{
143 		// GdaRow* gda_row_new_from_list (GdaDataModel *model,  const GList *values);
144 		auto p = gda_row_new_from_list((model is null) ? null : model.getDataModelStruct(), values);
145 		if(p is null)
146 		{
147 			throw new ConstructionException("null returned by gda_row_new_from_list((model is null) ? null : model.getDataModelStruct(), values)");
148 		}
149 		this(cast(GdaRow*) p);
150 	}
151 	
152 	/**
153 	 * Creates a new GdaRow from an existing one.
154 	 * Returns: a newly allocated GdaRow with a copy of the data in row.
155 	 */
156 	public Row copy()
157 	{
158 		// GdaRow* gda_row_copy (GdaRow *row);
159 		auto p = gda_row_copy(gdaRow);
160 		
161 		if(p is null)
162 		{
163 			return null;
164 		}
165 		
166 		return ObjectG.getDObject!(Row)(cast(GdaRow*) p);
167 	}
168 	
169 	/**
170 	 * Deallocates all memory associated to a GdaRow.
171 	 */
172 	public void free()
173 	{
174 		// void gda_row_free (GdaRow *row);
175 		gda_row_free(gdaRow);
176 	}
177 	
178 	/**
179 	 * Gets the GdaDataModel the given GdaRow belongs to.
180 	 * Returns: a GdaDataModel.
181 	 */
182 	public DataModel getModel()
183 	{
184 		// GdaDataModel* gda_row_get_model (GdaRow *row);
185 		auto p = gda_row_get_model(gdaRow);
186 		
187 		if(p is null)
188 		{
189 			return null;
190 		}
191 		
192 		return ObjectG.getDObject!(DataModel)(cast(GdaDataModel*) p);
193 	}
194 	
195 	/**
196 	 * Gets the number of the given row, that is, its position in its containing
197 	 * data model.
198 	 * Returns: the row number, or -1 if there was an error.
199 	 */
200 	public int getNumber()
201 	{
202 		// gint gda_row_get_number (GdaRow *row);
203 		return gda_row_get_number(gdaRow);
204 	}
205 	
206 	/**
207 	 * Sets the row number for the given row.
208 	 * Params:
209 	 * number = the new row number.
210 	 */
211 	public void setNumber(int number)
212 	{
213 		// void gda_row_set_number (GdaRow *row,  gint number);
214 		gda_row_set_number(gdaRow, number);
215 	}
216 	
217 	/**
218 	 * Returns the unique identifier for this row. This identifier is
219 	 * assigned by the different providers, to uniquely identify
220 	 * rows returned to clients. If there is no ID, this means that
221 	 * the row has not been created by a provider, or that it the
222 	 * provider cannot identify it (ie, modifications to it won't
223 	 * take place into the database).
224 	 * Returns: the unique identifier for this row.
225 	 */
226 	public string getId()
227 	{
228 		// const gchar* gda_row_get_id (GdaRow *row);
229 		return Str.toString(gda_row_get_id(gdaRow));
230 	}
231 	
232 	/**
233 	 * Assigns a new identifier to the given row. This function is
234 	 * usually called by providers.
235 	 * Params:
236 	 * id = new identifier for the row.
237 	 */
238 	public void setId(string id)
239 	{
240 		// void gda_row_set_id (GdaRow *row,  const gchar *id);
241 		gda_row_set_id(gdaRow, Str.toStringz(id));
242 	}
243 	
244 	/**
245 	 * Gets a pointer to a GdaValue stored in a GdaRow.
246 	 * This is a pointer to the internal array of values. Don't try to free
247 	 * or modify it!
248 	 * Params:
249 	 * num = field index.
250 	 * Returns: a pointer to the GdaValue in the position num of row.
251 	 */
252 	public Value getValue(int num)
253 	{
254 		// GdaValue* gda_row_get_value (GdaRow *row,  gint num);
255 		auto p = gda_row_get_value(gdaRow, num);
256 		
257 		if(p is null)
258 		{
259 			return null;
260 		}
261 		
262 		return ObjectG.getDObject!(Value)(cast(GdaValue*) p);
263 	}
264 	
265 	/**
266 	 * Returns: the number of columns that the row has.
267 	 */
268 	public int getLength()
269 	{
270 		// gint gda_row_get_length (GdaRow *row);
271 		return gda_row_get_length(gdaRow);
272 	}
273 }