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