Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -373,10 +373,32 @@ * \param str The string to append * \return A new autoreleased OFString with the specified string appended */ - (OFString*)stringByAppendingString: (OFString*)str; +/** + * Creates a new string by deleting leading whitespaces. + * + * \return A new autoreleased OFString with leading whitespaces deleted + */ +- (OFString*)stringByDeletingLeadingWhitespaces; + +/** + * Creates a new string by deleting trailing whitespaces. + * + * \return A new autoreleased OFString with trailing whitespaces deleted + */ +- (OFString*)stringByDeletingTrailingWhitespaces; + +/** + * Creates a new string by deleting leading and trailing whitespaces. + * + * \return A new autoreleased OFString with leading and trailing whitespaces + * deleted + */ +- (OFString*)stringByDeletingLeadingAndTrailingWhitespaces; + /** * Checks whether the string has the specified prefix. * * \param prefix The prefix to check for * \return A boolean whether the string has the specified prefix Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -999,10 +999,58 @@ OFMutableString *new; new = [OFMutableString stringWithString: self]; [new appendString: str]; + /* + * Class swizzle the string to be immutable. We declared the return type + * to be OFString*, so it can't be modified anyway. But not swizzling it + * would create a real copy each time -[copy] is called. + */ + new->isa = [OFString class]; + return new; +} + +- (OFString*)stringByDeletingLeadingWhitespaces +{ + OFMutableString *new; + + new = [OFMutableString stringWithString: self]; + [new deleteLeadingWhitespaces]; + + /* + * Class swizzle the string to be immutable. We declared the return type + * to be OFString*, so it can't be modified anyway. But not swizzling it + * would create a real copy each time -[copy] is called. + */ + new->isa = [OFString class]; + return new; +} + +- (OFString*)stringByDeletingTrailingWhitespaces +{ + OFMutableString *new; + + new = [OFMutableString stringWithString: self]; + [new deleteTrailingWhitespaces]; + + /* + * Class swizzle the string to be immutable. We declared the return type + * to be OFString*, so it can't be modified anyway. But not swizzling it + * would create a real copy each time -[copy] is called. + */ + new->isa = [OFString class]; + return new; +} + +- (OFString*)stringByDeletingLeadingAndTrailingWhitespaces +{ + OFMutableString *new; + + new = [OFMutableString stringWithString: self]; + [new deleteLeadingAndTrailingWhitespaces]; + /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */