GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

iochannel.hh

Go to the documentation of this file.
00001 /* GFC-Core: GTK+ Foundation Classes (Core Library) 00002 * Copyright (C) 2003-2004 The GFC 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 GFC_G_IOCHANNEL_HH 00025 #define GFC_G_IOCHANNEL_HH 00026 00027 #ifndef GFC_TRACKABLE_HH 00028 #include <gfc/trackable.hh> 00029 #endif 00030 00031 #ifndef GFC_UTF_STRING_HH 00032 #include <gfc/utfstring.hh> 00033 #endif 00034 00035 #ifndef __G_IOCHANNEL_H__ 00036 #include <glib/giochannel.h> 00037 #endif 00038 00039 namespace GFC { 00040 00041 namespace G { 00042 00043 class Error; 00044 class Source; 00045 00048 00049 enum IOChannelError 00050 { 00051 IO_CHANNEL_ERROR_FBIG = G_IO_CHANNEL_ERROR_FBIG, 00052 IO_CHANNEL_ERROR_INVAL = G_IO_CHANNEL_ERROR_INVAL, 00053 IO_CHANNEL_ERROR_IO = G_IO_CHANNEL_ERROR_IO, 00054 IO_CHANNEL_ERROR_ISDIR = G_IO_CHANNEL_ERROR_ISDIR, 00055 IO_CHANNEL_ERROR_NOSPC = G_IO_CHANNEL_ERROR_NOSPC, 00056 IO_CHANNEL_ERROR_NXIO = G_IO_CHANNEL_ERROR_NXIO, 00057 IO_CHANNEL_ERROR_OVERFLOW = G_IO_CHANNEL_ERROR_OVERFLOW, 00058 IO_CHANNEL_ERROR_PIPE = G_IO_CHANNEL_ERROR_PIPE, 00059 IO_CHANNEL_ERROR_FAILED = G_IO_CHANNEL_ERROR_FAILED 00060 00061 }; 00062 00065 00066 enum IOStatus 00067 { 00068 IO_STATUS_ERROR = G_IO_STATUS_ERROR, 00069 IO_STATUS_NORMAL = G_IO_STATUS_NORMAL, 00070 IO_STATUS_EOF = G_IO_STATUS_EOF, 00071 IO_STATUS_AGAIN = G_IO_STATUS_AGAIN 00072 }; 00073 00076 00077 enum SeekType 00078 { 00079 IO_SEEK_CUR = G_SEEK_CUR, 00080 IO_SEEK_SET = G_SEEK_SET, 00081 IO_SEEK_END = G_SEEK_END 00082 }; 00083 00086 00087 enum IOCondition 00088 { 00089 IO_IN = G_IO_IN, 00090 IO_OUT = G_IO_OUT, 00091 IO_PRI = G_IO_PRI, 00092 IO_ERR = G_IO_ERR, 00093 IO_HUP = G_IO_HUP, 00094 IO_NVAL = G_IO_NVAL 00095 } ; 00096 00098 00099 typedef unsigned int IOConditionField; 00100 00104 00105 enum IOFlags 00106 { 00107 IO_FLAG_APPEND = G_IO_FLAG_APPEND, 00109 00110 IO_FLAG_NONBLOCK = G_IO_FLAG_NONBLOCK, 00112 00113 IO_FLAG_IS_READABLE = G_IO_FLAG_IS_READABLE, /* Read only flag */ 00115 00116 IO_FLAG_IS_WRITEABLE = G_IO_FLAG_IS_WRITEABLE, /* Read only flag */ 00118 00119 IO_FLAG_IS_SEEKABLE = G_IO_FLAG_IS_SEEKABLE, /* Read only flag */ 00121 00122 IO_FLAG_MASK = G_IO_FLAG_MASK, 00124 00125 IO_FLAG_GET_MASK = G_IO_FLAG_GET_MASK, 00127 00128 IO_FLAG_SET_MASK = G_IO_FLAG_SET_MASK 00130 }; 00131 00133 00134 typedef unsigned int IOFlagsField; 00135 00158 00159 class IOChannel : public Trackable 00160 { 00161 IOChannel(const IOChannel&); 00162 IOChannel& operator=(const IOChannel&); 00163 00164 GIOChannel *channel_; 00165 00166 public: 00169 00170 explicit IOChannel(GIOChannel *channel, bool owns_reference = true); 00177 00178 virtual ~IOChannel(); 00180 00182 00183 static Pointer<IOChannel> create(const String& filename, const char *mode, G::Error *error); 00191 00192 static Pointer<IOChannel> create(int fd, bool close_on_unref = false); 00202 00203 static IOChannelError error_from_errno(int errno_number); 00207 00210 00211 GIOChannel* g_io_channel() const; 00213 00214 operator GIOChannel* () const; 00216 00217 size_t get_buffer_size() const; 00220 00221 IOConditionField get_buffer_condition() const; 00227 00228 IOFlagsField get_flags() const; 00237 00238 String get_line_term() const; 00242 00243 bool get_buffered() const; 00246 00247 String get_encoding() const; 00253 00254 bool get_close_on_unref() const; 00261 00262 int get_fd() const; 00265 00269 00270 virtual void ref(); 00272 00273 virtual void unref(); 00280 00281 IOStatus close(bool flush, G::Error *error = 0); 00291 00292 void set_buffer_size(size_t size); 00295 00296 IOStatus set_flags(IOFlagsField flags, G::Error *error = 0); 00301 00302 void set_line_term(const String& line_term); 00308 00309 void set_buffered(bool buffered); 00321 00322 IOStatus set_encoding(const char *encoding, G::Error *error = 0); 00343 00344 void set_close_on_unref(bool do_close); 00350 00351 IOStatus flush(G::Error *error = 0); 00355 00356 IOStatus read_line(String& str, size_t *bytes_read, G::Error *error = 0); 00362 00363 IOStatus read_to_end(String& str, size_t *bytes_read, G::Error *error = 0); 00369 00370 IOStatus read(char *buffer, size_t count, size_t *bytes_read, G::Error *error = 0); 00382 00383 IOStatus read(String& str, size_t *bytes_read, G::Error *error = 0); 00392 00393 IOStatus read(G::Unichar& unichar, G::Error *error = 0); 00398 00399 IOStatus write(const char *buffer, size_t count, size_t *bytes_written, G::Error *error = 0); 00415 00416 IOStatus write(const String& str, size_t *bytes_written, G::Error *error = 0); 00427 00428 IOStatus write(G::Unichar unichar, G::Error *error = 0); 00433 00434 IOStatus seek(gint64 offset, SeekType type, G::Error *error = 0); 00443 00445 00446 }; 00447 00448 } // namespace G 00449 00450 } // namespace GFC 00451 00452 #include <gfc/glib/inline/iochannel.inl> 00453 00454 #endif // GFC_G_IOCHANNEL_HH

Generated on Tue Aug 24 00:04:56 2004 for GFC-Core by doxygen 1.3.8