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  */
75 public class Gda
76 {
77 	
78 	/**
79 	 */
80 	
81 	/**
82 	 * Initializes the GDA library.
83 	 * Params:
84 	 * appId = name of the program.
85 	 * args = list of arguments, usually argv from main().
86 	 */
87 	public static void init(string appId, string versio, string[] args)
88 	{
89 		// void gda_init (const gchar *app_id,  const gchar *version,  gint nargs,  gchar *args[]);
90 		gda_init(Str.toStringz(appId), Str.toStringz(versio), cast(int) args.length, Str.toStringzArray(args));
91 	}
92 	
93 	/**
94 	 * Runs the GDA main loop, which is nothing more than the Bonobo main
95 	 * loop, but with internally added stuff specific for applications using
96 	 * libgda.
97 	 * You can specify a function to be called after everything has been correctly
98 	 * initialized (that is, for initializing your own stuff).
99 	 * Params:
100 	 * initFunc = function to be called when everything has been initialized.
101 	 * userData = data to be passed to the init function.
102 	 */
103 	public static void mainRun(GdaInitFunc initFunc, void* userData)
104 	{
105 		// void gda_main_run (GdaInitFunc init_func,  gpointer user_data);
106 		gda_main_run(initFunc, userData);
107 	}
108 	
109 	/**
110 	 * Exits the main loop.
111 	 */
112 	public static void mainQuit()
113 	{
114 		// void gda_main_quit (void);
115 		gda_main_quit();
116 	}
117 	
118 	/**
119 	 * Params:
120 	 * type = Type to convert from.
121 	 * 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.
122 	 */
123 	public static string typeToString(GdaValueType type)
124 	{
125 		// const gchar* gda_type_to_string (GdaValueType type);
126 		return Str.toString(gda_type_to_string(type));
127 	}
128 	
129 	/**
130 	 * Params:
131 	 * str = the name of a GdaValueType, as returned by gda_type_to_string().
132 	 * Returns: the GdaValueType represented by the given str.
133 	 */
134 	public static GdaValueType typeFromString(string str)
135 	{
136 		// GdaValueType gda_type_from_string (const gchar *str);
137 		return gda_type_from_string(Str.toStringz(str));
138 	}
139 	
140 	/**
141 	 * Creates a new list of strings, which contains all keys of a given hash
142 	 * table. After using it, you should free this list by calling g_list_free.
143 	 * Params:
144 	 * hashTable = a hash table.
145 	 * Returns: a new GList.
146 	 */
147 	public static ListG stringHashToList(HashTable hashTable)
148 	{
149 		// GList* gda_string_hash_to_list (GHashTable *hash_table);
150 		auto p = gda_string_hash_to_list((hashTable is null) ? null : hashTable.getHashTableStruct());
151 		
152 		if(p is null)
153 		{
154 			return null;
155 		}
156 		
157 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
158 	}
159 	
160 	/**
161 	 * Replaces the placeholders (:name) in the given SQL command with
162 	 * the values from the GdaParameterList specified as the params
163 	 * argument.
164 	 * Params:
165 	 * sql = a SQL command containing placeholders for values.
166 	 * params = a list of values for the placeholders.
167 	 * 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.
168 	 */
169 	public static string sqlReplacePlaceholders(string sql, ParameterList params)
170 	{
171 		// gchar* gda_sql_replace_placeholders (const gchar *sql,  GdaParameterList *params);
172 		return Str.toString(gda_sql_replace_placeholders(Str.toStringz(sql), (params is null) ? null : params.getParameterListStruct()));
173 	}
174 	
175 	/**
176 	 * Loads a file, specified by the given uri, and returns the file
177 	 * contents as a string.
178 	 * It is the caller's responsibility to free the returned value.
179 	 * Params:
180 	 * filename = path for the file to be loaded.
181 	 * Returns: the file contents as a newly-allocated string, or NULL if there is an error.
182 	 */
183 	public static string fileLoad(string filename)
184 	{
185 		// gchar* gda_file_load (const gchar *filename);
186 		return Str.toString(gda_file_load(Str.toStringz(filename)));
187 	}
188 	
189 	/**
190 	 * Saves a chunk of data into a file.
191 	 * Params:
192 	 * filename = path for the file to be saved.
193 	 * buffer = contents of the file.
194 	 * len = size of buffer.
195 	 * Returns: TRUE if successful, FALSE on error.
196 	 */
197 	public static int fileSave(string filename, string buffer, int len)
198 	{
199 		// gboolean gda_file_save (const gchar *filename,  const gchar *buffer,  gint len);
200 		return gda_file_save(Str.toStringz(filename), Str.toStringz(buffer), len);
201 	}
202 }