GDataInputStream

GDataInputStream

Synopsis




                    GDataInputStream;
enum                GDataStreamByteOrder;
enum                GDataStreamNewlineType;
GDataInputStream*   g_data_input_stream_new             (GInputStream *base_stream);
void                g_data_input_stream_set_byte_order  (GDataInputStream *stream,
                                                         GDataStreamByteOrder order);
GDataStreamByteOrder g_data_input_stream_get_byte_order (GDataInputStream *stream);
void                g_data_input_stream_set_newline_type
                                                        (GDataInputStream *data_stream,
                                                         GDataStreamNewlineType type);
GDataStreamNewlineType g_data_input_stream_get_newline_type
                                                        (GDataInputStream *stream);
guchar              g_data_input_stream_read_byte       (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);
gint16              g_data_input_stream_read_int16      (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);
guint16             g_data_input_stream_read_uint16     (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);
gint32              g_data_input_stream_read_int32      (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);
guint32             g_data_input_stream_read_uint32     (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);
gint64              g_data_input_stream_read_int64      (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);
guint64             g_data_input_stream_read_uint64     (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);
char*               g_data_input_stream_read_line       (GDataInputStream *stream,
                                                         gsize *length,
                                                         GCancellable *cancellable,
                                                         GError **error);
char*               g_data_input_stream_read_until      (GDataInputStream *stream,
                                                         gchar stop_char,
                                                         gsize *length,
                                                         GCancellable *cancellable,
                                                         GError **error);


Object Hierarchy


  GObject
   +----GInputStream
         +----GFilterInputStream
               +----GBufferedInputStream
                     +----GDataInputStream

Description

Details

GDataInputStream

typedef struct _GDataInputStream GDataInputStream;


enum GDataStreamByteOrder

typedef enum  {
  G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN,
  G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN,
  G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN
} GDataStreamByteOrder;


enum GDataStreamNewlineType

typedef enum  {
  G_DATA_STREAM_NEWLINE_TYPE_LF,
  G_DATA_STREAM_NEWLINE_TYPE_CR,
  G_DATA_STREAM_NEWLINE_TYPE_CR_LF,
  G_DATA_STREAM_NEWLINE_TYPE_ANY
} GDataStreamNewlineType;


g_data_input_stream_new ()

GDataInputStream*   g_data_input_stream_new             (GInputStream *base_stream);

base_stream :

a given GInputStream.

Returns :

a new GDataInputStream.

g_data_input_stream_set_byte_order ()

void                g_data_input_stream_set_byte_order  (GDataInputStream *stream,
                                                         GDataStreamByteOrder order);

This function sets the byte order for the given stream. All subsequent reads from the stream will be read in the given order.

stream :

a given GDataInputStream.

order :

a GDataStreamByteOrder to set.

g_data_input_stream_get_byte_order ()

GDataStreamByteOrder g_data_input_stream_get_byte_order (GDataInputStream *stream);

stream :

a given GDataInputStream.

Returns :

the stream's current GDataStreamByteOrder.

g_data_input_stream_set_newline_type ()

void                g_data_input_stream_set_newline_type
                                                        (GDataInputStream *data_stream,
                                                         GDataStreamNewlineType type);

Sets the newline type for the stream.

TODO: is it valid to set this to G_DATA_STREAM_NEWLINE_TYPE_ANY, or should it always be set to {_LF, _CR, _CR_LF}

data_stream :

type :

the type of new line return as GDataStreamNewlineType.

g_data_input_stream_get_newline_type ()

GDataStreamNewlineType g_data_input_stream_get_newline_type
                                                        (GDataInputStream *stream);

Gets the current newline type for the stream.

stream :

a given GDataInputStream.

Returns :

GDataStreamNewlineType for the given stream.

g_data_input_stream_read_byte ()

guchar              g_data_input_stream_read_byte       (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);

In order to get the correct byte order for this read operation, see g_data_stream_get_byte_order() and g_data_stream_set_byte_order().

stream :

a given GDataInputStream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

an unsigned 8-bit/1-byte value read from the stream or 0 if an error occured.

g_data_input_stream_read_int16 ()

gint16              g_data_input_stream_read_int16      (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);

In order to get the correct byte order for this read operation, see g_data_stream_get_byte_order() and g_data_stream_set_byte_order().

stream :

a given GDataInputStream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

a signed 16-bit/2-byte value read from stream or 0 if an error occured.

g_data_input_stream_read_uint16 ()

guint16             g_data_input_stream_read_uint16     (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);

In order to get the correct byte order for this read operation, see g_data_stream_get_byte_order() and g_data_stream_set_byte_order().

stream :

a given GDataInputStream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

an unsigned 16-bit/2-byte value read from the stream or 0 if an error occured.

g_data_input_stream_read_int32 ()

gint32              g_data_input_stream_read_int32      (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);

In order to get the correct byte order for this read operation, see g_data_stream_get_byte_order() and g_data_stream_set_byte_order().

stream :

a given GDataInputStream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

a signed 32-bit/4-byte value read from the stream or 0 if an error occured.

g_data_input_stream_read_uint32 ()

guint32             g_data_input_stream_read_uint32     (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);

In order to get the correct byte order for this read operation, see g_data_stream_get_byte_order() and g_data_stream_set_byte_order().

stream :

a given GDataInputStream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

an unsigned 32-bit/4-byte value read from the stream or 0 if an error occured.

g_data_input_stream_read_int64 ()

gint64              g_data_input_stream_read_int64      (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);

In order to get the correct byte order for this read operation, see g_data_stream_get_byte_order() and g_data_stream_set_byte_order().

stream :

a given GDataInputStream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

a signed 64-bit/8-byte value read from stream or 0 if an error occured.

g_data_input_stream_read_uint64 ()

guint64             g_data_input_stream_read_uint64     (GDataInputStream *stream,
                                                         GCancellable *cancellable,
                                                         GError **error);

In order to get the correct byte order for this read operation, see g_data_stream_get_byte_order().

stream :

a given GDataInputStream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

an unsigned 64-bit/8-byte read from stream or 0 if an error occured.

g_data_input_stream_read_line ()

char*               g_data_input_stream_read_line       (GDataInputStream *stream,
                                                         gsize *length,
                                                         GCancellable *cancellable,
                                                         GError **error);

stream :

a given GDataInputStream.

length :

a gsize to get the length of the data read in.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

a string with the line that was read in. Set length to a gsize to get the length of the read line. This function will return NULL on an error.

g_data_input_stream_read_until ()

char*               g_data_input_stream_read_until      (GDataInputStream *stream,
                                                         gchar stop_char,
                                                         gsize *length,
                                                         GCancellable *cancellable,
                                                         GError **error);

NOTE: not supported for GDataInputStream.

stream :

a given GDataInputStream.

stop_char :

character to terminate the read.

length :

a gsize to get the length of the data read in.

cancellable :

optional GCancellable object, NULL to ignore.

error :

GError for error reporting.

Returns :

NULL.