Samond Classes Library 1.2.4-RELEASE build 198
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 
24 #import <Foundation/Foundation.h>
25 #import <scl/SCObject.h>
27 
28 #pragma mark -
29 #pragma mark Class Constants
30 
39 #define SCStreamClass @"SCStream"
40 
45 #define SC_STREAM_MAX_STRING_LENGTH 4096
46 
51 #define SC_NULL_NSSTRING @"__NULL_NSSTRING__"
52 
57 #define SC_NULL_OBJECT @"__NULL_OBJECT__"
58 
59 
60 #pragma mark -
61 #pragma mark Stream Support Types
62 
71 typedef enum {
77 
83 
90 
95 typedef enum {
101 
107 
113 
119 
125 
131 
137 
143 
149 
155 
161 
168 
174 
175 
176 @protocol SCStreamDelegate;
177 @class SCStreamException;
178 
179 #pragma mark -
180 
237 @interface SCStream : SCObject {
238  SCStreamErrorHandling fErrorHandling; // Errors handling mode
239  SCStreamStatus fStatus; // Stream status
240  NSString *fName; // Stream name
241  BOOL fOpened; // Stream opening flag
242  id fObject; // Pointer to the current loaded object
243  SCStreamException *fStreamException; // Last detected stream error
244  SCSystemException *fSystemException; // Last detected system error
245  id<SCStreamDelegate> fDelegate; // Stream delegate object
246  SCULong fTotalRead; // Number of the totally readed characters
247  SCULong fTotalWrite; // Number of the totally writed characters
248  SCULong fLastRead; // Number of the characters that were readed during last operation
249  SCULong fLastWrite; // Number of the characters that were writed during last operation
250 }
251 #pragma mark -
252 #pragma mark Свойства экземпляра класса
253 
264 @property (nonatomic, readwrite, assign) SCStreamErrorHandling errorHandling;
265 
270 @property (nonatomic, readonly, assign) SCStreamStatus status;
271 
276 @property (nonatomic, readonly, retain) NSString *name;
277 
282 @property (nonatomic, readonly, assign) BOOL opened;
283 
288 @property (nonatomic, readonly, assign) BOOL readable;
289 
294 @property (nonatomic, readonly, assign) BOOL writable;
295 
300 @property (nonatomic, readonly, assign) BOOL readOnly;
301 
306 @property (nonatomic, readonly, assign) BOOL writeOnly;
307 
312 @property (nonatomic, readonly, assign) BOOL readWrite;
313 
318 @property (nonatomic, readonly, assign) id object;
319 
324 @property (nonatomic, readonly, retain) SCStreamException *streamException;
325 
330 @property (nonatomic, readonly, retain) SCSystemException *systemException;
331 
336 @property (nonatomic, readwrite, retain) id<SCStreamDelegate> delegate;
337 
357 @property (nonatomic, readonly, assign) BOOL eof;
358 
370 @property (nonatomic, readonly, assign) SCULong totalRead;
371 
376 @property (nonatomic, readonly, assign) SCULong totalWrite;
377 
382 @property (nonatomic, readonly, assign) SCULong lastRead;
383 
388 @property (nonatomic, readonly, assign) SCULong lastWrite;
389 
392 #pragma mark -
393 #pragma mark Initializing Streams
394 - (instancetype)init;
395 
396 #pragma mark -
397 #pragma mark Data Reading
398 - (SCSize)readBytes:(SCSize)count toBuffer:(void *)buffer;
399 - (id)readObject;
400 - (SCByte)readByte;
401 - (SCUByte)readUByte;
402 - (SCShort)readShort;
403 - (SCUShort)readUShort;
404 - (SCInteger)readInteger;
405 - (SCUInteger)readUInteger;
406 - (SCLong)readLong;
407 - (SCULong)readULong;
408 - (char)readChar;
409 - (unichar)readUnichar;
410 - (const char *)readCharString;
411 - (BOOL)readBool;
412 - (SCFloat)readFloat;
413 - (SCDouble)readDouble;
414 - (NSInteger)readNSInteger;
415 - (NSUInteger)readNSUInteger;
416 - (SCSize)readToByte:(SCByte *)buffer;
417 - (SCSize)readToUByte:(SCUByte *)buffer;
418 - (SCSize)readToShort:(SCShort *)buffer;
419 - (SCSize)readToUShort:(SCUShort *)buffer;
420 - (SCSize)readToInteger:(SCInteger *)buffer;
421 - (SCSize)readToUInteger:(SCUInteger *)buffer;
422 - (SCSize)readToLong:(SCULong *)buffer;
423 - (SCSize)readToULong:(SCULong *)buffer;
424 - (SCSize)readToChar:(char *)buffer;
425 - (SCSize)readToUnichar:(unichar *)buffer;
426 - (SCSize)readToCharString:(char *)buffer max:(SCSize)max;
427 - (SCSize)readToBool:(BOOL *)buffer;
428 - (SCSize)readToFloat:(SCFloat *)buffer;
429 - (SCSize)readToDouble:(SCDouble *)buffer;
430 - (SCSize)readToNSInteger:(NSInteger *)buffer;
431 - (SCSize)readToNSUInteger:(NSUInteger *)buffer;
432 
433 #pragma mark -
434 #pragma mark Data Writing
435 - (SCSize)writeBytes:(SCSize)count fromBuffer:(const void *)buffer;
436 - (void)writeObject:(id<SCStreaming>)object;
437 - (void)writeByte:(SCByte)variable;
438 - (void)writeUByte:(SCUByte)variable;
439 - (void)writeShort:(SCShort)variable;
440 - (void)writeUShort:(SCUShort)variable;
441 - (void)writeInteger:(SCInteger)variable;
442 - (void)writeUInteger:(SCUInteger)variable;
443 - (void)writeLong:(SCLong)variable;
444 - (void)writeULong:(SCULong)variable;
445 - (void)writeChar:(char)variable;
446 - (void)writeUnichar:(unichar)variable;
447 - (void)writeCharString:(const char *)variable;
448 - (void)writeBool:(BOOL)variable;
449 - (void)writeFloat:(SCFloat)variable;
450 - (void)writeDouble:(SCDouble)variable;
451 - (void)writeNSInteger:(NSInteger)variable;
452 - (void)writeNSUInteger:(NSUInteger)variable;
453 
454 #pragma mark -
455 #pragma mark Text Files Support
456 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding max:(SCInteger)max;
457 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding;
458 - (NSString *)readStringWithMax:(SCInteger)max;
459 - (NSString *)readString;
460 - (void)writeString:(NSString *)string encoding:(NSStringEncoding)encoding;
461 - (void)writeString:(NSString *)string;
462 
463 #pragma mark -
464 #pragma mark Statistic Methods
465 - (void)resetStats;
466 
467 @end
uint64_t SCULong
Definition: SCTypes.h:86
int16_t SCShort
Definition: SCTypes.h:43
Definition: SCStream.h:112
Definition: SCStream.h:130
int64_t SCLong
Definition: SCTypes.h:58
Definition: SCStream.h:100
int32_t SCInteger
Definition: SCTypes.h:49
uint32_t SCUInteger
Definition: SCTypes.h:77
SCStreamStatusCode
Definition: SCStream.h:95
Definition: SCStream.h:118
Class SCObject header file.
Definition: SCStream.h:160
Definition: SCStream.h:82
int8_t SCByte
Definition: SCTypes.h:37
Streams events handling class.
Definition: SCStreamDelegate.h:274
uint16_t SCUShort
Definition: SCTypes.h:71
SCStreamErrorHandling
Definition: SCStream.h:71
Parent class of all library classes.
Definition: SCObject.h:61
uint8_t SCUByte
Definition: SCTypes.h:65
Definition: SCStream.h:142
System error exception class.
Definition: SCSystemException.h:101
Definition: SCStream.h:148
Definition: SCStream.h:106
Exception SCSystemException header file.
Definition: SCStream.h:76
Definition: SCStream.h:166
double SCDouble
Definition: SCTypes.h:99
Streams communications protocol.
Definition: SCStreaming.h:43
Exception class SCStreamException.
Definition: SCStreamException.h:343
SCInteger SCStreamStatus
Definition: SCStream.h:173
float SCFloat
Definition: SCTypes.h:93
Definition: SCStream.h:136
Definition: SCStream.h:88
Definition: SCStream.h:124
Abstract parent class of the stream classes hierarchy.
Definition: SCStream.h:237
size_t SCSize
Definition: SCTypes.h:214
Definition: SCStream.h:154