Fix crash on startup if an LV2 plugin has a bad .ttl file.
[ardour.git] / libs / glibmm2 / gio / src / datainputstream.hg
1 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
3 /* Copyright (C) 2007 The gtkmm Development Team
4  *
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.
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  * Library General Public License for more details.
14  *
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.
18  */
19
20 #include <giomm/bufferedinputstream.h>
21 #include <giomm/enums.h>
22
23 _DEFS(giomm,gio)
24 _PINCLUDE(giomm/private/bufferedinputstream_p.h)
25
26 namespace Gio
27 {
28
29 /**
30  * An implementation of BufferedInputStream that allows for high-level data
31  * manipulation of arbitrary data (including binary operations).
32  *
33  * @ingroup Streams
34  *
35  * @newin2p16
36  */
37 class DataInputStream : public Gio::BufferedInputStream
38 {
39   _CLASS_GOBJECT(DataInputStream, GDataInputStream, G_DATA_INPUT_STREAM, Gio::BufferedInputStream, GBufferedInputStream)
40
41 protected:
42   _WRAP_CTOR(DataInputStream(const Glib::RefPtr<InputStream>& base_stream), g_data_input_stream_new)
43
44 public:
45
46   _WRAP_CREATE(const Glib::RefPtr<InputStream>& base_stream)
47
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)
52
53   _WRAP_METHOD(guchar read_byte(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_byte, errthrow)
54
55   /** non-cancellable version of read_byte()
56    */
57 #ifdef GLIBMM_EXCEPTIONS_ENABLED
58   guchar read_byte();
59 #else
60   guchar read_byte(std::auto_ptr<Glib::Error>& error);
61 #endif //GLIBMM_EXCEPTIONS_ENABLED
62
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()
65    */
66 #ifdef GLIBMM_EXCEPTIONS_ENABLED
67   gint16 read_int16();
68 #else
69   gint16 read_int16(std::auto_ptr<Glib::Error>& error);
70 #endif //GLIBMM_EXCEPTIONS_ENABLED
71
72   _WRAP_METHOD(guint16 read_uint16(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint16, errthrow)
73
74 //TODO: Real documentation:
75   /** non-cancellable version of read_uint16()
76    */
77 #ifdef GLIBMM_EXCEPTIONS_ENABLED
78   guint16 read_uint16();
79 #else
80   guint16 read_uint16(std::auto_ptr<Glib::Error>& error);
81 #endif //GLIBMM_EXCEPTIONS_ENABLED
82
83   _WRAP_METHOD(gint32 read_int32(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_int32, errthrow)
84
85   /** non-cancellable version of read_int32()
86    */
87 #ifdef GLIBMM_EXCEPTIONS_ENABLED
88   gint32 read_int32();
89 #else
90   gint32 read_int32(std::auto_ptr<Glib::Error>& error);
91 #endif //GLIBMM_EXCEPTIONS_ENABLED
92
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()
95    */
96 #ifdef GLIBMM_EXCEPTIONS_ENABLED
97   guint32 read_uint32();
98 #else
99   guint32 read_uint32(std::auto_ptr<Glib::Error>& error);
100 #endif //GLIBMM_EXCEPTIONS_ENABLED
101
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()
104    */
105 #ifdef GLIBMM_EXCEPTIONS_ENABLED
106   gint64 read_int64();
107 #else
108   gint64 read_int64(std::auto_ptr<Glib::Error>& error);
109 #endif //GLIBMM_EXCEPTIONS_ENABLED
110
111   _WRAP_METHOD(guint64 read_uint64(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint64, errthrow)
112
113   /** non-cancellable version of read_uint64()
114    */
115 #ifdef GLIBMM_EXCEPTIONS_ENABLED
116   guint64 read_uint64();
117 #else
118   guint64 read_uint64(std::auto_ptr<Glib::Error>& error);
119 #endif //GLIBMM_EXCEPTIONS_ENABLED
120
121   _IGNORE(g_data_input_stream_read_line)
122
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);
129 #else
130   bool read_line(std::string& line, const Glib::RefPtr<Cancellable>& cancellable, std::auto_ptr<Glib::Error>& error);
131 #endif //GLIBMM_EXCEPTIONS_ENABLED
132
133   /** non-cancellable version of read_line()
134    */
135 #ifdef GLIBMM_EXCEPTIONS_ENABLED
136   bool read_line(std::string& line);
137 #else
138   bool read_line(std::string& line, std::auto_ptr<Glib::Error>& error);
139 #endif //GLIBMM_EXCEPTIONS_ENABLED
140
141   _IGNORE(g_data_input_stream_read_until)
142
143 #ifdef GLIBMM_EXCEPTIONS_ENABLED
144   bool read_until(std::string& data, const std::string& stop_chars, const Glib::RefPtr<Cancellable>& cancellable);
145 #else
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
148
149   /** non-cancellable version of read_until()
150    */
151 #ifdef GLIBMM_EXCEPTIONS_ENABLED
152   bool read_until(std::string& data, const std::string& stop_chars);
153 #else
154   bool read_until(std::string& data, const std::string& stop_chars, std::auto_ptr<Glib::Error>& error);
155 #endif //GLIBMM_EXCEPTIONS_ENABLED
156
157 };
158
159 } // namespace Gio
160