@@ -176,17 +176,17 @@ [_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]]) @@ -199,15 +199,15 @@ } return defaultValue; } -- (long long)longLongForKey: (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 @@ -216,14 +216,14 @@ 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; @@ -237,14 +237,14 @@ 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 @@ -253,14 +253,14 @@ 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 @@ -269,11 +269,11 @@ objc_autoreleasePoolPop(pool); return ret; } -- (OFArray OF_GENERIC(OFString *) *)stringArrayForKey: (OFString *)key +- (OFArray OF_GENERIC(OFString *) *)arrayValueForKey: (OFString *)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (id line in _lines) { @@ -293,11 +293,11 @@ [ret makeImmutable]; return ret; } -- (void)setString: (OFString *)string forKey: (OFString *)key +- (void)setStringValue: (OFString *)string forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); OFINICategoryPair *pair; for (id line in _lines) { @@ -333,64 +333,65 @@ } 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)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)setArrayValue: (OFArray OF_GENERIC(OFString *) *)arrayValue + forKey: (OFString *)key { void *pool; OFMutableArray *pairs; id const *lines; size_t count; bool replaced; - if (array.count == 0) { + if (arrayValue.count == 0) { [self removeValueForKey: key]; return; } pool = objc_autoreleasePoolPush(); - pairs = [OFMutableArray arrayWithCapacity: array.count]; + pairs = [OFMutableArray arrayWithCapacity: arrayValue.count]; - for (OFString *string in array) { + for (OFString *string in arrayValue) { OFINICategoryPair *pair; if (![string isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; @@ -420,11 +421,11 @@ [_lines insertObjectsFromArray: pairs atIndex: i]; replaced = true; /* Continue after inserted pairs */ - i += array.count - 1; + i += arrayValue.count - 1; } else i--; /* Continue at same position */ lines = _lines.objects; count = _lines.count;