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-libgda.html
27  * outPack = gda
28  * outFile = Gda
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = Gda
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gda_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.HashTable
48  * 	- glib.ListG
49  * 	- gda.ParameterList
50  * structWrap:
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gda.Gda;
57 
58 public  import gdac.gdatypes;
59 
60 private import gdac.gda;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 
65 private import glib.Str;
66 private import glib.HashTable;
67 private import glib.ListG;
68 private import gda.ParameterList;
69 
70 
71 
72 
73 /**
74  * Description
75  */
76 public class Gda
77 {
78 	
79 	/**
80 	 * Description
81 	 */
82 	
83 	/**
84 	 * Initializes the GDA library.
85 	 * Params:
86 	 * appId = name of the program.
87 	 * args = list of arguments, usually argv from main().
88 	 */
89 	public static void init(string appId, string versio, string[] args)
90 	{
91 		// void gda_init (const gchar *app_id,  const gchar *version,  gint nargs,  gchar *args[]);
92 		gda_init(Str.toStringz(appId), Str.toStringz(versio), cast(int) args.length, Str.toStringzArray(args));
93 	}
94 	
95 	/**
96 	 * Runs the GDA main loop, which is nothing more than the Bonobo main
97 	 * loop, but with internally added stuff specific for applications using
98 	 * libgda.
99 	 * You can specify a function to be called after everything has been correctly
100 	 * initialized (that is, for initializing your own stuff).
101 	 * Params:
102 	 * initFunc = function to be called when everything has been initialized.
103 	 * userData = data to be passed to the init function.
104 	 */
105 	public static void mainRun(GdaInitFunc initFunc, void* userData)
106 	{
107 		// void gda_main_run (GdaInitFunc init_func,  gpointer user_data);
108 		gda_main_run(initFunc, userData);
109 	}
110 	
111 	/**
112 	 * Exits the main loop.
113 	 */
114 	public static void mainQuit()
115 	{
116 		// void gda_main_quit (void);
117 		gda_main_quit();
118 	}
119 	
120 	/**
121 	 * Params:
122 	 * type = Type to convert from.
123 	 * Returns: the string representing the given GdaValueType. This is not necessarily the same string used to describe the column type in a SQL statement. Use gda_connection_get_schema() with GDA_CONNECTION_SCHEMA_TYPES to get the actual types supported by the provider.
124 	 */
125 	public static string typeToString(GdaValueType type)
126 	{
127 		// const gchar* gda_type_to_string (GdaValueType type);
128 		return Str.toString(gda_type_to_string(type));
129 	}
130 	
131 	/**
132 	 * Params:
133 	 * str = the name of a GdaValueType, as returned by gda_type_to_string().
134 	 * Returns: the GdaValueType represented by the given str.
135 	 */
136 	public static GdaValueType typeFromString(string str)
137 	{
138 		// GdaValueType gda_type_from_string (const gchar *str);
139 		return gda_type_from_string(Str.toStringz(str));
140 	}
141 	
142 	/**
143 	 * Creates a new list of strings, which contains all keys of a given hash
144 	 * table. After using it, you should free this list by calling g_list_free.
145 	 * Params:
146 	 * hashTable = a hash table.
147 	 * Returns: a new GList.
148 	 */
149 	public static ListG stringHashToList(HashTable hashTable)
150 	{
151 		// GList* gda_string_hash_to_list (GHashTable *hash_table);
152 		auto p = gda_string_hash_to_list((hashTable is null) ? null : hashTable.getHashTableStruct());
153 		
154 		if(p is null)
155 		{
156 			return null;
157 		}
158 		
159 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
160 	}
161 	
162 	/**
163 	 * Replaces the placeholders (:name) in the given SQL command with
164 	 * the values from the GdaParameterList specified as the params
165 	 * argument.
166 	 * Params:
167 	 * sql = a SQL command containing placeholders for values.
168 	 * params = a list of values for the placeholders.
169 	 * Returns: the SQL string with all placeholders replaced, or NULL on error. On success, the returned string must be freed by the caller when no longer needed.
170 	 */
171 	public static string sqlReplacePlaceholders(string sql, ParameterList params)
172 	{
173 		// gchar* gda_sql_replace_placeholders (const gchar *sql,  GdaParameterList *params);
174 		return Str.toString(gda_sql_replace_placeholders(Str.toStringz(sql), (params is null) ? null : params.getParameterListStruct()));
175 	}
176 	
177 	/**
178 	 * Loads a file, specified by the given uri, and returns the file
179 	 * contents as a string.
180 	 * It is the caller's responsibility to free the returned value.
181 	 * Params:
182 	 * filename = path for the file to be loaded.
183 	 * Returns: the file contents as a newly-allocated string, or NULL if there is an error.
184 	 */
185 	public static string fileLoad(string filename)
186 	{
187 		// gchar* gda_file_load (const gchar *filename);
188 		return Str.toString(gda_file_load(Str.toStringz(filename)));
189 	}
190 	
191 	/**
192 	 * Saves a chunk of data into a file.
193 	 * Params:
194 	 * filename = path for the file to be saved.
195 	 * buffer = contents of the file.
196 	 * len = size of buffer.
197 	 * Returns: TRUE if successful, FALSE on error.
198 	 */
199 	public static int fileSave(string filename, string buffer, int len)
200 	{
201 		// gboolean gda_file_save (const gchar *filename,  const gchar *buffer,  gint len);
202 		return gda_file_save(Str.toStringz(filename), Str.toStringz(buffer), len);
203 	}
204 }