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-GdaTable.html
27  * outPack = gda
28  * outFile = Table
29  * strct   = GdaTable
30  * realStrct=
31  * ctorStrct=
32  * clss    = Table
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GdaDataModelArray
38  * implements:
39  * prefixes:
40  * 	- gda_table_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gda.DataModel
48  * 	- gda.FieldAttributes
49  * structWrap:
50  * 	- GdaDataModel* -> DataModel
51  * 	- GdaFieldAttributes* -> FieldAttributes
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gda.Table;
58 
59 public  import gdac.gdatypes;
60 
61 private import gdac.gda;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 
66 private import glib.Str;
67 private import gda.DataModel;
68 private import gda.FieldAttributes;
69 
70 
71 
72 private import gda.DataModelArray;
73 
74 /**
75  * Description
76  */
77 public class Table : DataModelArray
78 {
79 	
80 	/** the main Gtk struct */
81 	protected GdaTable* gdaTable;
82 	
83 	
84 	public GdaTable* getTableStruct()
85 	{
86 		return gdaTable;
87 	}
88 	
89 	
90 	/** the main Gtk struct as a void* */
91 	protected override void* getStruct()
92 	{
93 		return cast(void*)gdaTable;
94 	}
95 	
96 	/**
97 	 * Sets our main struct and passes it to the parent class
98 	 */
99 	public this (GdaTable* gdaTable)
100 	{
101 		super(cast(GdaDataModelArray*)gdaTable);
102 		this.gdaTable = gdaTable;
103 	}
104 	
105 	protected override void setStruct(GObject* obj)
106 	{
107 		super.setStruct(obj);
108 		gdaTable = cast(GdaTable*)obj;
109 	}
110 	
111 	/**
112 	 */
113 	
114 	/**
115 	 * Creates a new GdaTable object, which is an in-memory representation
116 	 * of an entire table. It is mainly used by the GdaXmlDatabase class,
117 	 * but you can also use it in your applications for whatever you may need
118 	 * it.
119 	 * Params:
120 	 * name = name for the new table.
121 	 * Throws: ConstructionException GTK+ fails to create the object.
122 	 */
123 	public this (string name)
124 	{
125 		// GdaTable* gda_table_new (const gchar *name);
126 		auto p = gda_table_new(Str.toStringz(name));
127 		if(p is null)
128 		{
129 			throw new ConstructionException("null returned by gda_table_new(Str.toStringz(name))");
130 		}
131 		this(cast(GdaTable*) p);
132 	}
133 	
134 	/**
135 	 * Creates a GdaTable object from the given GdaDataModel. This
136 	 * is very useful to maintain an in-memory copy of a given
137 	 * recordset obtained from a database. This is also used when
138 	 * exporting data to a GdaXmlDatabase object.
139 	 * Params:
140 	 * name = name for the new table.
141 	 * model = model to create the table from.
142 	 * addData = whether to add model's data or not.
143 	 * Throws: ConstructionException GTK+ fails to create the object.
144 	 */
145 	public this (string name, DataModel model, int addData)
146 	{
147 		// GdaTable* gda_table_new_from_model (const gchar *name,  const GdaDataModel *model,  gboolean add_data);
148 		auto p = gda_table_new_from_model(Str.toStringz(name), (model is null) ? null : model.getDataModelStruct(), addData);
149 		if(p is null)
150 		{
151 			throw new ConstructionException("null returned by gda_table_new_from_model(Str.toStringz(name), (model is null) ? null : model.getDataModelStruct(), addData)");
152 		}
153 		this(cast(GdaTable*) p);
154 	}
155 	
156 	/**
157 	 * Returns: the name of the given GdaTable.
158 	 */
159 	public string getName()
160 	{
161 		// const gchar* gda_table_get_name (GdaTable *table);
162 		return Str.toString(gda_table_get_name(gdaTable));
163 	}
164 	
165 	/**
166 	 * Sets the name of the given GdaTable.
167 	 * Params:
168 	 * name = new name for the table.
169 	 */
170 	public void setName(string name)
171 	{
172 		// void gda_table_set_name (GdaTable *table,  const gchar *name);
173 		gda_table_set_name(gdaTable, Str.toStringz(name));
174 	}
175 	
176 	/**
177 	 * Adds a field to the given GdaTable.
178 	 * Params:
179 	 * fa = attributes for the new field.
180 	 */
181 	public void addField(FieldAttributes fa)
182 	{
183 		// void gda_table_add_field (GdaTable *table,  const GdaFieldAttributes *fa);
184 		gda_table_add_field(gdaTable, (fa is null) ? null : fa.getFieldAttributesStruct());
185 	}
186 	
187 	/**
188 	 * Adds data in the given table from the given model.
189 	 * Params:
190 	 * model = a GdaDataModel object.
191 	 */
192 	public void addDataFromModel(DataModel model)
193 	{
194 		// void gda_table_add_data_from_model (GdaTable *table,  const GdaDataModel *model);
195 		gda_table_add_data_from_model(gdaTable, (model is null) ? null : model.getDataModelStruct());
196 	}
197 }