Index: src/OFINICategory.h ================================================================== --- src/OFINICategory.h +++ src/OFINICategory.h @@ -48,11 +48,11 @@ * the first key/value pair found is returned. * * @param key The key for which the string value should be returned * @return The string value for the specified key, or `nil` if it does not exist */ -- (nullable OFString *)stringForKey: (OFString *)key; +- (nullable OFString *)stringValueForKey: (OFString *)key; /** * @brief Returns the string value for the specified key or the specified * default value if it does not exist. * @@ -62,27 +62,27 @@ * @param key The key for which the string value should be returned * @param defaultValue The value to return if the key does not exist * @return The string value for the specified key or the specified default * value if it does not exist */ -- (nullable OFString *)stringForKey: (OFString *)key - defaultValue: (nullable OFString *)defaultValue; +- (nullable OFString *)stringValueForKey: (OFString *)key + defaultValue: (nullable OFString *)defaultValue; /** - * @brief Returns the integer value for the specified key or the specified + * @brief Returns the long long value for the specified key or the specified * default value if it does not exist. * * If the specified key is a multi-key (see @ref arrayForKey:), the value of * the first key/value pair found is returned. * - * @param key The key for which the integer value should be returned + * @param key The key for which the long long value should be returned * @param defaultValue The value to return if the key does not exist - * @return The integer value for the specified key or the specified default + * @return The long long value for the specified key or the specified default * value if it does not exist */ -- (long long)integerForKey: (OFString *)key - defaultValue: (long long)defaultValue; +- (long long)longLongValueForKey: (OFString *)key + defaultValue: (long long)defaultValue; /** * @brief Returns the bool value for the specified key or the specified default * value if it does not exist. * @@ -92,12 +92,12 @@ * @param key The key for which the bool value should be returned * @param defaultValue The value to return if the key does not exist * @return The bool value for the specified key or the specified default value * if it does not exist */ -- (bool)boolForKey: (OFString *)key - defaultValue: (bool)defaultValue; +- (bool)boolValueForKey: (OFString *)key + defaultValue: (bool)defaultValue; /** * @brief Returns the float value for the specified key or the specified * default value if it does not exist. * @@ -107,12 +107,12 @@ * @param key The key for which the float value should be returned * @param defaultValue The value to return if the key does not exist * @return The float value for the specified key or the specified default value * if it does not exist */ -- (float)floatForKey: (OFString *)key - defaultValue: (float)defaultValue; +- (float)floatValueForKey: (OFString *)key + defaultValue: (float)defaultValue; /** * @brief Returns the double value for the specified key or the specified * default value if it does not exist. * @@ -122,12 +122,12 @@ * @param key The key for which the double value should be returned * @param defaultValue The value to return if the key does not exist * @return The double value for the specified key or the specified default * value if it does not exist */ -- (double)doubleForKey: (OFString *)key - defaultValue: (double)defaultValue; +- (double)doubleValueForKey: (OFString *)key + defaultValue: (double)defaultValue; /** * @brief Returns an array of string values for the specified multi-key, or an * empty array if the key does not exist. * @@ -136,86 +136,86 @@ * * @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 *) *)arrayForKey: (OFString *)key; +- (OFArray OF_GENERIC(OFString *) *)stringValuesForKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified string. * * If the specified key is a multi-key (see @ref arrayForKey:), the value of * the first key/value pair found is changed. * - * @param string The string to which the value of the key should be set + * @param stringValue The string value 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; +- (void)setStringValue: (OFString *)stringValue + forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified integer. * * If the specified key is a multi-key (see @ref arrayForKey:), the value of * the first key/value pair found is changed. * - * @param integer The integer to which the value of the key should be set + * @param longLongValue The long long value to which the key should be set * @param key The key for which the new value should be set */ -- (void)setInteger: (long long)integer - forKey: (OFString *)key; +- (void)setLongLongValue: (long long)longLongValue + 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 arrayForKey:), the value of - * the first key/value pair found is changed. + * 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 value of the key should be set + * @param boolValue The bool value 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; +- (void)setBoolValue: (bool)boolValue + 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 arrayForKey:), the value of - * the first key/value pair found is changed. + * 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 value of the key should be set + * @param floatValue The float value 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; +- (void)setFloatValue: (float)floatValue + 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 arrayForKey:), the value of - * the first key/value pair found is changed. + * 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 value of the key should be set + * @param doubleValue The double value 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; +- (void)setDoubleValue: (double)doubleValue + 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 arrayForKey: for more information about multi-keys. + * See also @ref stringValuesForKey: for more information about multi-keys. * - * @param array The array of strings to which the multi-key should be set + * @param stringValues 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)setArray: (OFArray OF_GENERIC(OFString *) *)array - forKey: (OFString *)key; +- (void)setStringValues: (OFArray OF_GENERIC(OFString *) *)stringValues + forKey: (OFString *)key; /** * @brief Removes the value for the specified key * * If the specified key is a multi-key (see @ref arrayForKey:), all key/value Index: src/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -176,18 +176,18 @@ [_lines addObject: comment]; } } -- (OFString *)stringForKey: (OFString *)key +- (OFString *)stringValueForKey: (OFString *)key { - return [self stringForKey: key - defaultValue: nil]; + return [self stringValueForKey: key + defaultValue: nil]; } -- (OFString *)stringForKey: (OFString *)key - defaultValue: (OFString *)defaultValue +- (OFString *)stringValueForKey: (OFString *)key + defaultValue: (OFString *)defaultValue { for (id line in _lines) { OFINICategoryPair *pair; if (![line isKindOfClass: [OFINICategoryPair class]]) @@ -200,16 +200,16 @@ } return defaultValue; } -- (long long)integerForKey: (OFString *)key - defaultValue: (long long)defaultValue +- (long long)longLongValueForKey: (OFString *)key + defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringValueForKey: key + defaultValue: nil]; long long ret; if (value != nil) ret = [value longLongValueWithBase: 0]; else @@ -218,16 +218,16 @@ objc_autoreleasePoolPop(pool); return ret; } -- (bool)boolForKey: (OFString *)key - defaultValue: (bool)defaultValue +- (bool)boolValueForKey: (OFString *)key + defaultValue: (bool)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringValueForKey: key + defaultValue: nil]; bool ret; if (value != nil) { if ([value isEqual: @"true"]) ret = true; @@ -241,16 +241,16 @@ objc_autoreleasePoolPop(pool); return ret; } -- (float)floatForKey: (OFString *)key - defaultValue: (float)defaultValue +- (float)floatValueForKey: (OFString *)key + defaultValue: (float)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringValueForKey: key + defaultValue: nil]; float ret; if (value != nil) ret = value.floatValue; else @@ -259,16 +259,16 @@ objc_autoreleasePoolPop(pool); return ret; } -- (double)doubleForKey: (OFString *)key - defaultValue: (double)defaultValue +- (double)doubleValueForKey: (OFString *)key + defaultValue: (double)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringValueForKey: key + defaultValue: nil]; double ret; if (value != nil) ret = value.doubleValue; else @@ -277,11 +277,11 @@ objc_autoreleasePoolPop(pool); return ret; } -- (OFArray *)arrayForKey: (OFString *)key +- (OFArray OF_GENERIC(OFString *) *)stringValuesForKey: (OFString *)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (id line in _lines) { @@ -301,12 +301,12 @@ [ret makeImmutable]; return ret; } -- (void)setString: (OFString *)string - forKey: (OFString *)key +- (void)setStringValue: (OFString *)stringValue + forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); OFINICategoryPair *pair; for (id line in _lines) { @@ -315,11 +315,11 @@ pair = line; if ([pair->_key isEqual: key]) { OFString *old = pair->_value; - pair->_value = [string copy]; + pair->_value = [stringValue copy]; [old release]; objc_autoreleasePoolPop(pool); return; @@ -330,11 +330,11 @@ pair->_key = nil; pair->_value = nil; @try { pair->_key = [key copy]; - pair->_value = [string copy]; + pair->_value = [stringValue copy]; [_lines addObject: pair]; } @catch (id e) { [pair->_key release]; [pair->_value release]; @@ -342,77 +342,78 @@ } objc_autoreleasePoolPop(pool); } -- (void)setInteger: (long long)integer - forKey: (OFString *)key -{ - void *pool = objc_autoreleasePoolPush(); - - [self setString: [OFString stringWithFormat: @"%lld", integer] - 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)setArray: (OFArray *)array - forKey: (OFString *)key +- (void)setLongLongValue: (long long)longLongValue + forKey: (OFString *)key +{ + void *pool = objc_autoreleasePoolPush(); + + [self setStringValue: [OFString stringWithFormat: @"%lld", + longLongValue] + forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setBoolValue: (bool)boolValue + forKey: (OFString *)key +{ + [self setStringValue: (boolValue ? @"true" : @"false") + forKey: key]; +} + +- (void)setFloatValue: (float)floatValue + forKey: (OFString *)key +{ + void *pool = objc_autoreleasePoolPush(); + + [self setStringValue: [OFString stringWithFormat: @"%g", floatValue] + forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setDoubleValue: (double)doubleValue + forKey: (OFString *)key +{ + void *pool = objc_autoreleasePoolPush(); + + [self setStringValue: [OFString stringWithFormat: @"%g", doubleValue] + forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setStringValues: (OFArray OF_GENERIC(OFString *) *)stringValues + forKey: (OFString *)key { void *pool; OFMutableArray *pairs; id const *lines; size_t count; bool replaced; - if (array.count == 0) { + if (stringValues.count == 0) { [self removeValueForKey: key]; return; } pool = objc_autoreleasePoolPush(); - pairs = [OFMutableArray arrayWithCapacity: array.count]; + pairs = [OFMutableArray arrayWithCapacity: stringValues.count]; - for (id object in array) { + for (OFString *stringValue in stringValues) { OFINICategoryPair *pair; - if (![object isKindOfClass: [OFString class]]) + if (![stringValue isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; pair = [[[OFINICategoryPair alloc] init] autorelease]; pair->_key = [key copy]; - pair->_value = [object copy]; + pair->_value = [stringValue copy]; [pairs addObject: pair]; } lines = _lines.objects; @@ -434,11 +435,11 @@ [_lines insertObjectsFromArray: pairs atIndex: i]; replaced = true; /* Continue after inserted pairs */ - i += array.count - 1; + i += stringValues.count - 1; } else i--; /* Continue at same position */ lines = _lines.objects; count = _lines.count; Index: src/OFINIFileSettings.m ================================================================== --- src/OFINIFileSettings.m +++ src/OFINIFileSettings.m @@ -67,126 +67,127 @@ *category = [path substringToIndex: pos]; *key = [path substringFromIndex: pos + 1]; } -- (void)setString: (OFString *)string - forPath: (OFString *)path +- (void)setStringValue: (OFString *)string + forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category + andKey: &key + forPath: path]; + + [[_INIFile categoryForName: category] setStringValue: string + forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setLongLongValue: (long long)longLongValue + forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category + andKey: &key + forPath: path]; + + [[_INIFile categoryForName: category] setLongLongValue: longLongValue + forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setBoolValue: (bool)boolValue + 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]; + [[_INIFile categoryForName: category] setBoolValue: boolValue + forKey: key]; objc_autoreleasePoolPop(pool); } -- (void)setInteger: (long long)integer - forPath: (OFString *)path +- (void)setFloatValue: (float)floatValue + forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; - [[_INIFile categoryForName: category] setInteger: integer - forKey: key]; + [[_INIFile categoryForName: category] setFloatValue: floatValue + forKey: key]; objc_autoreleasePoolPop(pool); } -- (void)setBool: (bool)bool_ - forPath: (OFString *)path +- (void)setDoubleValue: (double)doubleValue + 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]; + [[_INIFile categoryForName: category] setDoubleValue: doubleValue + forKey: key]; objc_autoreleasePoolPop(pool); } -- (void)setFloat: (float)float_ - forPath: (OFString *)path +- (void)setStringValues: (OFArray OF_GENERIC(OFString *) *)stringValues + 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)setArray: (OFArray *)array - forPath: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFString *category, *key; - - [self of_getCategory: &category - andKey: &key - forPath: path]; - - [[_INIFile categoryForName: category] setArray: array - forKey: key]; - - objc_autoreleasePoolPop(pool); -} - -- (OFString *)stringForPath: (OFString *)path - defaultValue: (OFString *)defaultValue + [[_INIFile categoryForName: category] setStringValues: stringValues + forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (OFString *)stringValueForPath: (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 = [[_INIFile categoryForName: category] + stringValueForKey: key + defaultValue: defaultValue]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } -- (long long)integerForPath: (OFString *)path - defaultValue: (long long)defaultValue +- (long long)longLongValueForPath: (OFString *)path + defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; long long ret; @@ -193,86 +194,89 @@ [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] - integerForKey: key - defaultValue: defaultValue]; + longLongValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (bool)boolForPath: (OFString *)path - defaultValue: (bool)defaultValue +- (bool)boolValueForPath: (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]; + ret = [[_INIFile categoryForName: category] + boolValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (float)floatForPath: (OFString *)path - defaultValue: (float)defaultValue +- (float)floatValueForPath: (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]; + ret = [[_INIFile categoryForName: category] + floatValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (double)doubleForPath: (OFString *)path - defaultValue: (double)defaultValue +- (double)doubleValueForPath: (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]; + ret = [[_INIFile categoryForName: category] + doubleValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (OFArray *)arrayForPath: (OFString *)path +- (OFArray OF_GENERIC(OFString *) *)stringValuesForPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; OFArray *ret; [self of_getCategory: &category andKey: &key forPath: path]; - ret = [[_INIFile categoryForName: category] arrayForKey: key]; + ret = [[_INIFile categoryForName: category] stringValuesForKey: key]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } Index: src/OFSettings.h ================================================================== --- src/OFSettings.h +++ src/OFSettings.h @@ -65,135 +65,135 @@ */ - (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 integer. - * - * @param integer The integer to set - * @param path The path to store the integer at - */ -- (void)setInteger: (long long)integer - 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 strings at - */ -- (void)setArray: (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 value should be returned - * @return The string value 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 value should be returned - * @param defaultValue The default value to return if the path does not exist - * @return The string value of the specified path - */ -- (nullable OFString *)stringForPath: (OFString *)path - defaultValue: (nullable OFString *)defaultValue; - -/** - * @brief Returns the integer for the specified path, or the default value if - * the path does not exist. - * - * @param path The path for which the integer value should be returned - * @param defaultValue The default value to return if the path does not exist - * @return The integer value of the specified path - */ -- (long long)integerForPath: (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 value should be returned - * @param defaultValue The default value to return if the path does not exist - * @return The bool value 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 value should be returned - * @param defaultValue The default value to return if the path does not exist - * @return The float value 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 value should be returned - * @param defaultValue The default value to return if the path does not exist - * @return The double value 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 strings of the specified path - */ -- (OFArray OF_GENERIC(OFString *) *)arrayForPath: (OFString *)path; + * @brief Sets the specified path to the specified string value. + * + * @param stringValue The string value to set + * @param path The path to store the string value at + */ +- (void)setStringValue: (OFString *)stringValue + forPath: (OFString *)path; + +/** + * @brief Sets the specified path to the specified long long value. + * + * @param longLongValue The long long value to set + * @param path The path to store the long long value at + */ +- (void)setLongLongValue: (long long)longLongValue + forPath: (OFString *)path; + +/** + * @brief Sets the specified path to the specified bool value. + * + * @param boolValue The bool value to set + * @param path The path to store the bool value at + */ +- (void)setBoolValue: (bool)boolValue + forPath: (OFString *)path; + +/** + * @brief Sets the specified path to the specified float value. + * + * @param floatValue The float value to set + * @param path The path to store the float value at + */ +- (void)setFloatValue: (float)floatValue + forPath: (OFString *)path; + +/** + * @brief Sets the specified path to the specified double value. + * + * @param doubleValue The double value to set + * @param path The path to store the double value at + */ +- (void)setDoubleValue: (double)doubleValue + forPath: (OFString *)path; + +/** + * @brief Sets the specified path to the specified array of string values. + * + * @param stringValues The array of string values to set + * @param path The path to store the array of string values at + */ +- (void)setStringValues: (OFArray OF_GENERIC(OFString *) *)stringValues + forPath: (OFString *)path; + +/** + * @brief Returns the string value for the specified path, or `nil` if the path + * does not exist. + * + * @param path The path for which the string value should be returned + * @return The string value of the specified path + */ +- (nullable OFString *)stringValueForPath: (OFString *)path; + +/** + * @brief Returns the string value for the specified path, or the default value + * if the path does not exist. + * + * @param path The path for which the string value should be returned + * @param defaultValue The default value to return if the path does not exist + * @return The string value of the specified path + */ +- (nullable OFString *)stringValueForPath: (OFString *)path + defaultValue: (nullable OFString *)defaultValue; + +/** + * @brief Returns the long long value for the specified path, or the default + * value if the path does not exist. + * + * @param path The path for which the long long value should be returned + * @param defaultValue The default value to return if the path does not exist + * @return The long long value of the specified path + */ +- (long long)longLongValueForPath: (OFString *)path + defaultValue: (long long)defaultValue; + +/** + * @brief Returns the bool value for the specified path, or the default value if + * the path does not exist. + * + * @param path The path for which the bool value should be returned + * @param defaultValue The default value to return if the path does not exist + * @return The bool value of the specified path + */ +- (bool)boolValueForPath: (OFString *)path + defaultValue: (bool)defaultValue; + +/** + * @brief Returns the float value for the specified path, or the default value + * if the path does not exist. + * + * @param path The path for which the float value should be returned + * @param defaultValue The default value to return if the path does not exist + * @return The float value of the specified path + */ +- (float)floatValueForPath: (OFString *)path + defaultValue: (float)defaultValue; + +/** + * @brief Returns the double value for the specified path, or the default value + * if the path does not exist. + * + * @param path The path for which the double value should be returned + * @param defaultValue The default value to return if the path does not exist + * @return The double value of the specified path + */ +- (double)doubleValueForPath: (OFString *)path + defaultValue: (double)defaultValue; + +/** + * @brief Returns the array of string values for the specified path, or an empty + * array if the path does not exist. + * + * @param path The path for which the array of string values should be returned + * @return The array of string values of the specified path + */ +- (OFArray OF_GENERIC(OFString *) *)stringValuesForPath: (OFString *)path; /** * @brief Removes the value for the specified path. * * @param path The path for which the value should be removed Index: src/OFSettings.m ================================================================== --- src/OFSettings.m +++ src/OFSettings.m @@ -60,83 +60,83 @@ [_applicationName release]; [super dealloc]; } -- (void)setString: (OFString *)string - forPath: (OFString *)path -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)setInteger: (long long)integer - 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)setArray: (OFArray *)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)integerForPath: (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 *)arrayForPath: (OFString *)path +- (void)setStringValue: (OFString *)stringValue + forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setLongLongValue: (long long)longLongValue + forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setBoolValue: (bool)boolValue + forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setFloatValue: (float)floatValue + forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setDoubleValue: (double)doubleValue + forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setStringValues: (OFArray OF_GENERIC(OFString *) *)stringValues + forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (OFString *)stringValueForPath: (OFString *)path +{ + return [self stringValueForPath: path + defaultValue: nil]; +} + +- (OFString *)stringValueForPath: (OFString *)path + defaultValue: (OFString *)defaultValue +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (long long)longLongValueForPath: (OFString *)path + defaultValue: (long long)defaultValue +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (bool)boolValueForPath: (OFString *)path + defaultValue: (bool)defaultValue +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (float)floatValueForPath: (OFString *)path + defaultValue: (float)defaultValue +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (double)doubleValueForPath: (OFString *)path + defaultValue: (double)defaultValue +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (OFArray OF_GENERIC(OFString *) *)stringValuesForPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)removeValueForPath: (OFString *)path Index: tests/OFINIFileTests.m ================================================================== --- tests/OFINIFileTests.m +++ tests/OFINIFileTests.m @@ -60,59 +60,61 @@ 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(@"-[integerForKey:defaultValue:]", - [types integerForKey: @"integer" - defaultValue: 2] == 0x20) - - TEST(@"-[setInteger:forKey:]", R([types setInteger: 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" + TEST(@"-[stringValueForKey:]", + [[tests stringValueForKey: @"foo"] isEqual: @"bar"] && + [[foobar stringValueForKey: @"quxquxqux"] isEqual: @"hello\"wörld"]) + + TEST(@"-[setStringValue:forKey:]", + R([tests setStringValue: @"baz" + forKey: @"foo"]) && + R([tests setStringValue: @"new" + forKey: @"new"]) && + R([foobar setStringValue: @"a\fb" + forKey: @"qux3"])) + + TEST(@"-[longLongValueForKey:defaultValue:]", + [types longLongValueForKey: @"integer" + defaultValue: 2] == 0x20) + + TEST(@"-[setLongLongValue:forKey:]", + R([types setLongLongValue: 0x10 + forKey: @"integer"])) + + TEST(@"-[boolValueForKey:defaultValue:]", + [types boolValueForKey: @"bool" + defaultValue: false] == true) + + TEST(@"-[setBoolValue:forKey:]", R([types setBoolValue: false + forKey: @"bool"])) + + TEST(@"-[floatValueForKey:defaultValue:]", + [types floatValueForKey: @"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"])) + TEST(@"-[setFloatValue:forKey:]", R([types setFloatValue: 0.25f + forKey: @"float"])) + + TEST(@"-[doubleValueForKey:defaultValue:]", + [types doubleValueForKey: @"double" + defaultValue: 3] == 0.25) + + TEST(@"-[setDoubleValue:forKey:]", R([types setDoubleValue: 0.75 + forKey: @"double"])) array = [OFArray arrayWithObjects: @"1", @"2", nil]; - TEST(@"-[arrayForKey:]", - [[types arrayForKey: @"array1"] isEqual: array] && - [[types arrayForKey: @"array2"] isEqual: array] && - [[types arrayForKey: @"array3"] isEqual: [OFArray array]]) + TEST(@"-[stringValuesForKey:]", + [[types stringValuesForKey: @"array1"] isEqual: array] && + [[types stringValuesForKey: @"array2"] isEqual: array] && + [[types stringValuesForKey: @"array3"] isEqual: [OFArray array]]) array = [OFArray arrayWithObjects: @"foo", @"bar", nil]; - TEST(@"-[setArray:forKey:]", R([types setArray: array - forKey: @"array1"])) + TEST(@"-[setStringValues:forKey:]", + R([types setStringValues: array + forKey: @"array1"])) TEST(@"-[removeValueForKey:]", R([foobar removeValueForKey: @"quxqux "]) && R([types removeValueForKey: @"array2"]))