Samond Classes Library 1.2.1-RELEASE build 181
SCStream.h
См. документацию.
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>
27 #import <scl/SCSystemException.h>
28 #import <scl/SCStreamException.h>
29 
30 #pragma mark -
31 #pragma mark Class Constants
32 
36 #define SCStreamClass @"SCStream"
37 #define SC_STREAM_MAX_STRING_LENGTH 4096
39 
41 #pragma mark -
42 #pragma mark Stream Support Types
43 
62 
68 
74 };
75 
87 
102 
108 
114 
120 
126 
132 
138 
144 
150 
156 
162 
168 };
169 
181 
182 @protocol SCStreamDelegate;
183 
184 #pragma mark -
185 
242 @interface SCStream : SCObject {
243  SCStreamErrorHandling fErrorHandling; // Errors handling mode
244  SCStreamStatus fStatus; // Stream status
245  NSString *fName; // Stream name
246  BOOL fOpened; // Stream opening flag
247  id fObject; // Pointer to the current loaded object
248  SCStreamException *fStreamException; // Last detected stream error
249  SCSystemException *fSystemException; // Last detected system error
250  id<SCStreamDelegate> fDelegate; // Stream delegate object
251  SCULong fTotalRead; // Number of the totally readed characters
252  SCULong fTotalWrite; // Number of the totally writed characters
253  SCULong fLastRead; // Number of the characters that were readed during last operation
254  SCULong fLastWrite; // Number of the characters that were writed during last operation
255 }
256 #pragma mark -
257 #pragma mark Свойства экземпляра класса
258 
269 @property (nonatomic, assign, getter=errorHandling, setter=setErrorHandling:) SCStreamErrorHandling errorHandling;
270 
275 @property (nonatomic, assign, readonly, getter=status) SCStreamStatus status;
276 
281 @property (nonatomic, retain, readonly, getter=name) NSString *name;
282 
287 @property (nonatomic, assign, readonly, getter=opened) BOOL opened;
288 
293 @property (nonatomic, assign, readonly, getter=readable) BOOL readable;
294 
299 @property (nonatomic, assign, readonly, getter=writable) BOOL writable;
300 
305 @property (nonatomic, assign, readonly, getter=readOnly) BOOL readOnly;
306 
311 @property (nonatomic, assign, readonly, getter=writeOnly) BOOL writeOnly;
312 
317 @property (nonatomic, assign, readonly, getter=readWrite) BOOL readWrite;
318 
323 @property (retain, readonly, getter=object) id object;
324 
329 @property (nonatomic, assign, readonly, getter=streamException) SCStreamException *streamException;
330 
335 @property (nonatomic, assign, readonly, getter=systemException) SCSystemException *systemException;
336 
341 @property (nonatomic, retain, getter=delegate, setter=setDelegate:) id<SCStreamDelegate> delegate;
342 
362 @property (nonatomic, assign, readonly, getter=eof) BOOL eof;
363 
375 @property (nonatomic, assign, readonly, getter=totalRead) SCULong totalRead;
376 
381 @property (nonatomic, assign, readonly, getter=totalWrite) SCULong totalWrite;
382 
387 @property (nonatomic, assign, readonly, getter=lastRead) SCULong lastRead;
388 
393 @property (nonatomic, assign, readonly, getter=lastWrite) SCULong lastWrite;
394 
397 #pragma mark -
398 #pragma mark Instance Properties
399 - (SCStreamErrorHandling)errorHandling;
400 - (SCStreamStatus)status;
401 - (NSString *)name;
402 - (BOOL)opened;
403 - (BOOL)readable;
404 - (BOOL)writable;
405 - (BOOL)readOnly;
406 - (BOOL)writeOnly;
407 - (BOOL)readWrite;
408 - (id)object;
409 - (SCStreamException *)streamException;
410 - (SCSystemException *)systemException;
411 - (id)delegate;
412 - (void)setErrorHandling:(SCStreamErrorHandling)mode;
413 - (void)setDelegate:(id<SCStreamDelegate>)delegate;
414 
415 #pragma mark -
416 #pragma mark Initializing Streams
417 - (instancetype)init;
418 
419 #pragma mark -
420 #pragma mark Data Reading
421 - (SCSize)readBytes:(SCSize)count toBuffer:(void *)buffer;
422 - (id)readObject;
423 - (SCByte)readByte;
424 - (SCUByte)readUByte;
425 - (SCShort)readShort;
426 - (SCUShort)readUShort;
427 - (SCInteger)readInteger;
428 - (SCUInteger)readUInteger;
429 - (SCLong)readLong;
430 - (SCULong)readULong;
431 - (char)readChar;
432 - (unichar)readUnichar;
433 - (const char *)readCharString;
434 - (BOOL)readBool;
435 - (SCFloat)readFloat;
436 - (SCDouble)readDouble;
437 - (NSInteger)readNSInteger;
438 - (NSUInteger)readNSUInteger;
439 - (SCSize)readToByte:(SCByte *)buffer;
440 - (SCSize)readToUByte:(SCUByte *)buffer;
441 - (SCSize)readToShort:(SCShort *)buffer;
442 - (SCSize)readToUShort:(SCUShort *)buffer;
443 - (SCSize)readToInteger:(SCInteger *)buffer;
444 - (SCSize)readToUInteger:(SCUInteger *)buffer;
445 - (SCSize)readToLong:(SCULong *)buffer;
446 - (SCSize)readToULong:(SCULong *)buffer;
447 - (SCSize)readToChar:(char *)buffer;
448 - (SCSize)readToUnichar:(unichar *)buffer;
449 - (SCSize)readToCharString:(char *)buffer max:(SCSize)max;
450 - (SCSize)readToBool:(BOOL *)buffer;
451 - (SCSize)readToFloat:(SCFloat *)buffer;
452 - (SCSize)readToDouble:(SCDouble *)buffer;
453 - (SCSize)readToNSInteger:(NSInteger *)buffer;
454 - (SCSize)readToNSUInteger:(NSUInteger *)buffer;
455 
456 #pragma mark -
457 #pragma mark Data Writing
458 - (SCSize)writeBytes:(SCSize)count fromBuffer:(const void *)buffer;
459 - (void)writeObject:(id<SCStreaming>)object;
460 - (void)writeByte:(SCByte)variable;
461 - (void)writeUByte:(SCUByte)variable;
462 - (void)writeShort:(SCShort)variable;
463 - (void)writeUShort:(SCUShort)variable;
464 - (void)writeInteger:(SCInteger)variable;
465 - (void)writeUInteger:(SCUInteger)variable;
466 - (void)writeLong:(SCLong)variable;
467 - (void)writeULong:(SCULong)variable;
468 - (void)writeChar:(char)variable;
469 - (void)writeUnichar:(unichar)variable;
470 - (void)writeCharString:(const char *)variable;
471 - (void)writeBool:(BOOL)variable;
472 - (void)writeFloat:(SCFloat)variable;
473 - (void)writeDouble:(SCDouble)variable;
474 - (void)writeNSInteger:(NSInteger)variable;
475 - (void)writeNSUInteger:(NSUInteger)variable;
476 
477 #pragma mark -
478 #pragma mark Text Files Support
479 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding max:(SCInteger)max;
480 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding;
481 - (NSString *)readStringWithMax:(SCInteger)max;
482 - (NSString *)readString;
483 - (void)writeString:(NSString *)string encoding:(NSStringEncoding)encoding;
484 - (void)writeString:(NSString *)string;
485 
486 #pragma mark -
487 #pragma mark Stream Seeking
488 - (BOOL)eof;
489 
490 #pragma mark -
491 #pragma mark Statistic Methods
492 - (SCULong)totalRead;
493 - (SCULong)totalWrite;
494 - (SCULong)lastRead;
495 - (SCULong)lastWrite;
496 - (void)resetStats;
497 
498 @end
uint64_t SCULong
Definition: SCTypes.h:82
int16_t SCShort
Definition: SCTypes.h:46
SCULong lastWrite
Definition: SCStream.h:393
Definition: SCStream.h:101
int64_t SCLong
Definition: SCTypes.h:58
BOOL readable
Definition: SCStream.h:293
Definition: SCStream.h:131
_SCStreamErrorHandling
Definition: SCStream.h:56
Definition: SCStream.h:137
Definition: SCStream.h:61
NSString * name
Definition: SCStream.h:281
SCStreamErrorHandling errorHandling
Definition: SCStream.h:269
int32_t SCInteger
Definition: SCTypes.h:52
SCStreamStatus status
Definition: SCStream.h:275
Definition: SCStream.h:155
SCULong totalWrite
Definition: SCStream.h:381
id< SCStreamDelegate > delegate
Definition: SCStream.h:341
uint32_t SCUInteger
Definition: SCTypes.h:76
Definition: SCStream.h:67
BOOL writable
Definition: SCStream.h:299
Definition: SCStream.h:143
_SCStreamStatus
Definition: SCStream.h:96
Definition: SCStream.h:161
int8_t SCByte
Definition: SCTypes.h:40
SCULong totalRead
Definition: SCStream.h:375
Класс реализует методы протокола SCStreamDelegate.
Definition: SCStreamDelegate.h:267
SCSystemException * systemException
Definition: SCStream.h:335
uint16_t SCUShort
Definition: SCTypes.h:70
SCInteger SCStreamStatus
Тип состояния потока
Definition: SCStream.h:180
enum _SCStreamErrorHandling SCStreamErrorHandling
Тип видов обработки возникших в протоке ошибок.
Definition: SCStream.h:86
Общий предок всех остальных классов библиотеки
Definition: SCObject.h:53
uint8_t SCUByte
Definition: SCTypes.h:64
id object
Definition: SCStream.h:323
Definition: SCStream.h:125
Definition: SCStream.h:107
Definition: SCStream.h:113
Класс исключительной ситуации системной ошибки
Definition: SCSystemException.h:87
Definition: SCStream.h:73
double SCDouble
Definition: SCTypes.h:94
Definition: SCStream.h:119
BOOL writeOnly
Definition: SCStream.h:311
Протокол поддержки механизма потоков
Definition: SCStreaming.h:42
BOOL eof
Definition: SCStream.h:362
Класс исключительных ситуаций в потоках
Definition: SCStreamException.h:165
SCStreamException * streamException
Definition: SCStream.h:329
float SCFloat
Definition: SCTypes.h:88
Definition: SCStream.h:167
Definition: SCStream.h:149
BOOL readWrite
Definition: SCStream.h:317
BOOL readOnly
Definition: SCStream.h:305
SCULong lastRead
Definition: SCStream.h:387
Абстрактный класс потоков библиотеки
Definition: SCStream.h:242
size_t SCSize
Definition: SCTypes.h:225
BOOL opened
Definition: SCStream.h:287