|
Samond Classes Library 1.1.6-RELEASE build 132
|
00001 // 00002 // SCConfigRecord.h 00003 // sclmac 00004 // 00005 // Created by Viacheslav Smolensky on 06.06.14. 00006 // Copyright (c) 2007 - 2014 by Samond Development Corporation. All rights reserved. 00007 // 00008 00016 #import <scl/SCServiceObject.h> 00017 #import <scl/SCTypes.h> 00018 #import <scl/SCStrings.h> 00019 00020 #define SCConfigRecordClass @"SCConfigRecord" ///< SCConfigRecord class name 00021 00022 #pragma mark - 00023 #pragma mark Configuration record type support types 00024 00030 enum _SCConfigRecordType { 00031 SCConfigRecordGeneric = 0, 00032 SCConfigRecordString = 1, 00033 SCConfigRecordNumber = 2, 00034 SCConfigRecordBool = 3, 00035 SCConfigRecordDate = 4, 00036 SCConfigRecordConfig = 11, 00037 }; 00038 00045 typedef enum _SCConfigRecordType SCConfigRecordType; 00046 00047 @class SCConfig; 00048 00049 #pragma mark - 00050 00067 @interface SCConfigRecord : SCServiceObject { 00068 NSString *fKey; // Record key 00069 id fValue; // Record value 00070 SCConfigRecordType fType; // Record type 00071 SCStrings *fComments; // Record comments 00072 } 00073 #pragma mark - 00074 #pragma mark Class properties 00075 #if (__MAC_OS_X_VERSION_MIN_REQUIRED > 1040) || IOS_TARGET 00076 00077 // Record key property 00078 @property (retain, getter=key, setter=setKey:) NSString *key; 00079 // Record value property 00080 @property (retain, getter=value, setter=setValue:) id value; 00081 // Record type property 00082 @property (assign, getter=type, setter=setType:) SCConfigRecordType type; 00083 // String record value 00084 @property (retain, getter=stringValue, setter=setStringValue:) NSString *stringValue; 00085 // Number record value 00086 @property (retain, getter=numberValue, setter=setNumberValue:) NSNumber *numberValue; 00087 // Boolean record value 00088 @property (assign, getter=boolValue, setter=setBoolValue:) BOOL boolValue; 00089 // Date and time record value 00090 @property (retain, getter=dateValue, setter=setDateValue:) NSDate *dateValue; 00091 // Config record value property 00092 @property (retain, getter=configValue, setter=setConfigValue:) SCConfig *configValue; 00093 // Record comments property 00094 @property (retain, getter=comments, setter=setComments:) SCStrings *comments; 00095 00096 #endif 00097 00098 #pragma mark - 00099 #pragma mark Creating and Initializing Configuration Record 00100 00106 + (SCConfigRecord *)recordWithDataDictionary:(NSDictionary *)dictionary; 00107 00113 + (SCConfigRecord *)recordWithDataDictionaryFromFile:(NSString *)path; 00114 00120 + (SCConfigRecord *)recordWithCoder:(NSCoder *)coder; 00121 00128 + (SCConfigRecord *)recordWithContentsOfSerializedFile:(NSString *)path; 00129 00137 + (SCConfigRecord *)recordWithStream:(SCStream *)stream; 00138 00146 + (SCConfigRecord *)recordWithFileStream:(NSString *)path; 00147 00155 + (SCConfigRecord *)recordWithKey:(NSString *)key value:(id)value type:(SCConfigRecordType)type; 00156 00163 + (SCConfigRecord *)recordWithKey:(NSString *)key value:(id)value; 00164 00170 + (SCConfigRecord *)recordWithRecord:(SCConfigRecord *)record; 00171 00177 + (SCConfigRecord *)recordWithString:(NSString *)string; 00178 00183 + (SCConfigRecord *)record; 00184 00191 + (SCConfigRecord *)recordWithKey:(NSString *)key stringValue:(NSString *)stringValue; 00192 00199 + (SCConfigRecord *)recordWithKey:(NSString *)key numberValue:(NSNumber *)numberValue; 00200 00207 + (SCConfigRecord *)recordWithKey:(NSString *)key boolValue:(BOOL)boolValue; 00208 00215 + (SCConfigRecord *)recordWithKey:(NSString *)key dateValue:(NSDate *)dateValue; 00216 00223 + (SCConfigRecord *)recordWithKey:(NSString *)key configValue:(SCConfig *)configValue; 00224 00232 - (id)initWithKey:(NSString *)key value:(id)value type:(SCConfigRecordType)type; 00233 00240 - (id)initWithKey:(NSString *)key value:(id)value; 00241 00247 - (id)initWithRecord:(SCConfigRecord *)record; 00248 00254 - (id)initWithString:(NSString *)string; 00255 00260 - (id)init; 00261 00268 - (id)initWithKey:(NSString *)key stringValue:(NSString *)stringValue; 00269 00276 - (id)initWithKey:(NSString *)key numberValue:(NSNumber *)numberValue; 00277 00284 - (id)initWithKey:(NSString *)key boolValue:(BOOL)boolValue; 00285 00292 - (id)initWithKey:(NSString *)key dateValue:(NSDate *)dateValue; 00293 00300 - (id)initWithKey:(NSString *)key configValue:(SCConfig *)configValue; 00301 00302 #pragma mark - 00303 #pragma mark Setting and Copying Configuration Records 00304 00310 - (void)setWithRecord:(SCConfigRecord *)record; 00311 00317 - (void)setWithString:(NSString *)string; 00318 00319 #pragma mark - 00320 #pragma mark Getting and Setting Configuration Record Properties 00321 00326 - (NSString *)key; 00327 00332 - (id)value; 00333 00339 - (NSString *)stringValue; 00340 00346 - (NSNumber *)numberValue; 00347 00353 - (BOOL)boolValue; 00354 00360 - (NSDate *)dateValue; 00361 00367 - (SCConfig *)configValue; 00368 00373 - (SCConfigRecordType)type; 00374 00379 - (SCStrings *)comments; 00380 00385 - (NSString *)description; 00386 00391 - (void)setKey:(NSString *)key; 00392 00397 - (void)setValue:(id)value; 00398 00403 - (void)setStringValue:(NSString *)stringValue; 00404 00409 - (void)setNumberValue:(NSNumber *)numberValue; 00410 00415 - (void)setBoolValue:(BOOL)boolValue; 00416 00421 - (void)setDateValue:(NSDate *)dateValue; 00422 00427 - (void)setConfigValue:(SCConfig *)configValue; 00428 00433 - (void)setType:(SCConfigRecordType)type; 00434 00439 - (void)setComments:(SCStrings *)comments; 00440 00445 - (BOOL)isStringRecord; 00446 00451 - (BOOL)isNumberRecord; 00452 00457 - (BOOL)isBoolRecord; 00458 00463 - (BOOL)isDateRecord; 00464 00469 - (BOOL)isConfigRecord; 00470 00475 - (BOOL)isEmpty; 00476 00481 - (BOOL)isKeyEmpty; 00482 00487 - (BOOL)isValueEmpty; 00488 00489 #pragma mark - 00490 #pragma mark Comparing Configuration Records 00491 00500 - (BOOL)isEqualToRecord:(SCConfigRecord *)record caseInsenstivie:(BOOL)caseInsensitive; 00501 00509 - (BOOL)isEqualToRecord:(SCConfigRecord *)record; 00510 00517 - (BOOL)isEqual:(id)object; 00518 00527 - (BOOL)isEqualToString:(NSString *)string caseInsensitive:(BOOL)caseInsensitive; 00528 00536 - (BOOL)isEqualToString:(NSString *)string; 00537 00545 - (BOOL)isEqualToKey:(NSString *)key caseInsensitive:(BOOL)caseInsensitive; 00546 00553 - (BOOL)isEqualToKey:(NSString *)key; 00554 00555 #pragma mark - 00556 #pragma mark Record comments controls 00557 00562 - (void)addComment:(NSString *)comment; 00563 00568 - (void)addComments:(SCStrings *)comments; 00569 00574 - (void)setComment:(NSString *)comment; 00575 00580 - (void)removeComment:(NSString *)comment; 00581 00585 - (void)removeComments; 00586 00592 - (void)replaceComment:(NSString *)comment withComment:(NSString *)newComment; 00593 00599 - (BOOL)haveComments; 00600 00601 #pragma mark - 00602 #pragma mark Getting record type names 00603 00609 + (NSString *)nameWithType:(SCConfigRecordType)type; 00610 00611 @end
1.7.3