af58dbfbe259335c49ab091856c85eb370e285ec
[platform/upstream/glib.git] / gio / gdatainputstream.h
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #ifndef __G_DATA_INPUT_STREAM_H__
24 #define __G_DATA_INPUT_STREAM_H__
25
26 #include <glib-object.h>
27 #include <gio/gbufferedinputstream.h>
28
29 G_BEGIN_DECLS
30
31 #define G_TYPE_DATA_INPUT_STREAM         (g_data_input_stream_get_type ())
32 #define G_DATA_INPUT_STREAM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DATA_INPUT_STREAM, GDataInputStream))
33 #define G_DATA_INPUT_STREAM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DATA_INPUT_STREAM, GDataInputStreamClass))
34 #define G_IS_DATA_INPUT_STREAM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DATA_INPUT_STREAM))
35 #define G_IS_DATA_INPUT_STREAM_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DATA_INPUT_STREAM))
36 #define G_DATA_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DATA_INPUT_STREAM, GDataInputStreamClass))
37
38 typedef struct _GDataInputStream         GDataInputStream;
39 typedef struct _GDataInputStreamClass    GDataInputStreamClass;
40 typedef struct _GDataInputStreamPrivate  GDataInputStreamPrivate;
41
42 struct _GDataInputStream
43 {
44   GBufferedInputStream parent;
45
46   /*< private >*/
47   GDataInputStreamPrivate *priv;
48 };
49
50 struct _GDataInputStreamClass
51 {
52  GBufferedInputStreamClass parent_class;
53
54   /* Padding for future expansion */
55   void (*_g_reserved1) (void);
56   void (*_g_reserved2) (void);
57   void (*_g_reserved3) (void);
58   void (*_g_reserved4) (void);
59   void (*_g_reserved5) (void);
60 };
61
62 typedef enum  {
63   G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN,
64   G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN,
65   G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN
66 } GDataStreamByteOrder;
67
68 typedef enum  {
69   G_DATA_STREAM_NEWLINE_TYPE_LF,
70   G_DATA_STREAM_NEWLINE_TYPE_CR,
71   G_DATA_STREAM_NEWLINE_TYPE_CR_LF,
72   G_DATA_STREAM_NEWLINE_TYPE_ANY
73 } GDataStreamNewlineType;
74
75 GType          g_data_input_stream_get_type   (void) G_GNUC_CONST;
76 GDataInputStream*  g_data_input_stream_new        (GInputStream *base_stream);
77
78 void                   g_data_input_stream_set_byte_order   (GDataInputStream        *stream,
79                                                              GDataStreamByteOrder     order);
80 GDataStreamByteOrder   g_data_input_stream_get_byte_order   (GDataInputStream        *stream);
81 void                   g_data_input_stream_set_newline_type (GDataInputStream        *data_stream,
82                                                              GDataStreamNewlineType   type);
83 GDataStreamNewlineType g_data_input_stream_get_newline_type (GDataInputStream        *stream);
84 guchar                 g_data_input_stream_read_byte        (GDataInputStream        *stream,
85                                                              GCancellable            *cancellable,
86                                                              GError                 **error);
87 gint16                 g_data_input_stream_read_int16       (GDataInputStream        *stream,
88                                                              GCancellable            *cancellable,
89                                                              GError                 **error);
90 guint16                g_data_input_stream_read_uint16      (GDataInputStream        *stream,
91                                                              GCancellable            *cancellable,
92                                                              GError                 **error);
93 gint32                 g_data_input_stream_read_int32       (GDataInputStream        *stream,
94                                                              GCancellable            *cancellable,
95                                                              GError                 **error);
96 guint32                g_data_input_stream_read_uint32      (GDataInputStream        *stream,
97                                                              GCancellable            *cancellable,
98                                                              GError                 **error);
99 gint64                 g_data_input_stream_read_int64       (GDataInputStream        *stream,
100                                                              GCancellable            *cancellable,
101                                                              GError                 **error);
102 guint64                g_data_input_stream_read_uint64      (GDataInputStream        *stream,
103                                                              GCancellable            *cancellable,
104                                                              GError                 **error);
105 char *                 g_data_input_stream_read_line        (GDataInputStream        *stream,
106                                                              gsize                   *length,
107                                                              GCancellable            *cancellable,
108                                                              GError                 **error);
109 char *                 g_data_input_stream_read_until       (GDataInputStream        *stream,
110                                                              gchar                    stop_char,
111                                                              gsize                   *length,
112                                                              GCancellable            *cancellable,
113                                                              GError                 **error);
114
115 G_END_DECLS
116
117 #endif /* __G_DATA_INPUT_STREAM_H__ */