Fix AKS -> ASK typo
[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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
25 #endif
26
27 #ifndef __G_DATA_INPUT_STREAM_H__
28 #define __G_DATA_INPUT_STREAM_H__
29
30 #include <glib-object.h>
31 #include <gio/gbufferedinputstream.h>
32
33 G_BEGIN_DECLS
34
35 #define G_TYPE_DATA_INPUT_STREAM         (g_data_input_stream_get_type ())
36 #define G_DATA_INPUT_STREAM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DATA_INPUT_STREAM, GDataInputStream))
37 #define G_DATA_INPUT_STREAM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DATA_INPUT_STREAM, GDataInputStreamClass))
38 #define G_IS_DATA_INPUT_STREAM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DATA_INPUT_STREAM))
39 #define G_IS_DATA_INPUT_STREAM_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DATA_INPUT_STREAM))
40 #define G_DATA_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DATA_INPUT_STREAM, GDataInputStreamClass))
41
42 /**
43  * GDataInputStream:
44  * @parent: a #GBufferedInputStream.
45  *
46  * An implementation of #GBufferedInputStream that allows for high-level 
47  * data manipulation of arbitrary data (including binary operations).
48  **/
49 typedef struct _GDataInputStream         GDataInputStream;
50 typedef struct _GDataInputStreamClass    GDataInputStreamClass;
51 typedef struct _GDataInputStreamPrivate  GDataInputStreamPrivate;
52
53 struct _GDataInputStream
54 {
55   GBufferedInputStream parent_instance;
56
57   /*< private >*/
58   GDataInputStreamPrivate *priv;
59 };
60
61 struct _GDataInputStreamClass
62 {
63  GBufferedInputStreamClass parent_class;
64   /*< private >*/
65   /* Padding for future expansion */
66   void (*_g_reserved1) (void);
67   void (*_g_reserved2) (void);
68   void (*_g_reserved3) (void);
69   void (*_g_reserved4) (void);
70   void (*_g_reserved5) (void);
71 };
72
73 /**
74  * GDataStreamByteOrder:
75  * @G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN: Selects Big Endian byte order. 
76  * @G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN: Selects Little Endian byte order.
77  * @G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN: Selects endianness based on host machine's architecture.
78  *
79  * #GDataStreamByteOrder is used to ensure proper endianness of streaming data sources
80  * across various machine architectures.
81  *
82  **/
83 typedef enum  {
84   G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN,
85   G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN,
86   G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN
87 } GDataStreamByteOrder;
88
89 /** 
90  * GDataStreamNewlineType:
91  * @G_DATA_STREAM_NEWLINE_TYPE_LF: Selects "LF" line endings, common on most modern UNIX platforms.
92  * @G_DATA_STREAM_NEWLINE_TYPE_CR: Selects "CR" line endings.
93  * @G_DATA_STREAM_NEWLINE_TYPE_CR_LF: Selects "CR, LF" line ending, common on Microsoft Windows.
94  * @G_DATA_STREAM_NEWLINE_TYPE_ANY: Automatically try to handle any line ending type.
95  *
96  * #GDataStreamNewlineType is used when checking for or setting the line endings for a given file.
97  **/
98 typedef enum  {
99   G_DATA_STREAM_NEWLINE_TYPE_LF,
100   G_DATA_STREAM_NEWLINE_TYPE_CR,
101   G_DATA_STREAM_NEWLINE_TYPE_CR_LF,
102   G_DATA_STREAM_NEWLINE_TYPE_ANY
103 } GDataStreamNewlineType;
104
105 GType          g_data_input_stream_get_type   (void) G_GNUC_CONST;
106 GDataInputStream*  g_data_input_stream_new        (GInputStream *base_stream);
107
108 void                   g_data_input_stream_set_byte_order   (GDataInputStream        *stream,
109                                                              GDataStreamByteOrder     order);
110 GDataStreamByteOrder   g_data_input_stream_get_byte_order   (GDataInputStream        *stream);
111 void                   g_data_input_stream_set_newline_type (GDataInputStream        *stream,
112                                                              GDataStreamNewlineType   type);
113 GDataStreamNewlineType g_data_input_stream_get_newline_type (GDataInputStream        *stream);
114 guchar                 g_data_input_stream_read_byte        (GDataInputStream        *stream,
115                                                              GCancellable            *cancellable,
116                                                              GError                 **error);
117 gint16                 g_data_input_stream_read_int16       (GDataInputStream        *stream,
118                                                              GCancellable            *cancellable,
119                                                              GError                 **error);
120 guint16                g_data_input_stream_read_uint16      (GDataInputStream        *stream,
121                                                              GCancellable            *cancellable,
122                                                              GError                 **error);
123 gint32                 g_data_input_stream_read_int32       (GDataInputStream        *stream,
124                                                              GCancellable            *cancellable,
125                                                              GError                 **error);
126 guint32                g_data_input_stream_read_uint32      (GDataInputStream        *stream,
127                                                              GCancellable            *cancellable,
128                                                              GError                 **error);
129 gint64                 g_data_input_stream_read_int64       (GDataInputStream        *stream,
130                                                              GCancellable            *cancellable,
131                                                              GError                 **error);
132 guint64                g_data_input_stream_read_uint64      (GDataInputStream        *stream,
133                                                              GCancellable            *cancellable,
134                                                              GError                 **error);
135 char *                 g_data_input_stream_read_line        (GDataInputStream        *stream,
136                                                              gsize                   *length,
137                                                              GCancellable            *cancellable,
138                                                              GError                 **error);
139 char *                 g_data_input_stream_read_until       (GDataInputStream        *stream,
140                                                              const gchar             *stop_chars,
141                                                              gsize                   *length,
142                                                              GCancellable            *cancellable,
143                                                              GError                 **error);
144
145 G_END_DECLS
146
147 #endif /* __G_DATA_INPUT_STREAM_H__ */