Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# iochannel.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2003 The Inti Development Team.
    00003  *
    00004  *  This program is free software; you can redistribute it and/or modify
    00005  *  it under the terms of the GNU General Public License as published by
    00006  *  the Free Software Foundation; either version 2 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  This program is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this program; if not, write to the Free Software
    00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00017  */
    00018
    00023
    00024 #ifndef INTI_G_IOCHANNEL_H
    00025 #define INTI_G_IOCHANNEL_H
    00026
    00027 #ifndef INTI_OBJECT_H
    00028 #include <inti/object.h>
    00029 #endif
    00030
    00031 #ifndef INTI_SLOT_H
    00032 #include <inti/slot.h>
    00033 #endif
    00034
    00035 #ifndef INTI_UTF_STRING_H
    00036 #include <inti/utf-string.h>
    00037 #endif
    00038
    00039 #ifndef __G_IOCHANNEL_H__
    00040 #include <glib/giochannel.h>
    00041 #endif
    00042
    00043 namespace Inti {
    00044
    00045 namespace G {
    00046
    00047 class Error;
    00048
    00051
    00052 enum IOChannelError
    00053 {
    00054         IO_CHANNEL_ERROR_FBIG = G_IO_CHANNEL_ERROR_FBIG,
    00055         IO_CHANNEL_ERROR_INVAL = G_IO_CHANNEL_ERROR_INVAL,
    00056         IO_CHANNEL_ERROR_IO = G_IO_CHANNEL_ERROR_IO,
    00057         IO_CHANNEL_ERROR_ISDIR = G_IO_CHANNEL_ERROR_ISDIR,
    00058         IO_CHANNEL_ERROR_NOSPC = G_IO_CHANNEL_ERROR_NOSPC,
    00059         IO_CHANNEL_ERROR_NXIO = G_IO_CHANNEL_ERROR_NXIO,
    00060         IO_CHANNEL_ERROR_OVERFLOW = G_IO_CHANNEL_ERROR_OVERFLOW,
    00061         IO_CHANNEL_ERROR_PIPE = G_IO_CHANNEL_ERROR_PIPE,
    00062         IO_CHANNEL_ERROR_FAILED = G_IO_CHANNEL_ERROR_FAILED
    00063
    00064 };
    00065
    00068
    00069 enum IOStatus
    00070 {
    00071         IO_STATUS_ERROR = G_IO_STATUS_ERROR,
    00072         IO_STATUS_NORMAL = G_IO_STATUS_NORMAL,
    00073         IO_STATUS_EOF = G_IO_STATUS_EOF,
    00074         IO_STATUS_AGAIN = G_IO_STATUS_AGAIN
    00075 };
    00076
    00079
    00080 enum SeekType
    00081 {
    00082         IO_SEEK_CUR = G_SEEK_CUR,
    00083         IO_SEEK_SET = G_SEEK_SET,
    00084         IO_SEEK_END = G_SEEK_END
    00085 };
    00086
    00089
    00090 enum IOCondition
    00091 {
    00092         IO_IN = G_IO_IN,
    00093         IO_OUT = G_IO_OUT,
    00094         IO_PRI = G_IO_PRI,
    00095         IO_ERR = G_IO_ERR,
    00096         IO_HUP = G_IO_HUP,
    00097         IO_NVAL = G_IO_NVAL
    00098 } ;
    00099
    00101
    00102 typedef unsigned int IOConditionField;
    00103
    00107
    00108 enum IOFlags
    00109 {
    00110         IO_FLAG_APPEND = G_IO_FLAG_APPEND,
    00112
    00113         IO_FLAG_NONBLOCK = G_IO_FLAG_NONBLOCK,
    00115
    00116         IO_FLAG_IS_READABLE = G_IO_FLAG_IS_READABLE,    /* Read only flag */
    00118
    00119         IO_FLAG_IS_WRITEABLE = G_IO_FLAG_IS_WRITEABLE,  /* Read only flag */
    00121
    00122         IO_FLAG_IS_SEEKABLE = G_IO_FLAG_IS_SEEKABLE,    /* Read only flag */
    00124
    00125         IO_FLAG_MASK = G_IO_FLAG_MASK,
    00127
    00128         IO_FLAG_GET_MASK = G_IO_FLAG_GET_MASK,
    00130
    00131         IO_FLAG_SET_MASK = G_IO_FLAG_SET_MASK
    00133 };
    00134
    00136
    00137 typedef unsigned int IOFlagsField;
    00138
    00161
    00162 class IOChannel : public ReferencedObject
    00163 {
    00164         IOChannel(const IOChannel&);
    00165         IOChannel& operator=(const IOChannel&);
    00166
    00167         GIOChannel *channel_;
    00168
    00169 public:
    00170         typedef Slot2<bool, IOChannel&, IOConditionField> IOSlot;
    00181
    00184
    00185         explicit IOChannel(GIOChannel *channel, bool reference = true);
    00192
    00193         virtual ~IOChannel();
    00195
    00197
    00198         static Pointer<IOChannel> create(const String& filename, const char *mode, G::Error *error);
    00206
    00207         static Pointer<IOChannel> create(int fd);
    00216
    00217         static IOChannelError error_from_errno(int errno_number);
    00221
    00224
    00225         GIOChannel* g_io_channel() const { return channel_; }
    00227
    00228         size_t get_buffer_size() const;
    00231
    00232         IOConditionField get_buffer_condition() const;
    00238
    00239         IOFlagsField get_flags() const;
    00248
    00249         String get_line_term() const;
    00253
    00254         bool get_buffered() const;
    00257
    00258         String get_encoding() const;
    00264
    00265         bool get_close_on_unref() const;
    00272
    00273         int get_fd() const;
    00276
    00280
    00281         virtual void ref();
    00283
    00284         virtual void unref();
    00291
    00292         IOStatus close(bool flush, G::Error *error);
    00302
    00303         unsigned int add_watch(IOConditionField condition, const IOSlot *slot, int priority = G_PRIORITY_DEFAULT, GDestroyNotify notify = 0);
    00310
    00311         void set_buffer_size(size_t size);
    00314
    00315         IOStatus set_flags(IOFlagsField flags, G::Error *error);
    00320
    00321         void set_line_term(const String& line_term);
    00327
    00328         void set_buffered(bool buffered);
    00340
    00341         IOStatus set_encoding(const char *encoding, G::Error *error);
    00362
    00363         void set_close_on_unref(bool do_close);
    00369
    00370         IOStatus flush(G::Error *error);
    00374
    00375         IOStatus read_line(String& str, G::Error *error);
    00380
    00381         IOStatus read_to_end(String& str, G::Error *error);
    00386
    00387         IOStatus read(char *buffer, size_t count, size_t *bytes_read, G::Error *error);
    00399
    00400         IOStatus read(String& str, size_t count, G::Error *error);
    00409
    00410         IOStatus read(G::Unichar& unichar, G::Error *error);
    00415
    00416         IOStatus write(const char *buffer, size_t count, size_t *bytes_written, G::Error *error);
    00432
    00433         IOStatus write(const String& str, G::Error *error);
    00443
    00444         IOStatus write(G::Unichar unichar, G::Error *error);
    00449
    00450         IOStatus seek(gint64 offset, SeekType type, G::Error *error);
    00459
    00461
    00462 };
    00463
    00464 } // namespace G
    00465
    00466 } // namespace Inti
    00467
    00468 #endif // INTI_G_IOCHANNEL_H

Main Page - Footer