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  */
76 public class Table : DataModelArray
77 {
78 	
79 	/** the main Gtk struct */
80 	protected GdaTable* gdaTable;
81 	
82 	
83 	public GdaTable* getTableStruct()
84 	{
85 		return gdaTable;
86 	}
87 	
88 	
89 	/** the main Gtk struct as a void* */
90 	protected override void* getStruct()
91 	{
92 		return cast(void*)gdaTable;
93 	}
94 	
95 	/**
96 	 * Sets our main struct and passes it to the parent class
97 	 */
98 	public this (GdaTable* gdaTable)
99 	{
100 		super(cast(GdaDataModelArray*)gdaTable);
101 		this.gdaTable = gdaTable;
102 	}
103 	
104 	protected override void setStruct(GObject* obj)
105 	{
106 		super.setStruct(obj);
107 		gdaTable = cast(GdaTable*)obj;
108 	}
109 	
110 	/**
111 	 */
112 	
113 	/**
114 	 * Creates a new GdaTable object, which is an in-memory representation
115 	 * of an entire table. It is mainly used by the GdaXmlDatabase class,
116 	 * but you can also use it in your applications for whatever you may need
117 	 * it.
118 	 * Params:
119 	 * name = name for the new table.
120 	 * Throws: ConstructionException GTK+ fails to create the object.
121 	 */
122 	public this (string name)
123 	{
124 		// GdaTable* gda_table_new (const gchar *name);
125 		auto p = gda_table_new(Str.toStringz(name));
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by gda_table_new(Str.toStringz(name))");
129 		}
130 		this(cast(GdaTable*) p);
131 	}
132 	
133 	/**
134 	 * Creates a GdaTable object from the given GdaDataModel. This
135 	 * is very useful to maintain an in-memory copy of a given
136 	 * recordset obtained from a database. This is also used when
137 	 * exporting data to a GdaXmlDatabase object.
138 	 * Params:
139 	 * name = name for the new table.
140 	 * model = model to create the table from.
141 	 * addData = whether to add model's data or not.
142 	 * Throws: ConstructionException GTK+ fails to create the object.
143 	 */
144 	public this (string name, DataModel model, int addData)
145 	{
146 		// GdaTable* gda_table_new_from_model (const gchar *name,  const GdaDataModel *model,  gboolean add_data);
147 		auto p = gda_table_new_from_model(Str.toStringz(name), (model is null) ? null : model.getDataModelStruct(), addData);
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by gda_table_new_from_model(Str.toStringz(name), (model is null) ? null : model.getDataModelStruct(), addData)");
151 		}
152 		this(cast(GdaTable*) p);
153 	}
154 	
155 	/**
156 	 * Returns: the name of the given GdaTable.
157 	 */
158 	public string getName()
159 	{
160 		// const gchar* gda_table_get_name (GdaTable *table);
161 		return Str.toString(gda_table_get_name(gdaTable));
162 	}
163 	
164 	/**
165 	 * Sets the name of the given GdaTable.
166 	 * Params:
167 	 * name = new name for the table.
168 	 */
169 	public void setName(string name)
170 	{
171 		// void gda_table_set_name (GdaTable *table,  const gchar *name);
172 		gda_table_set_name(gdaTable, Str.toStringz(name));
173 	}
174 	
175 	/**
176 	 * Adds a field to the given GdaTable.
177 	 * Params:
178 	 * fa = attributes for the new field.
179 	 */
180 	public void addField(FieldAttributes fa)
181 	{
182 		// void gda_table_add_field (GdaTable *table,  const GdaFieldAttributes *fa);
183 		gda_table_add_field(gdaTable, (fa is null) ? null : fa.getFieldAttributesStruct());
184 	}
185 	
186 	/**
187 	 * Adds data in the given table from the given model.
188 	 * Params:
189 	 * model = a GdaDataModel object.
190 	 */
191 	public void addDataFromModel(DataModel model)
192 	{
193 		// void gda_table_add_data_from_model (GdaTable *table,  const GdaDataModel *model);
194 		gda_table_add_data_from_model(gdaTable, (model is null) ? null : model.getDataModelStruct());
195 	}
196 }