Add new error codes for when compilation fails and make compilation error
[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 /**
39  * GDataInputStream:
40  * @parent: a #GBufferedInputStream.
41  *
42  * An implementation of #GBufferedInputStream that allows for high-level 
43  * data manipulation of arbitrary data (including binary operations).
44  **/
45 typedef struct _GDataInputStream         GDataInputStream;
46 typedef struct _GDataInputStreamClass    GDataInputStreamClass;
47 typedef struct _GDataInputStreamPrivate  GDataInputStreamPrivate;
48
49 struct _GDataInputStream
50 {
51   GBufferedInputStream parent;
52
53   /*< private >*/
54   GDataInputStreamPrivate *priv;
55 };
56
57 struct _GDataInputStreamClass
58 {
59  GBufferedInputStreamClass parent_class;
60   /*< private >*/
61   /* Padding for future expansion */
62   void (*_g_reserved1) (void);
63   void (*_g_reserved2) (void);
64   void (*_g_reserved3) (void);
65   void (*_g_reserved4) (void);
66   void (*_g_reserved5) (void);
67 };
68
69 /**
70  * GDataStreamByteOrder:
71  * @G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN: Selects Big Endian byte order. 
72  * @G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN: Selects Little Endian byte order.
73  * @G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN: Selects endianness based on host machine's architecture.
74  *
75  * #GDataStreamByteOrder is used to ensure proper endianness of streaming data sources
76  * across various machine architectures.
77  *
78  **/
79 typedef enum  {
80   G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN,
81   G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN,
82   G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN
83 } GDataStreamByteOrder;
84
85 /** 
86  * GDataStreamNewlineType:
87  * @G_DATA_STREAM_NEWLINE_TYPE_LF: Selects "LF" line endings, common on most modern UNIX platforms.
88  * @G_DATA_STREAM_NEWLINE_TYPE_CR: Selects "CR" line endings.
89  * @G_DATA_STREAM_NEWLINE_TYPE_CR_LF: Selects "CR, LF" line ending, common on Microsoft Windows.
90  * @G_DATA_STREAM_NEWLINE_TYPE_ANY: Selects any line ending type.
91  *
92  * #GDataStreamNewlineType is used when checking for or setting the line endings for a given file.
93  **/
94 typedef enum  {
95   G_DATA_STREAM_NEWLINE_TYPE_LF,
96   G_DATA_STREAM_NEWLINE_TYPE_CR,
97   G_DATA_STREAM_NEWLINE_TYPE_CR_LF,
98   G_DATA_STREAM_NEWLINE_TYPE_ANY
99 } GDataStreamNewlineType;
100
101 GType          g_data_input_stream_get_type   (void) G_GNUC_CONST;
102 GDataInputStream*  g_data_input_stream_new        (GInputStream *base_stream);
103
104 void                   g_data_input_stream_set_byte_order   (GDataInputStream        *stream,
105                                                              GDataStreamByteOrder     order);
106 GDataStreamByteOrder   g_data_input_stream_get_byte_order   (GDataInputStream        *stream);
107 void                   g_data_input_stream_set_newline_type (GDataInputStream        *stream,
108                                                              GDataStreamNewlineType   type);
109 GDataStreamNewlineType g_data_input_stream_get_newline_type (GDataInputStream        *stream);
110 guchar                 g_data_input_stream_read_byte        (GDataInputStream        *stream,
111                                                              GCancellable            *cancellable,
112                                                              GError                 **error);
113 gint16                 g_data_input_stream_read_int16       (GDataInputStream        *stream,
114                                                              GCancellable            *cancellable,
115                                                              GError                 **error);
116 guint16                g_data_input_stream_read_uint16      (GDataInputStream        *stream,
117                                                              GCancellable            *cancellable,
118                                                              GError                 **error);
119 gint32                 g_data_input_stream_read_int32       (GDataInputStream        *stream,
120                                                              GCancellable            *cancellable,
121                                                              GError                 **error);
122 guint32                g_data_input_stream_read_uint32      (GDataInputStream        *stream,
123                                                              GCancellable            *cancellable,
124                                                              GError                 **error);
125 gint64                 g_data_input_stream_read_int64       (GDataInputStream        *stream,
126                                                              GCancellable            *cancellable,
127                                                              GError                 **error);
128 guint64                g_data_input_stream_read_uint64      (GDataInputStream        *stream,
129                                                              GCancellable            *cancellable,
130                                                              GError                 **error);
131 char *                 g_data_input_stream_read_line        (GDataInputStream        *stream,
132                                                              gsize                   *length,
133                                                              GCancellable            *cancellable,
134                                                              GError                 **error);
135 char *                 g_data_input_stream_read_until       (GDataInputStream        *stream,
136                                                              const gchar             *stop_chars,
137                                                              gsize                   *length,
138                                                              GCancellable            *cancellable,
139                                                              GError                 **error);
140
141 G_END_DECLS
142
143 #endif /* __G_DATA_INPUT_STREAM_H__ */