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