Overview
Comment: | Remove useless *Value from selector names |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b0b5eff39623c3b4e50c1033b52221b0 |
User & Date: | js on 2021-03-07 01:53:28 |
Other Links: | manifest | tags |
Context
2021-03-07
| ||
02:36 | Style change: Allow more than 1 argument per line check-in: a0fd103a0b user: js tags: trunk | |
01:53 | Remove useless *Value from selector names check-in: b0b5eff396 user: js tags: trunk | |
2021-02-28
| ||
23:42 | OFINICategory: Documentation fixes check-in: b5afddbea4 user: js tags: trunk | |
Changes
Modified src/OFINICategory.h from [30849cd33f] to [ce099ffcaa].
︙ | ︙ | |||
37 38 39 40 41 42 43 | * @brief The name of the INI category */ @property (copy, nonatomic) OFString *name; - (instancetype)init OF_UNAVAILABLE; /** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | < | | | | | | | < | | | | | < | | < | | < | | < | | < | | | | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | * @brief The name of the INI category */ @property (copy, nonatomic) OFString *name; - (instancetype)init OF_UNAVAILABLE; /** * @brief Returns the string for the specified key, or `nil` if it does not * exist. * * If the specified key is a multi-key (see @ref stringArrayForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the string should be returned * @return The string for the specified key, or `nil` if it does not exist */ - (nullable OFString *)stringForKey: (OFString *)key; /** * @brief Returns the string for the specified key or the specified default * value if it does not exist. * * If the specified key is a multi-key (see @ref stringArrayForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the string should be returned * @param defaultValue The value to return if the key does not exist * @return The string for the specified key or the specified default value if * it does not exist */ - (nullable OFString *)stringForKey: (OFString *)key defaultValue: (nullable OFString *)defaultValue; /** * @brief Returns the long long for the specified key or the specified default * value if it does not exist. * * If the specified key is a multi-key (see @ref stringArrayForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the long long should be returned * @param defaultValue The value to return if the key does not exist * @return The long long for the specified key or the specified default value * if it does not exist */ - (long long)longLongForKey: (OFString *)key defaultValue: (long long)defaultValue; /** * @brief Returns the bool for the specified key or the specified default value * if it does not exist. * * If the specified key is a multi-key (see @ref stringArrayForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the bool should be returned * @param defaultValue The value to return if the key does not exist * @return The bool for the specified key or the specified default value if it * does not exist */ - (bool)boolForKey: (OFString *)key defaultValue: (bool)defaultValue; /** * @brief Returns the float for the specified key or the specified default * value if it does not exist. * * If the specified key is a multi-key (see @ref stringArrayForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the float should be returned * @param defaultValue The value to return if the key does not exist * @return The float for the specified key or the specified default value if it * does not exist */ - (float)floatForKey: (OFString *)key defaultValue: (float)defaultValue; /** * @brief Returns the double for the specified key or the specified default * value if it does not exist. * * If the specified key is a multi-key (see @ref stringArrayForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the double should be returned * @param defaultValue The value to return if the key does not exist * @return The double for the specified key or the specified default value if * it does not exist */ - (double)doubleForKey: (OFString *)key defaultValue: (double)defaultValue; /** * @brief Returns an array of strings for the specified multi-key, or an empty * array if the key does not exist. * * A multi-key is a key which exists several times in the same category. Each * occurrence of the key/value pair adds the respective value to the array. * * @param key The multi-key for which the array should be returned * @return The array for the specified key, or an empty array if it does not * exist */ - (OFArray OF_GENERIC(OFString *) *)stringArrayForKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified string. * * If the specified key is a multi-key (see @ref stringValuesForKey:), the * value of the first key/value pair found is changed. * * @param string The string to which the key should be set * @param key The key for which the new value should be set */ - (void)setString: (OFString *)string forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified long long. * * If the specified key is a multi-key (see @ref stringValuesForKey:), the value * of the first key/value pair found is changed. * * @param longLong The long long to which the key should be set * @param key The key for which the new value should be set */ - (void)setLongLong: (long long)longLong forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified bool. * * If the specified key is a multi-key (see @ref stringValuesForKey:), the * value of the first key/value pair found is changed. * * @param bool_ The bool to which the key should be set * @param key The key for which the new value should be set */ - (void)setBool: (bool)bool_ forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified float. * * If the specified key is a multi-key (see @ref stringValuesForKey:), the * value of the first key/value pair found is changed. * * @param float_ The float to which the key should be set * @param key The key for which the new value should be set */ - (void)setFloat: (float)float_ forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified double. * * If the specified key is a multi-key (see @ref stringValuesForKey:), the value * of the first key/value pair found is changed. * * @param double_ The double to which the key should be set * @param key The key for which the new value should be set */ - (void)setDouble: (double)double_ forKey: (OFString *)key; /** * @brief Sets the specified multi-key to the specified array of strings. * * It replaces the first occurrence of the multi-key with several key/value * pairs and removes all following occurrences. If the multi-key does not exist * yet, it is appended to the section. * * See also @ref stringArrayForKey: for more information about multi-keys. * * @param array The array of strings to which the multi-key should be set * @param key The multi-key for which the new values should be set */ - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array forKey: (OFString *)key; /** * @brief Removes the value for the specified key * * If the specified key is a multi-key (see @ref stringValuesForKey:), all * key/value pairs matching the specified key are removed. * * @param key The key of the value to remove */ - (void)removeValueForKey: (OFString *)key; @end OF_ASSUME_NONNULL_END |
Modified src/OFINICategory.m from [49cee2e98a] to [504a2316bf].
︙ | ︙ | |||
48 49 50 51 52 53 54 | ![string hasPrefix: @"\f"] && ![string hasSuffix: @" "] && ![string hasSuffix: @"\t"] && ![string hasSuffix: @"\f"] && ![string containsString: @"\""]) return string; mutableString = [[string mutableCopy] autorelease]; | | < | < | < | < | < | < | < | < | < | < | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | ![string hasPrefix: @"\f"] && ![string hasSuffix: @" "] && ![string hasSuffix: @"\t"] && ![string hasSuffix: @"\f"] && ![string containsString: @"\""]) return string; mutableString = [[string mutableCopy] autorelease]; [mutableString replaceOccurrencesOfString: @"\\" withString: @"\\\\"]; [mutableString replaceOccurrencesOfString: @"\f" withString: @"\\f"]; [mutableString replaceOccurrencesOfString: @"\r" withString: @"\\r"]; [mutableString replaceOccurrencesOfString: @"\n" withString: @"\\n"]; [mutableString replaceOccurrencesOfString: @"\"" withString: @"\\\""]; [mutableString prependString: @"\""]; [mutableString appendString: @"\""]; [mutableString makeImmutable]; return mutableString; } static OFString * unescapeString(OFString *string) { OFMutableString *mutableString; if (![string hasPrefix: @"\""] || ![string hasSuffix: @"\""]) return string; string = [string substringWithRange: of_range(1, string.length - 2)]; mutableString = [[string mutableCopy] autorelease]; [mutableString replaceOccurrencesOfString: @"\\f" withString: @"\f"]; [mutableString replaceOccurrencesOfString: @"\\r" withString: @"\r"]; [mutableString replaceOccurrencesOfString: @"\\n" withString: @"\n"]; [mutableString replaceOccurrencesOfString: @"\\\"" withString: @"\""]; [mutableString replaceOccurrencesOfString: @"\\\\" withString: @"\\"]; [mutableString makeImmutable]; return mutableString; } @implementation OFINICategoryPair |
︙ | ︙ | |||
174 175 176 177 178 179 180 | comment->_comment = [line copy]; [_lines addObject: comment]; } } | | | < | | | | | < < | | < < | | < < | | < | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | comment->_comment = [line copy]; [_lines addObject: comment]; } } - (OFString *)stringForKey: (OFString *)key { return [self stringForKey: key defaultValue: nil]; } - (OFString *)stringForKey: (OFString *)key defaultValue: (OFString *)defaultValue { for (id line in _lines) { OFINICategoryPair *pair; if (![line isKindOfClass: [OFINICategoryPair class]]) continue; pair = line; if ([pair->_key isEqual: key]) return [[pair->_value copy] autorelease]; } return defaultValue; } - (long long)longLongForKey: (OFString *)key defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringForKey: key defaultValue: nil]; long long ret; if (value != nil) ret = [value longLongValueWithBase: 0]; else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (bool)boolForKey: (OFString *)key defaultValue: (bool)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringForKey: key defaultValue: nil]; bool ret; if (value != nil) { if ([value isEqual: @"true"]) ret = true; else if ([value isEqual: @"false"]) ret = false; else @throw [OFInvalidFormatException exception]; } else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (float)floatForKey: (OFString *)key defaultValue: (float)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringForKey: key defaultValue: nil]; float ret; if (value != nil) ret = value.floatValue; else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (double)doubleForKey: (OFString *)key defaultValue: (double)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringForKey: key defaultValue: nil]; double ret; if (value != nil) ret = value.doubleValue; else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (OFArray OF_GENERIC(OFString *) *)stringArrayForKey: (OFString *)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (id line in _lines) { OFINICategoryPair *pair; |
︙ | ︙ | |||
299 300 301 302 303 304 305 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return ret; } | < | | | < | | < | | > > > > | > | > | | > | | | | | < < < < < < < < < < < | | | | | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return ret; } - (void)setString: (OFString *)string forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); OFINICategoryPair *pair; for (id line in _lines) { if (![line isKindOfClass: [OFINICategoryPair class]]) continue; pair = line; if ([pair->_key isEqual: key]) { OFString *old = pair->_value; pair->_value = [string copy]; [old release]; objc_autoreleasePoolPop(pool); return; } } pair = [[[OFINICategoryPair alloc] init] autorelease]; pair->_key = nil; pair->_value = nil; @try { pair->_key = [key copy]; pair->_value = [string copy]; [_lines addObject: pair]; } @catch (id e) { [pair->_key release]; [pair->_value release]; @throw e; } objc_autoreleasePoolPop(pool); } - (void)setLongLong: (long long)longLong forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setString: [OFString stringWithFormat: @"%lld", longLong] forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setBool: (bool)bool_ forKey: (OFString *)key { [self setString: (bool_ ? @"true" : @"false") forKey: key]; } - (void)setFloat: (float)float_ forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setString: [OFString stringWithFormat: @"%g", float_] forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setDouble: (double)double_ forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setString: [OFString stringWithFormat: @"%g", double_] forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array forKey: (OFString *)key { void *pool; OFMutableArray *pairs; id const *lines; size_t count; bool replaced; if (array.count == 0) { [self removeValueForKey: key]; return; } pool = objc_autoreleasePoolPush(); pairs = [OFMutableArray arrayWithCapacity: array.count]; for (OFString *string in array) { OFINICategoryPair *pair; if (![string isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; pair = [[[OFINICategoryPair alloc] init] autorelease]; pair->_key = [key copy]; pair->_value = [string copy]; [pairs addObject: pair]; } lines = _lines.objects; count = _lines.count; replaced = false; |
︙ | ︙ | |||
433 434 435 436 437 438 439 | if (!replaced) { [_lines insertObjectsFromArray: pairs atIndex: i]; replaced = true; /* Continue after inserted pairs */ | | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | if (!replaced) { [_lines insertObjectsFromArray: pairs atIndex: i]; replaced = true; /* Continue after inserted pairs */ i += array.count - 1; } else i--; /* Continue at same position */ lines = _lines.objects; count = _lines.count; continue; |
︙ | ︙ |
Modified src/OFINIFile.h from [5f1fab4818] to [4e2773d0f5].
︙ | ︙ | |||
99 100 101 102 103 104 105 | /** * @brief Writes the contents of the OFINIFile to a file in the specified * encoding. * * @param path The path of the file to write to * @param encoding The encoding to use */ | | < | 99 100 101 102 103 104 105 106 107 108 109 | /** * @brief Writes the contents of the OFINIFile to a file in the specified * encoding. * * @param path The path of the file to write to * @param encoding The encoding to use */ - (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding; @end OF_ASSUME_NONNULL_END |
Modified src/OFINIFile.m from [c32d0fe539] to [4d99c8e035].
︙ | ︙ | |||
25 26 27 28 29 30 31 | #import "OFINICategory+Private.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" OF_DIRECT_MEMBERS @interface OFINIFile () | | < | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "OFINICategory+Private.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" OF_DIRECT_MEMBERS @interface OFINIFile () - (void)of_parseFile: (OFString *)path encoding: (of_string_encoding_t)encoding; @end static bool isWhitespaceLine(OFString *line) { const char *cString = line.UTF8String; size_t length = line.UTF8StringLength; |
︙ | ︙ | |||
62 63 64 65 66 67 68 | - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithPath: (OFString *)path { | | < | < | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithPath: (OFString *)path { return [self initWithPath: path encoding: OF_STRING_ENCODING_UTF_8]; } - (instancetype)initWithPath: (OFString *)path encoding: (of_string_encoding_t)encoding { self = [super init]; @try { _categories = [[OFMutableArray alloc] init]; [self of_parseFile: path encoding: encoding]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
108 109 110 111 112 113 114 | [_categories addObject: category]; objc_autoreleasePoolPop(pool); return category; } | | < | < | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | [_categories addObject: category]; objc_autoreleasePoolPop(pool); return category; } - (void)of_parseFile: (OFString *)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFFile *file; OFINICategory *category = nil; OFString *line; @try { file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { /* Handle missing file like an empty file */ if (e.errNo == ENOENT) return; @throw e; } |
︙ | ︙ | |||
156 157 158 159 160 161 162 | } objc_autoreleasePoolPop(pool); } - (void)writeToFile: (OFString *)path { | | < | < | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | } objc_autoreleasePoolPop(pool); } - (void)writeToFile: (OFString *)path { [self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8]; } - (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; bool first = true; for (OFINICategory *category in _categories) if ([category of_writeToStream: file encoding: encoding first: first]) first = false; objc_autoreleasePoolPop(pool); } @end |
Modified src/OFINIFileSettings.m from [d49cdb7650] to [a5f326cd7a].
︙ | ︙ | |||
65 66 67 68 69 70 71 | return; } *category = [path substringToIndex: pos]; *key = [path substringFromIndex: pos + 1]; } | < | | > | > > | > | > > > > | | < | | < < < | < < | | > | > > | > | > > > > | < | | | < < < | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < | < | | | | > | > | > > > > > > > > > > > | < | | < | | < < < | < | | < | | < < < | < | < < < < < < < < < < < < < < < < < < < < | | < < < | | < < < | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | return; } *category = [path substringToIndex: pos]; *key = [path substringFromIndex: pos + 1]; } - (void)setString: (OFString *)string forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setString: string forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setLongLong: (long long)longLong forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setLongLong: longLong forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setBool: (bool)bool_ forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setBool: bool_ forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setFloat: (float)float_ forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setFloat: float_ forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setDouble: (double)double_ forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setDouble: double_ forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setStringArray: array forKey: key]; objc_autoreleasePoolPop(pool); } - (OFString *)stringForPath: (OFString *)path defaultValue: (OFString *)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key, *ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] stringForKey: key defaultValue: defaultValue]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (long long)longLongForPath: (OFString *)path defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; long long ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] longLongForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; bool ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] boolForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; float ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] floatForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; double ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] doubleForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; OFArray *ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] stringArrayForKey: key]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (void)removeValueForPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] removeValueForKey: key]; objc_autoreleasePoolPop(pool); } - (void)save { [_INIFile writeToFile: _filePath]; } @end |
Modified src/OFSettings.h from [8b2581256c] to [10aa8b7158].
︙ | ︙ | |||
63 64 65 66 67 68 69 | * accessed * @return An initialized OFSettings instance */ - (instancetype)initWithApplicationName: (OFString *)applicationName OF_DESIGNATED_INITIALIZER; /** | | | | < | | | | < | | | | < | | | | < | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | < | | | | | < | | | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | * accessed * @return An initialized OFSettings instance */ - (instancetype)initWithApplicationName: (OFString *)applicationName OF_DESIGNATED_INITIALIZER; /** * @brief Sets the specified path to the specified string. * * @param string The string to set * @param path The path to store the string at */ - (void)setString: (OFString *)string forPath: (OFString *)path; /** * @brief Sets the specified path to the specified long long. * * @param longLong The long long to set * @param path The path to store the long long at */ - (void)setLongLong: (long long)longLong forPath: (OFString *)path; /** * @brief Sets the specified path to the specified bool. * * @param bool_ The bool to set * @param path The path to store the bool at */ - (void)setBool: (bool)bool_ forPath: (OFString *)path; /** * @brief Sets the specified path to the specified float. * * @param float_ The float to set * @param path The path to store the float at */ - (void)setFloat: (float)float_ forPath: (OFString *)path; /** * @brief Sets the specified path to the specified double. * * @param double_ The double to set * @param path The path to store the double at */ - (void)setDouble: (double)double_ forPath: (OFString *)path; /** * @brief Sets the specified path to the specified array of strings. * * @param array The array of strings to set * @param path The path to store the array of string at */ - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array forPath: (OFString *)path; /** * @brief Returns the string for the specified path, or `nil` if the path does * not exist. * * @param path The path for which the string should be returned * @return The string of the specified path */ - (nullable OFString *)stringForPath: (OFString *)path; /** * @brief Returns the string for the specified path, or the default value if * the path does not exist. * * @param path The path for which the string should be returned * @param defaultValue The default value to return if the path does not exist * @return The string of the specified path */ - (nullable OFString *)stringForPath: (OFString *)path defaultValue: (nullable OFString *)defaultValue; /** * @brief Returns the long long for the specified path, or the default value if * the path does not exist. * * @param path The path for which the long long should be returned * @param defaultValue The default value to return if the path does not exist * @return The long long of the specified path */ - (long long)longLongForPath: (OFString *)path defaultValue: (long long)defaultValue; /** * @brief Returns the bool for the specified path, or the default value if the * path does not exist. * * @param path The path for which the bool should be returned * @param defaultValue The default value to return if the path does not exist * @return The bool of the specified path */ - (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue; /** * @brief Returns the float for the specified path, or the default value if the * path does not exist. * * @param path The path for which the float should be returned * @param defaultValue The default value to return if the path does not exist * @return The float of the specified path */ - (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue; /** * @brief Returns the double for the specified path, or the default value if * the path does not exist. * * @param path The path for which the double should be returned * @param defaultValue The default value to return if the path does not exist * @return The double of the specified path */ - (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue; /** * @brief Returns the array of strings for the specified path, or an empty * array if the path does not exist. * * @param path The path for which the array of strings should be returned * @return The array of string values of the specified path */ - (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path; /** * @brief Removes the value for the specified path. * * @param path The path for which the value should be removed */ - (void)removeValueForPath: (OFString *)path; |
︙ | ︙ |
Modified src/OFSettings.m from [48a4a9191f] to [8b3ec674cd].
︙ | ︙ | |||
58 59 60 61 62 63 64 | - (void)dealloc { [_applicationName release]; [super dealloc]; } | < | < | < | < | < | | | | | < | | | | < | < | < | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | - (void)dealloc { [_applicationName release]; [super dealloc]; } - (void)setString: (OFString *)string forPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)setLongLong: (long long)longLong forPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)setBool: (bool)bool_ forPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)setFloat: (float)float_ forPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)setDouble: (double)double_ forPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array forPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (OFString *)stringForPath: (OFString *)path { return [self stringForPath: path defaultValue: nil]; } - (OFString *)stringForPath: (OFString *)path defaultValue: (OFString *)defaultValue { OF_UNRECOGNIZED_SELECTOR } - (long long)longLongForPath: (OFString *)path defaultValue: (long long)defaultValue { OF_UNRECOGNIZED_SELECTOR } - (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue { OF_UNRECOGNIZED_SELECTOR } - (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue { OF_UNRECOGNIZED_SELECTOR } - (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue { OF_UNRECOGNIZED_SELECTOR } - (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)removeValueForPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR |
︙ | ︙ |
Modified tests/OFINIFileTests.m from [fab3932383] to [ad2cd47828].
︙ | ︙ | |||
58 59 60 61 62 63 64 | foobar = [file categoryForName: @"foobar"]; types = [file categoryForName: @"types"]; TEST(@"-[categoryForName:]", tests != nil && foobar != nil && types != nil) module = @"OFINICategory"; | | | | | | < | < | < | < | | | < | < | | < | < | | | | < | | | | | | | | | < | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | foobar = [file categoryForName: @"foobar"]; types = [file categoryForName: @"types"]; TEST(@"-[categoryForName:]", tests != nil && foobar != nil && types != nil) module = @"OFINICategory"; TEST(@"-[stringForKey:]", [[tests stringForKey: @"foo"] isEqual: @"bar"] && [[foobar stringForKey: @"quxquxqux"] isEqual: @"hello\"wörld"]) TEST(@"-[setString:forKey:]", R([tests setString: @"baz" forKey: @"foo"]) && R([tests setString: @"new" forKey: @"new"]) && R([foobar setString: @"a\fb" forKey: @"qux3"])) TEST(@"-[longLongForKey:defaultValue:]", [types longLongForKey: @"integer" defaultValue: 2] == 0x20) TEST(@"-[setLongLong:forKey:]", R([types setLongLong: 0x10 forKey: @"integer"])) TEST(@"-[boolForKey:defaultValue:]", [types boolForKey: @"bool" defaultValue: false] == true) TEST(@"-[setBool:forKey:]", R([types setBool: false forKey: @"bool"])) TEST(@"-[floatForKey:defaultValue:]", [types floatForKey: @"float" defaultValue: 1] == 0.5f) TEST(@"-[setFloat:forKey:]", R([types setFloat: 0.25f forKey: @"float"])) TEST(@"-[doubleForKey:defaultValue:]", [types doubleForKey: @"double" defaultValue: 3] == 0.25) TEST(@"-[setDouble:forKey:]", R([types setDouble: 0.75 forKey: @"double"])) array = [OFArray arrayWithObjects: @"1", @"2", nil]; TEST(@"-[stringArrayForKey:]", [[types stringArrayForKey: @"array1"] isEqual: array] && [[types stringArrayForKey: @"array2"] isEqual: array] && [[types stringArrayForKey: @"array3"] isEqual: [OFArray array]]) array = [OFArray arrayWithObjects: @"foo", @"bar", nil]; TEST(@"-[setStringArray:forKey:]", R([types setStringArray: array forKey: @"array1"])) TEST(@"-[removeValueForKey:]", R([foobar removeValueForKey: @"quxqux "]) && R([types removeValueForKey: @"array2"])) module = @"OFINIFile"; |
︙ | ︙ |