iodevice.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Mark Page
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 #include "../api_core.h"
00036 #include "datatypes.h"
00037 #include "../System/sharedptr.h"
00038 
00039 class CL_IODeviceProvider;
00040 class CL_IODevice_Impl;
00041 
00048 class CL_API_CORE CL_IODevice
00049 {
00052 
00053 public:
00055         enum SeekMode
00056         {
00058                 seek_set,
00059 
00061                 seek_cur,
00062 
00064                 seek_end
00065         };
00066 
00070 
00071 public:
00073         CL_IODevice();
00074 
00078         CL_IODevice(CL_IODeviceProvider *provider);
00079 
00080         ~CL_IODevice();
00081 
00085 
00086 public:
00088         bool is_null() const;
00089         
00091 
00093         int get_size() const;
00094 
00096 
00098         int get_position() const;
00099 
00101 
00102         bool is_little_endian() const;
00103 
00107 
00108 public:
00110 
00115         int send(const void *data, int len, bool send_all = true);
00116 
00124         int receive(void *data, int len, bool receive_all = true);
00125 
00131         int peek(void *data, int len);
00132 
00138         bool seek(int position, SeekMode mode = seek_set);
00139 
00147         int read(void *data, int len, bool receive_all = true);
00148 
00156         int write(const void *data, int len, bool send_all = true);
00157 
00159         void set_system_mode();
00160 
00162         void set_big_endian_mode();
00163 
00165         void set_little_endian_mode();
00166 
00170         void write_int64(cl_int64 data);
00171 
00175         void write_uint64(cl_uint64 data);
00176 
00180         void write_int32(cl_int32 data);
00181 
00185         void write_uint32(cl_uint32 data);
00186 
00190         void write_int16(cl_int16 data);
00191 
00195         void write_uint16(cl_uint16 data);
00196 
00200         void write_int8(cl_int8 data);
00201 
00205         void write_uint8(cl_uint8 data);
00206 
00212         void write_float(float data);
00213 
00220         void write_string_a(const CL_StringRef8 &str);
00221 
00223 
00224         cl_int64 read_int64();
00225 
00227 
00228         cl_uint64 read_uint64();
00229 
00231 
00232         cl_int32 read_int32();
00233 
00235 
00236         cl_uint32 read_uint32();
00237 
00239 
00240         cl_int16 read_int16();
00241 
00243 
00244         cl_uint16 read_uint16();
00245 
00247 
00248         cl_int8 read_int8();
00249 
00251 
00252         cl_uint8 read_uint8();
00253 
00255 
00257         float read_float();
00258 
00260 
00263         CL_String8 read_string_a();
00264 
00266 
00269         CL_String8 read_string_nul();
00270 
00279         CL_String8 read_string_text(const char *skip_initial_chars, const char *read_until_chars, bool allow_eof = true);
00280 
00282         CL_IODevice duplicate();
00283 
00287 
00288 protected:
00289         CL_SharedPtr<CL_IODevice_Impl> impl;
00291 };
00292 

Generated on Thu Dec 3 02:39:29 2009 for ClanLib by  doxygen 1.4.6