alternative to assert
[gtkD.git] / gtkD / srcgda / gda / Blob.d
blob7c685fedb6080f12637e98ed919ae943e17ab825
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = libgda-gda-blob.html
26 * outPack = gda
27 * outFile = Blob
28 * strct = GdaBlob
29 * realStrct=
30 * ctorStrct=
31 * clss = Blob
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gda_blob_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * structWrap:
45 * - GdaBlob* -> Blob
46 * module aliases:
47 * local aliases:
50 module gda.Blob;
52 version(noAssert)
54 version(Tango)
56 import tango.io.Stdout; // use the tango loging?
60 private import gdac.gdatypes;
62 private import gdac.gda;
69 /**
70 * Description
72 public class Blob
75 /** the main Gtk struct */
76 protected GdaBlob* gdaBlob;
79 public GdaBlob* getBlobStruct()
81 return gdaBlob;
85 /** the main Gtk struct as a void* */
86 protected void* getStruct()
88 return cast(void*)gdaBlob;
91 /**
92 * Sets our main struct and passes it to the parent class
94 public this (GdaBlob* gdaBlob)
96 version(noAssert)
98 if ( gdaBlob is null )
100 int zero = 0;
101 version(Tango)
103 Stdout("struct gdaBlob is null on constructor").newline;
105 else
107 printf("struct gdaBlob is null on constructor");
109 zero = zero / zero;
112 else
114 assert(gdaBlob !is null, "struct gdaBlob is null on constructor");
116 this.gdaBlob = gdaBlob;
125 * Opens an existing BLOB. The BLOB must be initialized by
126 * gda_connection_create_blob or obtained from a GdaValue.
127 * blob :
128 * a GdaBlob structure obtained from a GdaValue or allocated by the
129 * user when he/she wants to create a new GdaBlob.
130 * mode :
131 * see GdaBlobMode.
132 * Returns :
133 * 0 if everything's ok. In case of error, -1 is returned and the
134 * provider should have added an error to the connection.
136 public int open(GdaBlobMode mode)
138 // gint gda_blob_open (GdaBlob *blob, GdaBlobMode mode);
139 return gda_blob_open(gdaBlob, mode);
143 * Reads a chunk of bytes from the BLOB into a user-provided location.
144 * blob :
145 * a GdaBlob which is opened with the flag GDA_BLOB_MODE_READ set.
146 * buf :
147 * buffer to read the data into.
148 * size :
149 * maximum number of bytes to read.
150 * bytes_read :
151 * on return it will point to the number of bytes actually read.
152 * Returns :
153 * 0 if everything's ok. In case of error, -1 is returned and the
154 * provider should have added an error to the connection.
156 public int read(void* buf, int size, int* bytesRead)
158 // gint gda_blob_read (GdaBlob *blob, gpointer buf, gint size, gint *bytes_read);
159 return gda_blob_read(gdaBlob, buf, size, bytesRead);
163 * Writes a chunk of bytes from a user-provided location to the BLOB.
164 * blob :
165 * a GdaBlob which is opened with the flag GDA_BLOB_MODE_WRITE set.
166 * buf :
167 * buffer to write the data from.
168 * size :
169 * maximum number of bytes to read.
170 * bytes_written :
171 * on return it will point to the number of bytes actually written.
172 * Returns :
173 * 0 if everything's ok. In case of error, -1 is returned and the
174 * provider should have added an error to the connection.
176 public int write(void* buf, int size, int* bytesWritten)
178 // gint gda_blob_write (GdaBlob *blob, gpointer buf, gint size, gint *bytes_written);
179 return gda_blob_write(gdaBlob, buf, size, bytesWritten);
183 * Sets the blob read/write position.
184 * blob :
185 * a opened GdaBlob.
186 * offset :
187 * offset added to the position specified by whence.
188 * whence :
189 * SEEK_SET, SEEK_CUR or SEEK_END with the same meaning as in fseek(3).
190 * Returns :
191 * the current position in the blob or < 0 in case of error. In case
192 * of error the provider should have added an error to the connection.
194 public int lseek(int offset, int whence)
196 // gint gda_blob_lseek (GdaBlob *blob, gint offset, gint whence);
197 return gda_blob_lseek(gdaBlob, offset, whence);
201 * Closes the BLOB. After calling this function, blob should no longer be used.
202 * blob :
203 * a opened GdaBlob.
204 * Returns :
205 * 0 if everything's ok. In case of error, -1 is returned and the
206 * provider should have added an error to the connection.
208 public int close()
210 // gint gda_blob_close (GdaBlob *blob);
211 return gda_blob_close(gdaBlob);
215 * Removes the BLOB from the database. After calling this function, blob
216 * should no longer be used.
217 * blob :
218 * a valid GdaBlob.
219 * Returns :
220 * 0 if everything's ok. In case of error, -1 is returned and the
221 * provider should have added an error to the connection.
223 public int remove()
225 // gint gda_blob_remove (GdaBlob *blob);
226 return gda_blob_remove(gdaBlob);
230 * Let the provider free any internal data stored in blob. The user
231 * is still responsible for deallocating blob itself.
232 * blob :
233 * a valid GdaBlob.
235 public void freeData()
237 // void gda_blob_free_data (GdaBlob *blob);
238 gda_blob_free_data(gdaBlob);