2
// Generated by gtkmmproc -- DO NOT MODIFY!
3
#ifndef _GIOMM_CONVERTER_H
4
#define _GIOMM_CONVERTER_H
7
#include <glibmm/ustring.h>
8
#include <sigc++/sigc++.h>
10
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
12
/* Copyright (C) 2012 The giomm Development Team
14
* This library is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU Lesser General Public
16
* License as published by the Free Software Foundation; either
17
* version 2.1 of the License, or (at your option) any later version.
19
* This library is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
* Lesser General Public License for more details.
24
* You should have received a copy of the GNU Lesser General Public
25
* License along with this library; if not, write to the Free
26
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29
#include <glibmm/interface.h>
32
#ifndef DOXYGEN_SHOULD_SKIP_THIS
33
typedef struct _GConverterIface GConverterIface;
34
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
36
#ifndef DOXYGEN_SHOULD_SKIP_THIS
37
typedef struct _GConverter GConverter;
38
typedef struct _GConverterClass GConverterClass;
39
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
43
{ class Converter_Class; } // namespace Gio
47
/** @addtogroup giommEnums giomm Enums and Flags */
63
#ifndef DOXYGEN_SHOULD_SKIP_THIS
68
class Value<Gio::ConverterResult> : public Glib::Value_Enum<Gio::ConverterResult>
71
static GType value_type() G_GNUC_CONST;
75
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
83
* @par Bitwise operators:
84
* <tt>%ConverterFlags operator|(ConverterFlags, ConverterFlags)</tt><br>
85
* <tt>%ConverterFlags operator&(ConverterFlags, ConverterFlags)</tt><br>
86
* <tt>%ConverterFlags operator^(ConverterFlags, ConverterFlags)</tt><br>
87
* <tt>%ConverterFlags operator~(ConverterFlags)</tt><br>
88
* <tt>%ConverterFlags& operator|=(ConverterFlags&, ConverterFlags)</tt><br>
89
* <tt>%ConverterFlags& operator&=(ConverterFlags&, ConverterFlags)</tt><br>
90
* <tt>%ConverterFlags& operator^=(ConverterFlags&, ConverterFlags)</tt><br>
94
CONVERTER_NO_FLAGS = 0x0,
95
CONVERTER_INPUT_AT_END = (1 << 0),
96
CONVERTER_FLUSH = (1 << 1)
99
/** @ingroup giommEnums */
100
inline ConverterFlags operator|(ConverterFlags lhs, ConverterFlags rhs)
101
{ return static_cast<ConverterFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
103
/** @ingroup giommEnums */
104
inline ConverterFlags operator&(ConverterFlags lhs, ConverterFlags rhs)
105
{ return static_cast<ConverterFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
107
/** @ingroup giommEnums */
108
inline ConverterFlags operator^(ConverterFlags lhs, ConverterFlags rhs)
109
{ return static_cast<ConverterFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
111
/** @ingroup giommEnums */
112
inline ConverterFlags operator~(ConverterFlags flags)
113
{ return static_cast<ConverterFlags>(~static_cast<unsigned>(flags)); }
115
/** @ingroup giommEnums */
116
inline ConverterFlags& operator|=(ConverterFlags& lhs, ConverterFlags rhs)
117
{ return (lhs = static_cast<ConverterFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
119
/** @ingroup giommEnums */
120
inline ConverterFlags& operator&=(ConverterFlags& lhs, ConverterFlags rhs)
121
{ return (lhs = static_cast<ConverterFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
123
/** @ingroup giommEnums */
124
inline ConverterFlags& operator^=(ConverterFlags& lhs, ConverterFlags rhs)
125
{ return (lhs = static_cast<ConverterFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
130
#ifndef DOXYGEN_SHOULD_SKIP_THIS
135
class Value<Gio::ConverterFlags> : public Glib::Value_Flags<Gio::ConverterFlags>
138
static GType value_type() G_GNUC_CONST;
142
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
149
/** Converter - Data conversion interface.
150
* Converter is implemented by objects that convert binary data in various
151
* ways. The conversion can be stateful and may fail at any place.
153
* Some example conversions are: character set conversion, compression,
154
* decompression and regular expression replace.
159
class Converter : public Glib::Interface
162
#ifndef DOXYGEN_SHOULD_SKIP_THIS
165
typedef Converter CppObjectType;
166
typedef Converter_Class CppClassType;
167
typedef GConverter BaseObjectType;
168
typedef GConverterIface BaseClassType;
171
friend class Converter_Class;
172
static CppClassType converter_class_;
175
Converter(const Converter&);
176
Converter& operator=(const Converter&);
178
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
181
* You should derive from this class to use it.
185
#ifndef DOXYGEN_SHOULD_SKIP_THIS
186
/** Called by constructors of derived classes. Provide the result of
187
* the Class init() function to ensure that it is properly
190
* @param interface_class The Class object for the derived type.
192
explicit Converter(const Glib::Interface_Class& interface_class);
195
// This is public so that C++ wrapper instances can be
196
// created for C instances of unwrapped types.
197
// For instance, if an unexpected C type implements the C interface.
198
explicit Converter(GConverter* castitem);
201
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
204
virtual ~Converter();
206
static void add_interface(GType gtype_implementer);
208
/** Get the GType for this class, for use with the underlying GObject type system.
210
static GType get_type() G_GNUC_CONST;
212
#ifndef DOXYGEN_SHOULD_SKIP_THIS
213
static GType get_base_type() G_GNUC_CONST;
216
///Provides access to the underlying C GObject.
217
GConverter* gobj() { return reinterpret_cast<GConverter*>(gobject_); }
219
///Provides access to the underlying C GObject.
220
const GConverter* gobj() const { return reinterpret_cast<GConverter*>(gobject_); }
227
/** This is the main operation used when converting data. It is to be called
228
* multiple times in a loop, and each time it will do some work, i.e.
229
* producing some output (in @a outbuf) or consuming some input (from @a inbuf) or
230
* both. If its not possible to do any work an error is returned.
232
* Note that a single call may not consume all input (or any input at all).
233
* Also a call may produce output even if given no input, due to state stored
234
* in the converter producing output.
236
* If any data was either produced or consumed, and then an error happens, then
237
* only the successful conversion is reported and the error is returned on the
240
* A full conversion loop involves calling this method repeatedly, each time
241
* giving it new input and space output space. When there is no more input
242
* data after the data in @a inbuf, the flag CONVERTER_INPUT_AT_END must be set.
243
* The loop will be (unless some error happens) returning CONVERTER_CONVERTED
244
* each time until all data is consumed and all output is produced, then
245
* CONVERTER_FINISHED is returned instead. Note, that CONVERTER_FINISHED
246
* may be returned even if CONVERTER_INPUT_AT_END is not set, for instance
247
* in a decompression converter where the end of data is detectable from the
248
* data (and there might even be other data after the end of the compressed data).
250
* When some data has successfully been converted @a bytes_read and is set to
251
* the number of bytes read from @a inbuf, and @a bytes_written is set to indicate
252
* how many bytes was written to @a outbuf. If there are more data to output
253
* or consume (i.e. unless the CONVERTER_INPUT_AT_END is specified) then
254
* CONVERTER_CONVERTED is returned, and if no more data is to be output
255
* then CONVERTER_FINISHED is returned.
257
* On error CONVERTER_ERROR is returned and @a error is set accordingly.
258
* Some errors need special handling:
260
* IO_ERROR_NO_SPACE is returned if there is not enough space
261
* to write the resulting converted data, the application should
262
* call the function again with a larger @a outbuf to continue.
264
* IO_ERROR_PARTIAL_INPUT is returned if there is not enough
265
* input to fully determine what the conversion should produce,
266
* and the CONVERTER_INPUT_AT_END flag is not set. This happens for
267
* example with an incomplete multibyte sequence when converting text,
268
* or when a regexp matches up to the end of the input (and may match
269
* further input). It may also happen when @a inbuf_size is zero and
270
* there is no more data to produce.
272
* When this happens the application should read more input and then
273
* call the function again. If further input shows that there is no
274
* more data call the function again with the same data but with
275
* the CONVERTER_INPUT_AT_END flag set. This may cause the conversion
276
* to finish as e.g. in the regexp match case (or, to fail again with
277
* IO_ERROR_PARTIAL_INPUT in e.g. a charset conversion where the
278
* input is actually partial).
280
* After g_converter_convert() has returned CONVERTER_FINISHED the
281
* converter object is in an invalid state where its not allowed
282
* to call g_converter_convert() anymore. At this time you can only
283
* free the object or call g_converter_reset() to reset it to the
286
* If the flag CONVERTER_FLUSH is set then conversion is modified
287
* to try to write out all internal state to the output. The application
288
* has to call the function multiple times with the flag set, and when
289
* the available input has been consumed and all internal state has
290
* been produced then CONVERTER_FLUSHED (or CONVERTER_FINISHED if
291
* really at the end) is returned instead of CONVERTER_CONVERTED.
292
* This is somewhat similar to what happens at the end of the input stream,
293
* but done in the middle of the data.
295
* This has different meanings for different conversions. For instance
296
* in a compression converter it would mean that we flush all the
297
* compression state into output such that if you uncompress the
298
* compressed data you get back all the input data. Doing this may
299
* make the final file larger due to padding though. Another example
300
* is a regexp conversion, where if you at the end of the flushed data
301
* have a match, but there is also a potential longer match. In the
302
* non-flushed case we would ask for more input, but when flushing we
303
* treat this as the end of input and do the match.
305
* Flushing is not always possible (like if a charset converter flushes
306
* at a partial multibyte sequence). Converters are supposed to try
307
* to produce as much output as possible and then return an error
308
* (typically IO_ERROR_PARTIAL_INPUT).
311
* @param inbuf The buffer
312
* containing the data to convert.
313
* @param inbuf_size The number of bytes in @a inbuf.
314
* @param outbuf A buffer to write converted data in.
315
* @param outbuf_size The number of bytes in @a outbuf, must be at least one.
316
* @param flags A ConverterFlags controlling the conversion details.
317
* @param bytes_read Will be set to the number of bytes read from @a inbuf on success.
318
* @param bytes_written Will be set to the number of bytes written to @a outbuf on success.
319
* @return A ConverterResult, CONVERTER_ERROR on error.
321
ConverterResult convert(const void* inbuf, gsize inbuf_size, void* outbuf, gsize outbuf_size, ConverterFlags flags, gsize& bytes_read, gsize& bytes_written);
323
/** Resets all internal state in the converter, making it behave
324
* as if it was just created. If the converter has any internal
325
* state that would produce output then that output is lost.
332
virtual ConverterResult convert_vfunc(const void* inbuf, gsize inbuf_size, void* outbuf, gsize outbuf_size, ConverterFlags flags, gsize& bytes_read, gsize& bytes_written);
335
virtual void reset_vfunc();
341
//C++ methods used to invoke GTK+ virtual functions:
344
//GTK+ Virtual Functions (override these to change behaviour):
346
//Default Signal Handlers::
356
/** A Glib::wrap() method for this object.
358
* @param object The C instance.
359
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
360
* @result A C++ instance that wraps this C instance.
362
* @relates Gio::Converter
364
Glib::RefPtr<Gio::Converter> wrap(GConverter* object, bool take_copy = false);
369
#endif /* _GIOMM_CONVERTER_H */