Samond Classes Library 1.1.6-RELEASE build 132

SCStream.h

Go to the documentation of this file.
00001 //
00002 //  SCStream.h
00003 //  scl
00004 //
00005 //  Created by Viacheslav Smolensky on 02.03.12.
00006 //  Copyright (c) 2007 - 2014 by Samond Development Corporation. All rights reserved.
00007 //
00008 
00016 #import <Foundation/Foundation.h>
00017 #import <scl/SCTypes.h>
00018 #import <scl/SCObject.h>
00019 #import <scl/SCStreamProtocol.h>
00020 #import <scl/SCSystemException.h>
00021 #import <scl/SCStreamException.h>
00022 
00023 #define SCStreamClass @"SCStream" ///< SCStream class name
00024 
00025 @protocol SCStreamDelegate;
00026 
00027 #pragma mark -
00028 #pragma mark Streams supporting constants
00029 
00031 #define SC_STREAM_MAX_STRING_LENGTH     4096    ///< String maximum length
00032 
00033 #pragma mark -
00034 #pragma mark Streams supporing types
00035 
00041 enum _SCStreamErrorHandling {
00042         SCStreamErrorHandlingSystem     = 1,    
00043         SCStreamErrorHandlingStream     = 2,    
00044         SCStreamErrorHandlingStatus = 3         
00045 };
00046 
00052 typedef enum _SCStreamErrorHandling SCStreamErrorHandling;
00053 
00058 enum _SCStreamStatus {
00059         SCStreamOK                      = 0,    
00060     SCStreamUnexpectedClassError    = 1,    
00061     SCStreamIncompleteReadError     = 2,    
00062     SCStreamIncompleteWriteError    = 3,    
00063     SCStreamOpenError               = 4,    
00064     SCStreamNotOpenError            = 5,    
00065     SCStreamReadOnlyError           = 6,    
00066     SCStreamWriteOnlyError          = 7,    
00067     SCStreamReadError               = 8,    
00068     SCStreamWriteError              = 9,    
00069         SCStreamUnknownClassError               = 11,   
00070         SCStreamUnsupportedClass        = 12,   
00071 };
00072 
00078 typedef SCUInteger SCStreamStatus;
00079 
00080 #pragma mark -
00081 
00106 @interface SCStream : SCObject {
00107         SCStreamErrorHandling   fErrorHandling;         // Error handling mode
00108         SCStreamStatus                  fStatus;                        // Stream status
00109         NSString                            *fStreamName;               // Stream name
00110         BOOL                                    fOpenFlag;                      // Stream opening flag
00111     SCStreamException      *fStreamException;   // Last detected stream exception
00112     SCSystemException      *fSystemException;   // Last detected system exception
00113     id<SCStreamDelegate>        fDelegate;                      // Stream events delegate object
00114         id                                              fObject;                        // Currently loaded object
00115 }
00116 #pragma mark -
00117 #pragma mark Class properties
00118 #if (__MAC_OS_X_VERSION_MIN_REQUIRED > 1040) || IOS_TARGET
00119 
00120 // Error handling mode type
00121 @property (nonatomic, assign, getter=errorHandling, setter=setErrorHandling:)
00122         SCStreamErrorHandling errorHandling;
00123 // Status property
00124 @property (nonatomic, assign, readonly, getter=status) SCStreamStatus status;
00125 // Stream name property
00126 @property (nonatomic, retain, readonly, getter=streamName) NSString *streamName;
00127 // Stream opening flag property
00128 @property (nonatomic, assign, readonly, getter=isOpen) BOOL isOpen;
00129 // Last detected stream exception property
00130 @property (nonatomic, assign, readonly, getter=streamException) SCStreamException *streamException;
00131 // Last detected system exception property
00132 @property (nonatomic, assign, readonly, getter=systemException) SCSystemException *systemException;
00133 // Stream is readable property
00134 @property (nonatomic, assign, readonly, getter=isReadable) BOOL isReadable;
00135 // Stream is writable property
00136 @property (nonatomic, assign, readonly, getter=isWritable) BOOL isWritable;
00137 // Stream is read only property
00138 @property (nonatomic, assign, readonly, getter=isReadOnly) BOOL isReadOnly;
00139 // Stream is write only property
00140 @property (nonatomic, assign, readonly, getter=isWriteOnly) BOOL isWriteOnly;
00141 // Stream is read and write property
00142 @property (nonatomic, assign, readonly, getter=isReadWrite) BOOL isReadWrite;
00143 // Stream events delegate object property
00144 @property (assign, getter=delegate, setter=setDelegate:) id<SCStreamDelegate> delegate;
00145 // Currently loaded object property
00146 @property (retain, readonly, getter=object) id object;
00147 
00148 #endif
00149 
00150 #pragma mark -
00151 #pragma mark Initializing Stream
00152 
00157 - (id)init;
00158 
00159 #pragma mark -
00160 #pragma mark Handling Errors
00161 
00166 - (SCStreamErrorHandling)errorHandling;
00167 
00172 - (SCStreamStatus)status;
00173 
00178 - (SCStreamException *)streamException;
00179 
00184 - (SCSystemException *)systemException;
00185 
00190 - (void)setErrorHandling:(SCStreamErrorHandling)mode;
00191 
00192 #pragma mark -
00193 #pragma mark Querying and Setting Exception Properties
00194 
00199 - (NSString *)streamName;
00200 
00205 - (BOOL)isOpen;
00206 
00212 - (BOOL)isReadable;
00213 
00219 - (BOOL)isWritable;
00220 
00225 - (BOOL)isReadOnly;
00226 
00231 - (BOOL)isWriteOnly;
00232 
00237 - (BOOL)isReadWrite;
00238 
00243 - (id<SCStreamDelegate>)delegate;
00244 
00249 - (void)setDelegate:(id<SCStreamDelegate>)delegate;
00250 
00255 - (id)object;
00256 
00257 #pragma mark -
00258 #pragma mark Reading from Stream
00259 
00269 - (SCUSize)readBytes:(SCUSize)count toBuffer:(void *)buffer;
00270 
00277 - (id<SCStreamProtocol>)readObject;
00278 
00285 - (SCByte)readByte;
00286 
00293 - (SCUByte)readUByte;
00294 
00301 - (SCShort)readShort;
00302 
00309 - (SCUShort)readUShort;
00310 
00317 - (SCInteger)readInteger;
00318 
00325 - (SCUInteger)readUInteger;
00326 
00333 - (SCLong)readLong;
00334 
00341 - (SCULong)readULong;
00342 
00349 - (char)readChar;
00350 
00357 - (unichar)readUnichar;
00358 
00365 - (const char *)readCharString;
00366 
00373 - (BOOL)readBool;
00374 
00381 - (SCFloat)readFloat;
00382 
00389 - (SCDouble)readDouble;
00390 
00398 - (SCUSize)readToByte:(SCByte *)buffer;
00399 
00407 - (SCUSize)readToUByte:(SCUByte *)buffer;
00408 
00416 - (SCUSize)readToShort:(SCShort *)buffer;
00417 
00425 - (SCUSize)readToUShort:(SCUShort *)buffer;
00426 
00434 - (SCUSize)readToInteger:(SCInteger *)buffer;
00435 
00443 - (SCUSize)readToUInteger:(SCUInteger *)buffer;
00444 
00452 - (SCUSize)readToLong:(SCULong *)buffer;
00453 
00461 - (SCUSize)readToULong:(SCULong *)buffer;
00462 
00470 - (SCUSize)readToChar:(char *)buffer;
00471 
00479 - (SCUSize)readToUnichar:(unichar *)buffer;
00480 
00489 - (SCUSize)readToCharString:(char *)buffer max:(SCUSize)max;
00490 
00498 - (SCUSize)readToBool:(BOOL *)buffer;
00499 
00507 - (SCUSize)readToFloat:(SCFloat *)buffer;
00508 
00516 - (SCUSize)readToDouble:(SCDouble *)buffer;
00517 
00518 #pragma mark -
00519 #pragma mark Writing into Stream
00520 
00530 - (SCUSize)writeBytes:(SCUSize)count fromBuffer:(const void *)buffer;
00531 
00538 - (void)writeObject:(id<SCStreamProtocol>)object;
00539 
00546 - (void)writeByte:(SCByte)variable;
00547 
00554 - (void)writeUByte:(SCUByte)variable;
00555 
00562 - (void)writeShort:(SCShort)variable;
00563 
00570 - (void)writeUShort:(SCUShort)variable;
00571 
00578 - (void)writeInteger:(SCInteger)variable;
00579 
00586 - (void)writeUInteger:(SCUInteger)variable;
00587 
00594 - (void)writeLong:(SCLong)variable;
00595 
00602 - (void)writeULong:(SCULong)variable;
00603 
00610 - (void)writeChar:(char)variable;
00611 
00618 - (void)writeUnichar:(unichar)variable;
00619 
00626 - (void)writeCharString:(const char *)variable;
00627 
00634 - (void)writeBool:(BOOL)variable;
00635 
00642 - (void)writeFloat:(SCFloat)variable;
00643 
00650 - (void)writeDouble:(SCDouble)variable;
00651 
00652 #pragma mark -
00653 #pragma mark Reading and Writing Text Files
00654 
00663 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding max:(SCUInteger)max;
00664 
00672 - (NSString *)readStringWithEncoding:(NSStringEncoding)encoding;
00673 
00681 - (NSString *)readStringWithMax:(SCUInteger)max;
00682 
00689 - (NSString *)readString;
00690 
00698 - (void)writeString:(NSString *)string encoding:(NSStringEncoding)encoding;
00699 
00706 - (void)writeString:(NSString *)string;
00707 
00708 #pragma mark -
00709 #pragma mark Seeking Stream
00710 
00715 - (BOOL)eof;
00716 
00717 @end
 All Classes Files Functions Typedefs Enumerations Enumerator Defines