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