| 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 = GDataInputStream.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = DataInputStream |
|---|
| 29 |
* strct = GDataInputStream |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = DataInputStream |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_data_input_stream_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* - g_data_input_stream_read_byte |
|---|
| 45 |
* omit signals: |
|---|
| 46 |
* imports: |
|---|
| 47 |
* - glib.Str |
|---|
| 48 |
* - glib.ErrorG |
|---|
| 49 |
* - glib.GException |
|---|
| 50 |
* - gio.Cancellable |
|---|
| 51 |
* - gio.InputStream |
|---|
| 52 |
* structWrap: |
|---|
| 53 |
* - GCancellable* -> Cancellable |
|---|
| 54 |
* - GInputStream* -> InputStream |
|---|
| 55 |
* module aliases: |
|---|
| 56 |
* local aliases: |
|---|
| 57 |
* overrides: |
|---|
| 58 |
*/ |
|---|
| 59 |
|
|---|
| 60 |
module gio.DataInputStream; |
|---|
| 61 |
|
|---|
| 62 |
public import gtkc.giotypes; |
|---|
| 63 |
|
|---|
| 64 |
private import gtkc.gio; |
|---|
| 65 |
private import glib.ConstructionException; |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
private import glib.Str; |
|---|
| 69 |
private import glib.ErrorG; |
|---|
| 70 |
private import glib.GException; |
|---|
| 71 |
private import gio.Cancellable; |
|---|
| 72 |
private import gio.InputStream; |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
private import gio.BufferedInputStream; |
|---|
| 77 |
|
|---|
| 78 |
/** |
|---|
| 79 |
* Description |
|---|
| 80 |
* Data input stream implements GInputStream and includes functions for |
|---|
| 81 |
* reading structured data directly from a binary input stream. |
|---|
| 82 |
*/ |
|---|
| 83 |
public class DataInputStream : BufferedInputStream |
|---|
| 84 |
{ |
|---|
| 85 |
|
|---|
| 86 |
/** the main Gtk struct */ |
|---|
| 87 |
protected GDataInputStream* gDataInputStream; |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
public GDataInputStream* getDataInputStreamStruct() |
|---|
| 91 |
{ |
|---|
| 92 |
return gDataInputStream; |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
/** the main Gtk struct as a void* */ |
|---|
| 97 |
protected override void* getStruct() |
|---|
| 98 |
{ |
|---|
| 99 |
return cast(void*)gDataInputStream; |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|
| 102 |
/** |
|---|
| 103 |
* Sets our main struct and passes it to the parent class |
|---|
| 104 |
*/ |
|---|
| 105 |
public this (GDataInputStream* gDataInputStream) |
|---|
| 106 |
{ |
|---|
| 107 |
if(gDataInputStream is null) |
|---|
| 108 |
{ |
|---|
| 109 |
this = null; |
|---|
| 110 |
return; |
|---|
| 111 |
} |
|---|
| 112 |
//Check if there already is a D object for this gtk struct |
|---|
| 113 |
void* ptr = getDObject(cast(GObject*)gDataInputStream); |
|---|
| 114 |
if( ptr !is null ) |
|---|
| 115 |
{ |
|---|
| 116 |
this = cast(DataInputStream)ptr; |
|---|
| 117 |
return; |
|---|
| 118 |
} |
|---|
| 119 |
super(cast(GBufferedInputStream*)gDataInputStream); |
|---|
| 120 |
this.gDataInputStream = gDataInputStream; |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
protected override void setStruct(GObject* obj) |
|---|
| 124 |
{ |
|---|
| 125 |
super.setStruct(obj); |
|---|
| 126 |
gDataInputStream = cast(GDataInputStream*)obj; |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
/** |
|---|
| 130 |
*/ |
|---|
| 131 |
|
|---|
| 132 |
/** |
|---|
| 133 |
* Creates a new data input stream for the base_stream. |
|---|
| 134 |
* Params: |
|---|
| 135 |
* baseStream = a GInputStream. |
|---|
| 136 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 137 |
*/ |
|---|
| 138 |
public this (InputStream baseStream) |
|---|
| 139 |
{ |
|---|
| 140 |
// GDataInputStream * g_data_input_stream_new (GInputStream *base_stream); |
|---|
| 141 |
auto p = g_data_input_stream_new((baseStream is null) ? null : baseStream.getInputStreamStruct()); |
|---|
| 142 |
if(p is null) |
|---|
| 143 |
{ |
|---|
| 144 |
throw new ConstructionException("null returned by g_data_input_stream_new((baseStream is null) ? null : baseStream.getInputStreamStruct())"); |
|---|
| 145 |
} |
|---|
| 146 |
this(cast(GDataInputStream*) p); |
|---|
| 147 |
} |
|---|
| 148 |
|
|---|
| 149 |
/** |
|---|
| 150 |
* This function sets the byte order for the given stream. All subsequent |
|---|
| 151 |
* reads from the stream will be read in the given order. |
|---|
| 152 |
* Params: |
|---|
| 153 |
* order = a GDataStreamByteOrder to set. |
|---|
| 154 |
*/ |
|---|
| 155 |
public void setByteOrder(GDataStreamByteOrder order) |
|---|
| 156 |
{ |
|---|
| 157 |
// void g_data_input_stream_set_byte_order (GDataInputStream *stream, GDataStreamByteOrder order); |
|---|
| 158 |
g_data_input_stream_set_byte_order(gDataInputStream, order); |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
/** |
|---|
| 162 |
* Gets the byte order for the data input stream. |
|---|
| 163 |
* Returns: the stream's current GDataStreamByteOrder. |
|---|
| 164 |
*/ |
|---|
| 165 |
public GDataStreamByteOrder getByteOrder() |
|---|
| 166 |
{ |
|---|
| 167 |
// GDataStreamByteOrder g_data_input_stream_get_byte_order (GDataInputStream *stream); |
|---|
| 168 |
return g_data_input_stream_get_byte_order(gDataInputStream); |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
/** |
|---|
| 172 |
* Sets the newline type for the stream. |
|---|
| 173 |
* Note that using G_DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a read |
|---|
| 174 |
* chunk ends in "CR" we must read an additional byte to know if this is "CR" or |
|---|
| 175 |
* "CR LF", and this might block if there is no more data availible. |
|---|
| 176 |
* Params: |
|---|
| 177 |
* type = the type of new line return as GDataStreamNewlineType. |
|---|
| 178 |
*/ |
|---|
| 179 |
public void setNewlineType(GDataStreamNewlineType type) |
|---|
| 180 |
{ |
|---|
| 181 |
// void g_data_input_stream_set_newline_type (GDataInputStream *stream, GDataStreamNewlineType type); |
|---|
| 182 |
g_data_input_stream_set_newline_type(gDataInputStream, type); |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
/** |
|---|
| 186 |
* Gets the current newline type for the stream. |
|---|
| 187 |
* Returns: GDataStreamNewlineType for the given stream. |
|---|
| 188 |
*/ |
|---|
| 189 |
public GDataStreamNewlineType getNewlineType() |
|---|
| 190 |
{ |
|---|
| 191 |
// GDataStreamNewlineType g_data_input_stream_get_newline_type (GDataInputStream *stream); |
|---|
| 192 |
return g_data_input_stream_get_newline_type(gDataInputStream); |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
/** |
|---|
| 196 |
* Reads a 16-bit/2-byte value from stream. |
|---|
| 197 |
* In order to get the correct byte order for this read operation, |
|---|
| 198 |
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). |
|---|
| 199 |
* Params: |
|---|
| 200 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 201 |
* Returns: a signed 16-bit/2-byte value read from stream or 0 if an error occurred. |
|---|
| 202 |
* Throws: GException on failure. |
|---|
| 203 |
*/ |
|---|
| 204 |
public short readInt16(Cancellable cancellable) |
|---|
| 205 |
{ |
|---|
| 206 |
// gint16 g_data_input_stream_read_int16 (GDataInputStream *stream, GCancellable *cancellable, GError **error); |
|---|
| 207 |
GError* err = null; |
|---|
| 208 |
|
|---|
| 209 |
auto p = g_data_input_stream_read_int16(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 210 |
|
|---|
| 211 |
if (err !is null) |
|---|
| 212 |
{ |
|---|
| 213 |
throw new GException( new ErrorG(err) ); |
|---|
| 214 |
} |
|---|
| 215 |
|
|---|
| 216 |
return p; |
|---|
| 217 |
} |
|---|
| 218 |
|
|---|
| 219 |
/** |
|---|
| 220 |
* Reads an unsigned 16-bit/2-byte value from stream. |
|---|
| 221 |
* In order to get the correct byte order for this read operation, |
|---|
| 222 |
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). |
|---|
| 223 |
* Params: |
|---|
| 224 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 225 |
* Returns: an unsigned 16-bit/2-byte value read from the stream or 0 if an error occurred. |
|---|
| 226 |
* Throws: GException on failure. |
|---|
| 227 |
*/ |
|---|
| 228 |
public ushort readUint16(Cancellable cancellable) |
|---|
| 229 |
{ |
|---|
| 230 |
// guint16 g_data_input_stream_read_uint16 (GDataInputStream *stream, GCancellable *cancellable, GError **error); |
|---|
| 231 |
GError* err = null; |
|---|
| 232 |
|
|---|
| 233 |
auto p = g_data_input_stream_read_uint16(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 234 |
|
|---|
| 235 |
if (err !is null) |
|---|
| 236 |
{ |
|---|
| 237 |
throw new GException( new ErrorG(err) ); |
|---|
| 238 |
} |
|---|
| 239 |
|
|---|
| 240 |
return p; |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
/** |
|---|
| 244 |
* Reads a signed 32-bit/4-byte value from stream. |
|---|
| 245 |
* In order to get the correct byte order for this read operation, |
|---|
| 246 |
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). |
|---|
| 247 |
* If cancellable is not NULL, then the operation can be cancelled by |
|---|
| 248 |
* triggering the cancellable object from another thread. If the operation |
|---|
| 249 |
* was cancelled, the error G_IO_ERROR_CANCELLED will be returned. |
|---|
| 250 |
* Params: |
|---|
| 251 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 252 |
* Returns: a signed 32-bit/4-byte value read from the stream or 0 if an error occurred. |
|---|
| 253 |
* Throws: GException on failure. |
|---|
| 254 |
*/ |
|---|
| 255 |
public int readInt32(Cancellable cancellable) |
|---|
| 256 |
{ |
|---|
| 257 |
// gint32 g_data_input_stream_read_int32 (GDataInputStream *stream, GCancellable *cancellable, GError **error); |
|---|
| 258 |
GError* err = null; |
|---|
| 259 |
|
|---|
| 260 |
auto p = g_data_input_stream_read_int32(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 261 |
|
|---|
| 262 |
if (err !is null) |
|---|
| 263 |
{ |
|---|
| 264 |
throw new GException( new ErrorG(err) ); |
|---|
| 265 |
} |
|---|
| 266 |
|
|---|
| 267 |
return p; |
|---|
| 268 |
} |
|---|
| 269 |
|
|---|
| 270 |
/** |
|---|
| 271 |
* Reads an unsigned 32-bit/4-byte value from stream. |
|---|
| 272 |
* In order to get the correct byte order for this read operation, |
|---|
| 273 |
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). |
|---|
| 274 |
* If cancellable is not NULL, then the operation can be cancelled by |
|---|
| 275 |
* triggering the cancellable object from another thread. If the operation |
|---|
| 276 |
* was cancelled, the error G_IO_ERROR_CANCELLED will be returned. |
|---|
| 277 |
* Params: |
|---|
| 278 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 279 |
* Returns: an unsigned 32-bit/4-byte value read from the stream or 0 if an error occurred. |
|---|
| 280 |
* Throws: GException on failure. |
|---|
| 281 |
*/ |
|---|
| 282 |
public uint readUint32(Cancellable cancellable) |
|---|
| 283 |
{ |
|---|
| 284 |
// guint32 g_data_input_stream_read_uint32 (GDataInputStream *stream, GCancellable *cancellable, GError **error); |
|---|
| 285 |
GError* err = null; |
|---|
| 286 |
|
|---|
| 287 |
auto p = g_data_input_stream_read_uint32(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 288 |
|
|---|
| 289 |
if (err !is null) |
|---|
| 290 |
{ |
|---|
| 291 |
throw new GException( new ErrorG(err) ); |
|---|
| 292 |
} |
|---|
| 293 |
|
|---|
| 294 |
return p; |
|---|
| 295 |
} |
|---|
| 296 |
|
|---|
| 297 |
/** |
|---|
| 298 |
* Reads a 64-bit/8-byte value from stream. |
|---|
| 299 |
* In order to get the correct byte order for this read operation, |
|---|
| 300 |
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). |
|---|
| 301 |
* If cancellable is not NULL, then the operation can be cancelled by |
|---|
| 302 |
* triggering the cancellable object from another thread. If the operation |
|---|
| 303 |
* was cancelled, the error G_IO_ERROR_CANCELLED will be returned. |
|---|
| 304 |
* Params: |
|---|
| 305 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 306 |
* Returns: a signed 64-bit/8-byte value read from stream or 0 if an error occurred. |
|---|
| 307 |
* Throws: GException on failure. |
|---|
| 308 |
*/ |
|---|
| 309 |
public long readInt64(Cancellable cancellable) |
|---|
| 310 |
{ |
|---|
| 311 |
// gint64 g_data_input_stream_read_int64 (GDataInputStream *stream, GCancellable *cancellable, GError **error); |
|---|
| 312 |
GError* err = null; |
|---|
| 313 |
|
|---|
| 314 |
auto p = g_data_input_stream_read_int64(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 315 |
|
|---|
| 316 |
if (err !is null) |
|---|
| 317 |
{ |
|---|
| 318 |
throw new GException( new ErrorG(err) ); |
|---|
| 319 |
} |
|---|
| 320 |
|
|---|
| 321 |
return p; |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
/** |
|---|
| 325 |
* Reads an unsigned 64-bit/8-byte value from stream. |
|---|
| 326 |
* In order to get the correct byte order for this read operation, |
|---|
| 327 |
* see g_data_input_stream_get_byte_order(). |
|---|
| 328 |
* If cancellable is not NULL, then the operation can be cancelled by |
|---|
| 329 |
* triggering the cancellable object from another thread. If the operation |
|---|
| 330 |
* was cancelled, the error G_IO_ERROR_CANCELLED will be returned. |
|---|
| 331 |
* Params: |
|---|
| 332 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 333 |
* Returns: an unsigned 64-bit/8-byte read from stream or 0 if an error occurred. |
|---|
| 334 |
* Throws: GException on failure. |
|---|
| 335 |
*/ |
|---|
| 336 |
public ulong readUint64(Cancellable cancellable) |
|---|
| 337 |
{ |
|---|
| 338 |
// guint64 g_data_input_stream_read_uint64 (GDataInputStream *stream, GCancellable *cancellable, GError **error); |
|---|
| 339 |
GError* err = null; |
|---|
| 340 |
|
|---|
| 341 |
auto p = g_data_input_stream_read_uint64(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 342 |
|
|---|
| 343 |
if (err !is null) |
|---|
| 344 |
{ |
|---|
| 345 |
throw new GException( new ErrorG(err) ); |
|---|
| 346 |
} |
|---|
| 347 |
|
|---|
| 348 |
return p; |
|---|
| 349 |
} |
|---|
| 350 |
|
|---|
| 351 |
/** |
|---|
| 352 |
* Reads a line from the data input stream. |
|---|
| 353 |
* If cancellable is not NULL, then the operation can be cancelled by |
|---|
| 354 |
* triggering the cancellable object from another thread. If the operation |
|---|
| 355 |
* was cancelled, the error G_IO_ERROR_CANCELLED will be returned. |
|---|
| 356 |
* Params: |
|---|
| 357 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 358 |
* Returns: a string with the line that was read in (without the newlines). Set length to a gsize to get the length of the read line. On an error, it will return NULL and error will be set. If there's no content to read, it will still return NULL, but error won't be set. [transfer full] |
|---|
| 359 |
* Throws: GException on failure. |
|---|
| 360 |
*/ |
|---|
| 361 |
public string readLine(Cancellable cancellable) |
|---|
| 362 |
{ |
|---|
| 363 |
// char * g_data_input_stream_read_line (GDataInputStream *stream, gsize *length, GCancellable *cancellable, GError **error); |
|---|
| 364 |
gsize length; |
|---|
| 365 |
GError* err = null; |
|---|
| 366 |
|
|---|
| 367 |
auto p = g_data_input_stream_read_line(gDataInputStream, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 368 |
|
|---|
| 369 |
if (err !is null) |
|---|
| 370 |
{ |
|---|
| 371 |
throw new GException( new ErrorG(err) ); |
|---|
| 372 |
} |
|---|
| 373 |
|
|---|
| 374 |
return Str.toString(p, length); |
|---|
| 375 |
} |
|---|
| 376 |
|
|---|
| 377 |
/** |
|---|
| 378 |
* The asynchronous version of g_data_input_stream_read_line(). It is |
|---|
| 379 |
* an error to have two outstanding calls to this function. |
|---|
| 380 |
* When the operation is finished, callback will be called. You |
|---|
| 381 |
* can then call g_data_input_stream_read_line_finish() to get |
|---|
| 382 |
* the result of the operation. |
|---|
| 383 |
* Since 2.20 |
|---|
| 384 |
* Params: |
|---|
| 385 |
* ioPriority = the I/O priority |
|---|
| 386 |
* of the request. |
|---|
| 387 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 388 |
* callback = callback to call when the request is satisfied. [scope async] |
|---|
| 389 |
* userData = the data to pass to callback function. [closure] |
|---|
| 390 |
*/ |
|---|
| 391 |
public void readLineAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 392 |
{ |
|---|
| 393 |
// void g_data_input_stream_read_line_async (GDataInputStream *stream, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 394 |
g_data_input_stream_read_line_async(gDataInputStream, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 395 |
} |
|---|
| 396 |
|
|---|
| 397 |
/** |
|---|
| 398 |
* Finish an asynchronous call started by |
|---|
| 399 |
* g_data_input_stream_read_line_async(). |
|---|
| 400 |
* Since 2.20 |
|---|
| 401 |
* Params: |
|---|
| 402 |
* result = the GAsyncResult that was provided to the callback. |
|---|
| 403 |
* Returns: a string with the line that was read in (without the newlines). Set length to a gsize to get the length of the read line. On an error, it will return NULL and error will be set. If there's no content to read, it will still return NULL, but error won't be set. [transfer full] |
|---|
| 404 |
* Throws: GException on failure. |
|---|
| 405 |
*/ |
|---|
| 406 |
public string readLineFinish(out GAsyncResult result) |
|---|
| 407 |
{ |
|---|
| 408 |
// char * g_data_input_stream_read_line_finish (GDataInputStream *stream, GAsyncResult *result, gsize *length, GError **error); |
|---|
| 409 |
gsize length; |
|---|
| 410 |
GError* err = null; |
|---|
| 411 |
|
|---|
| 412 |
auto p = g_data_input_stream_read_line_finish(gDataInputStream, &result, &length, &err); |
|---|
| 413 |
|
|---|
| 414 |
if (err !is null) |
|---|
| 415 |
{ |
|---|
| 416 |
throw new GException( new ErrorG(err) ); |
|---|
| 417 |
} |
|---|
| 418 |
|
|---|
| 419 |
return Str.toString(p, length); |
|---|
| 420 |
} |
|---|
| 421 |
|
|---|
| 422 |
/** |
|---|
| 423 |
* Reads a string from the data input stream, up to the first |
|---|
| 424 |
* occurrence of any of the stop characters. |
|---|
| 425 |
* In contrast to g_data_input_stream_read_until(), this function |
|---|
| 426 |
* does not consume the stop character. You have |
|---|
| 427 |
* to use g_data_input_stream_read_byte() to get it before calling |
|---|
| 428 |
* g_data_input_stream_read_upto() again. |
|---|
| 429 |
* Note that stop_chars may contain '\0' if stop_chars_len is |
|---|
| 430 |
* specified. |
|---|
| 431 |
* Since 2.24 |
|---|
| 432 |
* Params: |
|---|
| 433 |
* stopChars = characters to terminate the read |
|---|
| 434 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 435 |
* Returns: a string with the data that was read before encountering any of the stop characters. Set length to a gsize to get the length of the string. This function will return NULL on an error. [transfer full] |
|---|
| 436 |
* Throws: GException on failure. |
|---|
| 437 |
*/ |
|---|
| 438 |
public string readUpto(char[] stopChars, Cancellable cancellable) |
|---|
| 439 |
{ |
|---|
| 440 |
// char * g_data_input_stream_read_upto (GDataInputStream *stream, const gchar *stop_chars, gssize stop_chars_len, gsize *length, GCancellable *cancellable, GError **error); |
|---|
| 441 |
gsize length; |
|---|
| 442 |
GError* err = null; |
|---|
| 443 |
|
|---|
| 444 |
auto p = g_data_input_stream_read_upto(gDataInputStream, stopChars.ptr, cast(int) stopChars.length, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 445 |
|
|---|
| 446 |
if (err !is null) |
|---|
| 447 |
{ |
|---|
| 448 |
throw new GException( new ErrorG(err) ); |
|---|
| 449 |
} |
|---|
| 450 |
|
|---|
| 451 |
return Str.toString(p, length); |
|---|
| 452 |
} |
|---|
| 453 |
|
|---|
| 454 |
/** |
|---|
| 455 |
* The asynchronous version of g_data_input_stream_read_upto(). |
|---|
| 456 |
* It is an error to have two outstanding calls to this function. |
|---|
| 457 |
* In contrast to g_data_input_stream_read_until(), this function |
|---|
| 458 |
* does not consume the stop character. You have |
|---|
| 459 |
* to use g_data_input_stream_read_byte() to get it before calling |
|---|
| 460 |
* g_data_input_stream_read_upto() again. |
|---|
| 461 |
* Note that stop_chars may contain '\0' if stop_chars_len is |
|---|
| 462 |
* specified. |
|---|
| 463 |
* When the operation is finished, callback will be called. You |
|---|
| 464 |
* can then call g_data_input_stream_read_upto_finish() to get |
|---|
| 465 |
* the result of the operation. |
|---|
| 466 |
* Since 2.24 |
|---|
| 467 |
* Params: |
|---|
| 468 |
* stopChars = characters to terminate the read |
|---|
| 469 |
* ioPriority = the I/O priority |
|---|
| 470 |
* of the request. |
|---|
| 471 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 472 |
* callback = callback to call when the request is satisfied. [scope async] |
|---|
| 473 |
* userData = the data to pass to callback function. [closure] |
|---|
| 474 |
*/ |
|---|
| 475 |
public void readUptoAsync(char[] stopChars, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 476 |
{ |
|---|
| 477 |
// void g_data_input_stream_read_upto_async (GDataInputStream *stream, const gchar *stop_chars, gssize stop_chars_len, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 478 |
g_data_input_stream_read_upto_async(gDataInputStream, stopChars.ptr, cast(int) stopChars.length, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 479 |
} |
|---|
| 480 |
|
|---|
| 481 |
/** |
|---|
| 482 |
* Finish an asynchronous call started by |
|---|
| 483 |
* g_data_input_stream_read_upto_async(). |
|---|
| 484 |
* Note that this function does not consume the |
|---|
| 485 |
* stop character. You have to use g_data_input_stream_read_byte() to |
|---|
| 486 |
* get it before calling g_data_input_stream_read_upto_async() again. |
|---|
| 487 |
* Since 2.24 |
|---|
| 488 |
* Params: |
|---|
| 489 |
* result = the GAsyncResult that was provided to the callback |
|---|
| 490 |
* Returns: a string with the data that was read before encountering any of the stop characters. Set length to a gsize to get the length of the string. This function will return NULL on an error. [transfer full] |
|---|
| 491 |
* Throws: GException on failure. |
|---|
| 492 |
*/ |
|---|
| 493 |
public string readUptoFinish(out GAsyncResult result) |
|---|
| 494 |
{ |
|---|
| 495 |
// char * g_data_input_stream_read_upto_finish (GDataInputStream *stream, GAsyncResult *result, gsize *length, GError **error); |
|---|
| 496 |
gsize length; |
|---|
| 497 |
GError* err = null; |
|---|
| 498 |
|
|---|
| 499 |
auto p = g_data_input_stream_read_upto_finish(gDataInputStream, &result, &length, &err); |
|---|
| 500 |
|
|---|
| 501 |
if (err !is null) |
|---|
| 502 |
{ |
|---|
| 503 |
throw new GException( new ErrorG(err) ); |
|---|
| 504 |
} |
|---|
| 505 |
|
|---|
| 506 |
return Str.toString(p, length); |
|---|
| 507 |
} |
|---|
| 508 |
|
|---|
| 509 |
/** |
|---|
| 510 |
* Reads a string from the data input stream, up to the first |
|---|
| 511 |
* occurrence of any of the stop characters. |
|---|
| 512 |
* Note that, in contrast to g_data_input_stream_read_until_async(), |
|---|
| 513 |
* this function consumes the stop character that it finds. |
|---|
| 514 |
* Don't use this function in new code. Its functionality is |
|---|
| 515 |
* inconsistent with g_data_input_stream_read_until_async(). Both |
|---|
| 516 |
* functions will be marked as deprecated in a future release. Use |
|---|
| 517 |
* g_data_input_stream_read_upto() instead, but note that that function |
|---|
| 518 |
* does not consume the stop character. |
|---|
| 519 |
* Params: |
|---|
| 520 |
* stopChars = characters to terminate the read. |
|---|
| 521 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 522 |
* Returns: a string with the data that was read before encountering any of the stop characters. Set length to a gsize to get the length of the string. This function will return NULL on an error. [transfer full] |
|---|
| 523 |
* Throws: GException on failure. |
|---|
| 524 |
*/ |
|---|
| 525 |
public string readUntil(string stopChars, Cancellable cancellable) |
|---|
| 526 |
{ |
|---|
| 527 |
// char * g_data_input_stream_read_until (GDataInputStream *stream, const gchar *stop_chars, gsize *length, GCancellable *cancellable, GError **error); |
|---|
| 528 |
gsize length; |
|---|
| 529 |
GError* err = null; |
|---|
| 530 |
|
|---|
| 531 |
auto p = g_data_input_stream_read_until(gDataInputStream, Str.toStringz(stopChars), &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 532 |
|
|---|
| 533 |
if (err !is null) |
|---|
| 534 |
{ |
|---|
| 535 |
throw new GException( new ErrorG(err) ); |
|---|
| 536 |
} |
|---|
| 537 |
|
|---|
| 538 |
return Str.toString(p, length); |
|---|
| 539 |
} |
|---|
| 540 |
|
|---|
| 541 |
/** |
|---|
| 542 |
* The asynchronous version of g_data_input_stream_read_until(). |
|---|
| 543 |
* It is an error to have two outstanding calls to this function. |
|---|
| 544 |
* Note that, in contrast to g_data_input_stream_read_until(), |
|---|
| 545 |
* this function does not consume the stop character that it finds. You |
|---|
| 546 |
* must read it for yourself. |
|---|
| 547 |
* When the operation is finished, callback will be called. You |
|---|
| 548 |
* can then call g_data_input_stream_read_until_finish() to get |
|---|
| 549 |
* the result of the operation. |
|---|
| 550 |
* Don't use this function in new code. Its functionality is |
|---|
| 551 |
* inconsistent with g_data_input_stream_read_until(). Both functions |
|---|
| 552 |
* will be marked as deprecated in a future release. Use |
|---|
| 553 |
* g_data_input_stream_read_upto_async() instead. |
|---|
| 554 |
* Since 2.20 |
|---|
| 555 |
* Params: |
|---|
| 556 |
* stopChars = characters to terminate the read. |
|---|
| 557 |
* ioPriority = the I/O priority |
|---|
| 558 |
* of the request. |
|---|
| 559 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 560 |
* callback = callback to call when the request is satisfied. [scope async] |
|---|
| 561 |
* userData = the data to pass to callback function. [closure] |
|---|
| 562 |
*/ |
|---|
| 563 |
public void readUntilAsync(string stopChars, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 564 |
{ |
|---|
| 565 |
// void g_data_input_stream_read_until_async (GDataInputStream *stream, const gchar *stop_chars, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 566 |
g_data_input_stream_read_until_async(gDataInputStream, Str.toStringz(stopChars), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 567 |
} |
|---|
| 568 |
|
|---|
| 569 |
/** |
|---|
| 570 |
* Finish an asynchronous call started by |
|---|
| 571 |
* g_data_input_stream_read_until_async(). |
|---|
| 572 |
* Since 2.20 |
|---|
| 573 |
* Params: |
|---|
| 574 |
* result = the GAsyncResult that was provided to the callback. |
|---|
| 575 |
* Returns: a string with the data that was read before encountering any of the stop characters. Set length to a gsize to get the length of the string. This function will return NULL on an error. [transfer full] |
|---|
| 576 |
* Throws: GException on failure. |
|---|
| 577 |
*/ |
|---|
| 578 |
public string readUntilFinish(out GAsyncResult result) |
|---|
| 579 |
{ |
|---|
| 580 |
// char * g_data_input_stream_read_until_finish (GDataInputStream *stream, GAsyncResult *result, gsize *length, GError **error); |
|---|
| 581 |
gsize length; |
|---|
| 582 |
GError* err = null; |
|---|
| 583 |
|
|---|
| 584 |
auto p = g_data_input_stream_read_until_finish(gDataInputStream, &result, &length, &err); |
|---|
| 585 |
|
|---|
| 586 |
if (err !is null) |
|---|
| 587 |
{ |
|---|
| 588 |
throw new GException( new ErrorG(err) ); |
|---|
| 589 |
} |
|---|
| 590 |
|
|---|
| 591 |
return Str.toString(p, length); |
|---|
| 592 |
} |
|---|
| 593 |
} |
|---|