1 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 /* Copyright (C) 2007 The gtkmm Development Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library 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.
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 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <giomm/bufferedinputstream.h>
21 #include <giomm/enums.h>
24 _PINCLUDE(giomm/private/bufferedinputstream_p.h)
30 * An implementation of BufferedInputStream that allows for high-level data
31 * manipulation of arbitrary data (including binary operations).
37 class DataInputStream : public Gio::BufferedInputStream
39 _CLASS_GOBJECT(DataInputStream, GDataInputStream, G_DATA_INPUT_STREAM, Gio::BufferedInputStream, GBufferedInputStream)
42 _WRAP_CTOR(DataInputStream(const Glib::RefPtr<InputStream>& base_stream), g_data_input_stream_new)
46 _WRAP_CREATE(const Glib::RefPtr<InputStream>& base_stream)
48 _WRAP_METHOD(void set_byte_order(DataStreamByteOrder order), g_data_input_stream_set_byte_order)
49 _WRAP_METHOD(DataStreamByteOrder get_byte_order() const, g_data_input_stream_get_byte_order)
50 _WRAP_METHOD(void set_newline_type(DataStreamNewlineType type), g_data_input_stream_set_newline_type)
51 _WRAP_METHOD(DataStreamNewlineType get_newline_type() const, g_data_input_stream_get_newline_type)
53 _WRAP_METHOD(guchar read_byte(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_byte, errthrow)
55 /** non-cancellable version of read_byte()
57 #ifdef GLIBMM_EXCEPTIONS_ENABLED
60 guchar read_byte(std::auto_ptr<Glib::Error>& error);
61 #endif //GLIBMM_EXCEPTIONS_ENABLED
63 _WRAP_METHOD(gint16 read_int16(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_int16, errthrow)
64 /** non-cancellable version of read_int16()
66 #ifdef GLIBMM_EXCEPTIONS_ENABLED
69 gint16 read_int16(std::auto_ptr<Glib::Error>& error);
70 #endif //GLIBMM_EXCEPTIONS_ENABLED
72 _WRAP_METHOD(guint16 read_uint16(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint16, errthrow)
74 //TODO: Real documentation:
75 /** non-cancellable version of read_uint16()
77 #ifdef GLIBMM_EXCEPTIONS_ENABLED
78 guint16 read_uint16();
80 guint16 read_uint16(std::auto_ptr<Glib::Error>& error);
81 #endif //GLIBMM_EXCEPTIONS_ENABLED
83 _WRAP_METHOD(gint32 read_int32(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_int32, errthrow)
85 /** non-cancellable version of read_int32()
87 #ifdef GLIBMM_EXCEPTIONS_ENABLED
90 gint32 read_int32(std::auto_ptr<Glib::Error>& error);
91 #endif //GLIBMM_EXCEPTIONS_ENABLED
93 _WRAP_METHOD(guint32 read_uint32(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint32, errthrow)
94 /** non-cancellable version of read_uint32()
96 #ifdef GLIBMM_EXCEPTIONS_ENABLED
97 guint32 read_uint32();
99 guint32 read_uint32(std::auto_ptr<Glib::Error>& error);
100 #endif //GLIBMM_EXCEPTIONS_ENABLED
102 _WRAP_METHOD(gint64 read_int64(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_int64, errthrow)
103 /** non-cancellable version of read_int64()
105 #ifdef GLIBMM_EXCEPTIONS_ENABLED
108 gint64 read_int64(std::auto_ptr<Glib::Error>& error);
109 #endif //GLIBMM_EXCEPTIONS_ENABLED
111 _WRAP_METHOD(guint64 read_uint64(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint64, errthrow)
113 /** non-cancellable version of read_uint64()
115 #ifdef GLIBMM_EXCEPTIONS_ENABLED
116 guint64 read_uint64();
118 guint64 read_uint64(std::auto_ptr<Glib::Error>& error);
119 #endif //GLIBMM_EXCEPTIONS_ENABLED
121 _IGNORE(g_data_input_stream_read_line)
123 // FIXME: In C, these functions return NULL if there is an error (i.e. end of
124 // stream reached), but if we use std::string, we don't have a way to tell an
125 // empty string from NULL. Perhaps we should use raw pointers as in C, but
126 // that would mean we need to worry about freeing the C string...
127 #ifdef GLIBMM_EXCEPTIONS_ENABLED
128 bool read_line(std::string& line, const Glib::RefPtr<Cancellable>& cancellable);
130 bool read_line(std::string& line, const Glib::RefPtr<Cancellable>& cancellable, std::auto_ptr<Glib::Error>& error);
131 #endif //GLIBMM_EXCEPTIONS_ENABLED
133 /** non-cancellable version of read_line()
135 #ifdef GLIBMM_EXCEPTIONS_ENABLED
136 bool read_line(std::string& line);
138 bool read_line(std::string& line, std::auto_ptr<Glib::Error>& error);
139 #endif //GLIBMM_EXCEPTIONS_ENABLED
141 _IGNORE(g_data_input_stream_read_until)
143 #ifdef GLIBMM_EXCEPTIONS_ENABLED
144 bool read_until(std::string& data, const std::string& stop_chars, const Glib::RefPtr<Cancellable>& cancellable);
146 bool read_until(std::string& data, const std::string& stop_chars, const Glib::RefPtr<Cancellable>& cancellable, std::auto_ptr<Glib::Error>& error);
147 #endif //GLIBMM_EXCEPTIONS_ENABLED
149 /** non-cancellable version of read_until()
151 #ifdef GLIBMM_EXCEPTIONS_ENABLED
152 bool read_until(std::string& data, const std::string& stop_chars);
154 bool read_until(std::string& data, const std::string& stop_chars, std::auto_ptr<Glib::Error>& error);
155 #endif //GLIBMM_EXCEPTIONS_ENABLED