Samond Classes Library 1.2.2-RELEASE build 188
SCStream.h
Go to the documentation of this file.
1 //
2 // SCStream.h
3 // scl
4 //
5 // Created by Viacheslav Smolensky on 02.03.12.
6 // Copyright (c) 2007 - 2017 by Samond Development Corporation. All rights reserved.
7 //
8 
25 #import <Foundation/Foundation.h>
26 #import <scl/SCObject.h>
29 
30 #pragma mark -
31 #pragma mark Class Constants
32 
41 #define SCStreamClass @"SCStream"
42 
47 #define SC_STREAM_MAX_STRING_LENGTH 4096
48 
49 
50 #pragma mark -
51 #pragma mark Stream Support Types
52 
61 typedef enum {
67 
73 
80 
85 typedef enum {
91 
97 
103 
109 
115 
121 
127 
133 
139 
145 
151 
158 
164 
165 
166 @protocol SCStreamDelegate;
167 
168 #pragma mark -
169 
226 @interface SCStream : SCObject {
227  SCStreamErrorHandling fErrorHandling; // Errors handling mode
228  SCStreamStatus fStatus; // Stream status
229  NSString *fName; // Stream name
230  BOOL fOpened; // Stream opening flag
231  id fObject; // Pointer to the current loaded object
232  SCStreamException *fStreamException; // Last detected stream error
233  SCSystemException *fSystemException; // Last detected system error
234  id<SCStreamDelegate> fDelegate; // Stream delegate object
235  SCULong fTotalRead; // Number of the totally readed characters
236  SCULong fTotalWrite; // Number of the totally writed characters
237  SCULong fLastRead; // Number of the characters that were readed during last operation
238  SCULong fLastWrite; // Number of the characters that were writed during last operation
239 }
240 #pragma mark -
241 #pragma mark Свойства экземпляра класса
242 
253 @property (nonatomic, readwrite, assign) SCStreamErrorHandling errorHandling;
254 
259 @property (nonatomic, readonly, assign) SCStreamStatus status;
260 
265 @property (nonatomic, readonly, retain) NSString *name;
266 
271 @property (nonatomic, readonly, assign) BOOL opened;
272 
277 @property (nonatomic, readonly, assign) BOOL readable;
278 
283 @property (nonatomic, readonly, assign) BOOL writable;
284 
289 @property (nonatomic, readonly, assign) BOOL readOnly;
290 
295 @property (nonatomic, readonly, assign) BOOL writeOnly;
296 
301 @property (nonatomic, readonly, assign) BOOL readWrite;
302 
307 @property (nonatomic, readonly, assign) id object;
308 
313 @property (nonatomic, readonly, retain) SCStreamException *streamException;
314 
319 @property (nonatomic, readonly, retain) SCSystemException *systemException;
320 
325 @property (nonatomic, readwrite, retain) id<SCStreamDelegate> delegate;
326 
346 @property (nonatomic, readonly, assign) BOOL eof;
347 
359 @property (nonatomic, readonly, assign) SCULong totalRead;
360 
365 @property (nonatomic, readonly, assign) SCULong totalWrite;
366 
371 @property (nonatomic, readonly, assign) SCULong lastRead;
372 
377 @property (nonatomic, readonly, assign) SCULong lastWrite;
378 
381 #pragma mark -
382 #pragma mark Initializing Streams
383 - (instancetype)init;
384 
385 #pragma mark -
386 #pragma mark Data Reading
387 - (SCSize)readBytes:(SCSize)count toBuffer:(void *)buffer;
388 - (id)readObject;
389 - (SCByte)readByte;
390 - (SCUByte)readUByte;
391 - (SCShort)readShort;
392 - (SCUShort)readUShort;
393 - (SCInteger)readInteger;
394 - (SCUInteger)readUInteger;
395 - (SCLong)readLong;
396 - (SCULong)readULong;
397 - (char)readChar;
398 - (unichar)readUnichar;
399 - (const char *)readCharString;
400 - (BOOL)readBool;
401 - (SCFloat)readFloat;
402 - (SCDouble)readDouble;
403 - (NSInteger)readNSInteger;
404 - (NSUInteger)readNSUInteger;
405 - (SCSize)readToByte:(SCByte *)buffer;
406 - (SCSize)readToUByte:(SCUByte *)buffer;
407 - (SCSize)readToShort:(SCShort *)buffer;
408 - (SCSize)readToUShort:(SCUShort *)buffer;
409 - (SCSize)readToInteger:(SCInteger *)buffer;
410 - (SCSize)readToUInteger:(SCUInteger *)buffer;
411 - (SCSize)readToLong:(SCULong *)buffer;
412 - (SCSize)readToULong:(SCULong *)buffer;
413 - (SCSize)readToChar:(char *)buffer;
414 - (SCSize)readToUnichar:(unichar *)buffer;
415 - (SCSize)readToCharString:(char *)buffer max:(SCSize)max;
416 - (SCSize)readToBool:(BOOL *)buffer;
417 - (SCSize)readToFloat:(SCFloat *)buffer;
418 - (SCSize)readToDouble:(SCDouble *)buffer;
419 - (SCSize)readToNSInteger:(NSInteger *)buffer;
420 - (SCSize)readToNSUInteger:(NSUInteger *)buffer;
421 
422 #pragma mark -
423 #pragma mark Data Writing
424 - (SCSize)writeBytes:(SCSize)count fromBuffer:(const void *)buffer;
425 - (void)writeObject:(id<SCStreaming>)object;
426 - (void)writeByte:(SCByte)variable;
427 - (void)writeUByte:(SCUByte)variable;
428 - (void)writeShort:(SCShort)variable;
429 - (void)writeUShort:(SCUShort)variable;
430 - (void)writeInteger:(SCInteger)variable;
431 - (void)writeUInteger:(SCUInteger)variable;
432 - (void)writeLong:(SCLong)variable;
433 - (void)writeULong:(SCULong)variable;
434 - (void)writeChar:(char)variable;
435 - (void)writeUnichar:(unichar)variable;
436 - (void)writeCharString:(const char *)variable;
437 - (void)writeBool:(BOOL)variable;
438 - (void)writeFloat:(SCFloat)variable;
439 - (void)writeDouble:(SCDouble)variable;
440 - (void)writeNSInteger:(NSInteger)variable;
441 - (void)writeNSUInteger:(NSUInteger)variable;
442 
443 #pragma mark -
444 #pragma mark Text Files Support
445 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding max:(SCInteger)max;
446 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding;
447 - (NSString *)readStringWithMax:(SCInteger)max;
448 - (NSString *)readString;
449 - (void)writeString:(NSString *)string encoding:(NSStringEncoding)encoding;
450 - (void)writeString:(NSString *)string;
451 
452 #pragma mark -
453 #pragma mark Statistic Methods
454 - (void)resetStats;
455 
456 @end
uint64_t SCULong
Definition: SCTypes.h:82
int16_t SCShort
Definition: SCTypes.h:46
Definition: SCStream.h:102
Definition: SCStream.h:120
int64_t SCLong
Definition: SCTypes.h:58
Definition: SCStream.h:90
int32_t SCInteger
Definition: SCTypes.h:52
uint32_t SCUInteger
Definition: SCTypes.h:76
SCStreamStatusCode
Definition: SCStream.h:85
Definition: SCStream.h:108
Class SCObject header file.
Definition: SCStream.h:150
Definition: SCStream.h:72
int8_t SCByte
Definition: SCTypes.h:40
Streams events handling class.
Definition: SCStreamDelegate.h:272
uint16_t SCUShort
Definition: SCTypes.h:70
SCStreamErrorHandling
Definition: SCStream.h:61
Parent class of all library classes.
Definition: SCObject.h:58
uint8_t SCUByte
Definition: SCTypes.h:64
Definition: SCStream.h:132
System error exception class.
Definition: SCSystemException.h:100
Definition: SCStream.h:138
Definition: SCStream.h:96
Exception SCSystemException header file.
Definition: SCStream.h:66
Definition: SCStream.h:156
double SCDouble
Definition: SCTypes.h:94
Streams communications protocol.
Definition: SCStreaming.h:42
Exception class SCStreamException.
Definition: SCStreamException.h:270
SCInteger SCStreamStatus
Definition: SCStream.h:163
float SCFloat
Definition: SCTypes.h:88
Definition: SCStream.h:126
Definition: SCStream.h:78
Class SCStreamException header file.
Definition: SCStream.h:114
Abstract parent class of the stream classes hierarchy.
Definition: SCStream.h:226
size_t SCSize
Definition: SCTypes.h:209
Definition: SCStream.h:144