Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00032
00033 #pragma once
00034
00035 #include "../api_core.h"
00036 #include "../System/cl_platform.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 { return !impl; }
00089
00091 void throw_if_null() const;
00092
00094
00096 int get_size() const;
00097
00099
00101 int get_position() const;
00102
00104
00105 bool is_little_endian() const;
00106
00108 const CL_IODeviceProvider *get_provider() const;
00109
00111 CL_IODeviceProvider *get_provider();
00112
00116
00117 public:
00119
00124 int send(const void *data, int len, bool send_all = true);
00125
00133 int receive(void *data, int len, bool receive_all = true);
00134
00140 int peek(void *data, int len);
00141
00147 bool seek(int position, SeekMode mode = seek_set);
00148
00156 int read(void *data, int len, bool receive_all = true);
00157
00165 int write(const void *data, int len, bool send_all = true);
00166
00168 void set_system_mode();
00169
00171 void set_big_endian_mode();
00172
00174 void set_little_endian_mode();
00175
00179 void write_int64(cl_byte64 data);
00180
00184 void write_uint64(cl_ubyte64 data);
00185
00189 void write_int32(cl_byte32 data);
00190
00194 void write_uint32(cl_ubyte32 data);
00195
00199 void write_int16(cl_byte16 data);
00200
00204 void write_uint16(cl_ubyte16 data);
00205
00209 void write_int8(cl_byte8 data);
00210
00214 void write_uint8(cl_ubyte8 data);
00215
00221 void write_float(float data);
00222
00229 void write_string_a(const CL_StringRef8 &str);
00230
00236 void write_string_nul(const CL_StringRef8 &str);
00237
00245 void write_string_text(const CL_StringRef8 &str);
00246
00248
00249 cl_byte64 read_int64();
00250
00252
00253 cl_ubyte64 read_uint64();
00254
00256
00257 cl_byte32 read_int32();
00258
00260
00261 cl_ubyte32 read_uint32();
00262
00264
00265 cl_byte16 read_int16();
00266
00268
00269 cl_ubyte16 read_uint16();
00270
00272
00273 cl_byte8 read_int8();
00274
00276
00277 cl_ubyte8 read_uint8();
00278
00280
00282 float read_float();
00283
00285
00288 CL_String8 read_string_a();
00289
00291
00294 CL_String8 read_string_nul();
00295
00305 CL_String8 read_string_text(const char *skip_initial_chars, const char *read_until_chars, bool allow_eof = true);
00306
00308 CL_IODevice duplicate();
00309
00313
00314 protected:
00315 CL_SharedPtr<CL_IODevice_Impl> impl;
00317 };
00318