Overview
Comment: | Add a new convenience method to OFString. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
88163bd1722606a1053222b6585933b6 |
User & Date: | js on 2009-05-23 22:07:22 |
Other Links: | manifest | tags |
Context
2009-05-24
| ||
00:18 | Get rid of dependency on getpagesize(). check-in: 127d635848 user: js tags: trunk | |
2009-05-23
| ||
22:07 | Add a new convenience method to OFString. check-in: 88163bd172 user: js tags: trunk | |
21:53 | A few renames. check-in: 526d04018d user: js tags: trunk | |
Changes
Modified src/OFMutableString.m from [da1cf273ef] to [d29d560858].
︙ | ︙ | |||
31 32 33 34 35 36 37 | #ifndef HAVE_ASPRINTF #import "asprintf.h" #endif @implementation OFMutableString - (id)copy { | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #ifndef HAVE_ASPRINTF #import "asprintf.h" #endif @implementation OFMutableString - (id)copy { return [[OFString alloc] initWithString: self]; } - setToCString: (const char*)str { size_t len; if (string != NULL) |
︙ | ︙ |
Modified src/OFString.h from [54ab126f71] to [0f37fc8589].
︙ | ︙ | |||
31 32 33 34 35 36 37 | int _unused; #endif #endif BOOL is_utf8; } /** | | | | | | | > > > > > > > > | | | | | | | | | > > > > > > > > | 31 32 33 34 35 36 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 | int _unused; #endif #endif BOOL is_utf8; } /** * \return A new autoreleased OFString */ + string; /** * Creates a new OFString from a C string. * * \param str A C string to initialize the OFString with * \return A new autoreleased OFString */ + stringWithCString: (const char*)str; /** * Creates a new OFString from a format string. * See printf for the format syntax. * * \param fmt A string used as format to initialize the OFString * \return A new autoreleased OFString */ + stringWithFormat: (OFString*)fmt, ...; /** * Creates a new OFString from another string. * * \param str A string to initialize the OFString with * \return A new autoreleased OFString */ + stringWithString: (OFString*)str; /** * Initializes an already allocated OFString. * * \return An initialized OFString */ - init; /** * Initializes an already allocated OFString with a C string. * * \param str A C string to initialize the OFString with * \return An initialized OFString */ - initWithCString: (const char*)str; /** * Initializes an already allocated OFString with a format string. * See printf for the format syntax. * * \param fmt A string used as format to initialize the OFString * \return An initialized OFString */ - initWithFormat: (OFString*)fmt, ...; /** * Initializes an already allocated OFString with a format string. * See printf for the format syntax. * * \param fmt A string used as format to initialize the OFString * \param args The arguments used in the format string * \return An initialized OFString */ - initWithFormat: (OFString*)fmt andArguments: (va_list)args; /** * Initializes an already allocated OFString with another string. * * \param str A string to initialize the OFString with * \return An initialized OFString */ - initWithString: (OFString*)str; /** * \return The OFString as a C string */ - (const char*)cString; /** * \return The length of the OFString |
︙ | ︙ |
Modified src/OFString.m from [7338b9f854] to [40c6a50185].
︙ | ︙ | |||
125 126 127 128 129 130 131 132 133 134 135 136 137 138 | va_start(args, fmt); ret = [[[self alloc] initWithFormat: fmt andArguments: args] autorelease]; va_end(args); return ret; } - init { [super init]; string = NULL; | > > > > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | va_start(args, fmt); ret = [[[self alloc] initWithFormat: fmt andArguments: args] autorelease]; va_end(args); return ret; } + stringWithString: (OFString*)str { return [[[self alloc] initWithString: str] autorelease]; } - init { [super init]; string = NULL; |
︙ | ︙ | |||
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 | } @catch (OFException *e) { free(string); @throw e; } return self; } - (const char*)cString { return string; } - (size_t)length { return length; } - (id)copy { return [self retain]; } - (id)mutableCopy { | > > > > > > > > > > > > > > > > > > > > > > > | | 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | } @catch (OFException *e) { free(string); @throw e; } return self; } - initWithString: (OFString*)str { self = [super init]; string = strdup([str cString]); length = [str length]; @try { [self addItemToMemoryPool: string]; } @catch (OFException *e) { /* * We can't use [super dealloc] on OS X here. * Compiler bug? Anyway, [self dealloc] will do here as we * don't reimplement dealloc. */ free(string); [self dealloc]; @throw e; } return self; } - (const char*)cString { return string; } - (size_t)length { return length; } - (id)copy { return [self retain]; } - (id)mutableCopy { return [[OFMutableString alloc] initWithString: self]; } - (BOOL)isEqual: (id)obj { if (![obj isKindOf: [OFString class]]) return NO; if (strcmp(string, [obj cString])) |
︙ | ︙ |