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