Overview
Comment: | Add OFNumber. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
555f28985ff2a2c21872b5343795ccef |
User & Date: | js on 2008-12-30 14:42:27 |
Other Links: | manifest | tags |
Context
2009-01-02
| ||
17:20 | Some import fixes, some static lib and win32 enhancements. check-in: ba01b9c18a user: js tags: trunk | |
2008-12-30
| ||
14:42 | Add OFNumber. check-in: 555f28985f user: js tags: trunk | |
2008-12-26
| ||
21:34 | Remove redundant method. check-in: 617ca244c5 user: js tags: trunk | |
Changes
Modified src/Makefile from [6024c12020] to [17df7c65b5].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | include ../extra.mk LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX} LIB_MAJOR = 1 LIB_MINOR = 0 SRCS = OFArray.m \ OFExceptions.m \ OFHashes.m \ OFFile.m \ OFList.m \ OFListObject.m \ OFObject.m \ OFString.m \ OFTCPSocket.m \ OFXMLFactory.m \ ${ASPRINTF} INCLUDESTMP = ${SRCS:.c=.h} | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | include ../extra.mk LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX} LIB_MAJOR = 1 LIB_MINOR = 0 SRCS = OFArray.m \ OFExceptions.m \ OFHashes.m \ OFFile.m \ OFList.m \ OFListObject.m \ OFNumber.m \ OFObject.m \ OFString.m \ OFTCPSocket.m \ OFXMLFactory.m \ ${ASPRINTF} INCLUDESTMP = ${SRCS:.c=.h} |
︙ | ︙ |
Added src/OFNumber.h version [2b396a780c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 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 | /* * Copyright (c) 2008 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" enum of_number_type { OF_NUMBER_CHAR, OF_NUMBER_SHORT, OF_NUMBER_INT, OF_NUMBER_LONG, OF_NUMBER_UCHAR, OF_NUMBER_USHORT, OF_NUMBER_UINT, OF_NUMBER_ULONG, OF_NUMBER_INT8, OF_NUMBER_INT16, OF_NUMBER_INT32, OF_NUMBER_INT64, OF_NUMBER_UINT8, OF_NUMBER_UINT16, OF_NUMBER_UINT32, OF_NUMBER_UINT64, OF_NUMBER_SIZE, OF_NUMBER_SSIZE, OF_NUMBER_PTRDIFF, OF_NUMBER_INTPTR, OF_NUMBER_FLOAT, OF_NUMBER_DOUBLE, OF_NUMBER_LONG_DOUBLE }; /** * The OFNumber class provides a way to store a number in an object and * manipulate it. */ @interface OFNumber: OFObject { union { char char_; short short_; int int_; long long_; unsigned char uchar; unsigned short ushort; unsigned int uint; unsigned long ulong; int8_t int8; int16_t int16; int32_t int32; int64_t int64; uint8_t uint8; uint16_t uint16; uint32_t uint32; uint64_t uint64; size_t size; ssize_t ssize; ptrdiff_t ptrdiff; intptr_t intptr; float float_; double double_; long double longdouble; } value; enum of_number_type type; } + newWithChar: (char)char_; + newWithShort: (short)short_; + newWithInt: (int)int_; + newWithLong: (long)long_; + newWithUChar: (unsigned char)uchar; + newWithUShort: (unsigned short)ushort; + newWithUInt: (unsigned int)uint; + newWithULong: (unsigned long)ulong; + newWithInt8: (int8_t)int8; + newWithInt16: (int16_t)int16; + newWithInt32: (int32_t)int32; + newWithInt64: (int64_t)int64; + newWithUInt8: (uint8_t)uint8; + newWithUInt16: (uint16_t)uint16; + newWithUInt32: (uint32_t)uint32; + newWithUInt64: (uint64_t)uint64; + newWithSize: (size_t)size; + newWithSSize: (ssize_t)ssize; + newWithPtrDiff: (ptrdiff_t)ptrdiff; + newWithIntPtr: (intptr_t)intptr; + newWithFloat: (float)float_; + newWithDouble: (double)double_; + newWithLongDouble: (long double)longdouble; - initWithChar: (char)char_; - initWithShort: (short)short_; - initWithInt: (int)int_; - initWithLong: (long)long_; - initWithUChar: (unsigned char)uchar; - initWithUShort: (unsigned short)ushort; - initWithUInt: (unsigned int)uint; - initWithULong: (unsigned long)ulong; - initWithInt8: (int8_t)int8; - initWithInt16: (int16_t)int16; - initWithInt32: (int32_t)int32; - initWithInt64: (int64_t)int64; - initWithUInt8: (uint8_t)uint8; - initWithUInt16: (uint16_t)uint16; - initWithUInt32: (uint32_t)uint32; - initWithUInt64: (uint64_t)uint64; - initWithSize: (size_t)size; - initWithSSize: (ssize_t)ssize; - initWithPtrDiff: (ptrdiff_t)ptrdiff; - initWithIntPtr: (intptr_t)intptr; - initWithFloat: (float)float_; - initWithDouble: (double)double_; - initWithLongDouble: (long double)longdouble; - (enum of_number_type)type; - (char)asChar; - (short)asShort; - (int)asInt; - (long)asLong; - (unsigned char)asUChar; - (unsigned short)asUShort; - (unsigned int)asUInt; - (unsigned long)asULong; - (int8_t)asInt8; - (int16_t)asInt16; - (int32_t)asInt32; - (int64_t)asInt64; - (uint8_t)asUInt8; - (uint16_t)asUInt16; - (uint32_t)asUInt32; - (uint64_t)asUInt64; - (size_t)asSize; - (ssize_t)asSSize; - (ptrdiff_t)asPtrDiff; - (intptr_t)asIntPtr; - (float)asFloat; - (double)asDouble; - (long double)asLongDouble; @end |
Added src/OFNumber.m version [f0e9fb484c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 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 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 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 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | /* * Copyright (c) 2008 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFNumber.h" #import "OFExceptions.h" #define RETURN_AS(t) \ switch (type) { \ case OF_NUMBER_CHAR: \ return (t)value.char_; \ case OF_NUMBER_SHORT: \ return (t)value.short_; \ case OF_NUMBER_INT: \ return (t)value.int_; \ case OF_NUMBER_LONG: \ return (t)value.long_; \ case OF_NUMBER_UCHAR: \ return (t)value.uchar; \ case OF_NUMBER_USHORT: \ return (t)value.ushort; \ case OF_NUMBER_UINT: \ return (t)value.uint; \ case OF_NUMBER_ULONG: \ return (t)value.ulong; \ case OF_NUMBER_INT8: \ return (t)value.int8; \ case OF_NUMBER_INT16: \ return (t)value.int16; \ case OF_NUMBER_INT32: \ return (t)value.int32; \ case OF_NUMBER_INT64: \ return (t)value.int64; \ case OF_NUMBER_UINT8: \ return (t)value.uint8; \ case OF_NUMBER_UINT16: \ return (t)value.uint16; \ case OF_NUMBER_UINT32: \ return (t)value.uint32; \ case OF_NUMBER_UINT64: \ return (t)value.uint64; \ case OF_NUMBER_SIZE: \ return (t)value.size; \ case OF_NUMBER_SSIZE: \ return (t)value.ssize; \ case OF_NUMBER_PTRDIFF: \ return (t)value.ptrdiff; \ case OF_NUMBER_INTPTR: \ return (t)value.intptr; \ case OF_NUMBER_FLOAT: \ return (t)value.float_; \ case OF_NUMBER_DOUBLE: \ return (t)value.double_; \ case OF_NUMBER_LONG_DOUBLE: \ return (t)value.longdouble; \ default: \ @throw [OFInvalidFormatException newWithObject: self]; \ \ /* Make gcc happy */ \ return 0; \ } @implementation OFNumber + newWithChar: (char)char_ { return [[self alloc] initWithChar: char_]; } + newWithShort: (short)short_ { return [[self alloc] initWithShort: short_]; } + newWithInt: (int)int_ { return [[self alloc] initWithInt: int_]; } + newWithLong: (long)long_ { return [[self alloc] initWithLong: long_]; } + newWithUChar: (unsigned char)uchar { return [[self alloc] initWithUChar: uchar]; } + newWithUShort: (unsigned short)ushort { return [[self alloc] initWithUShort: ushort]; } + newWithUInt: (unsigned int)uint { return [[self alloc] initWithUInt: uint]; } + newWithULong: (unsigned long)ulong { return [[self alloc] initWithULong: ulong]; } + newWithInt8: (int8_t)int8 { return [[self alloc] initWithInt8: int8]; } + newWithInt16: (int16_t)int16 { return [[self alloc] initWithInt16: int16]; } + newWithInt32: (int32_t)int32 { return [[self alloc] initWithInt32: int32]; } + newWithInt64: (int64_t)int64 { return [[self alloc] initWithInt64: int64]; } + newWithUInt8: (uint8_t)uint8 { return [[self alloc] initWithUInt8: uint8]; } + newWithUInt16: (uint16_t)uint16 { return [[self alloc] initWithUInt16: uint16]; } + newWithUInt32: (uint32_t)uint32 { return [[self alloc] initWithUInt32: uint32]; } + newWithUInt64: (uint64_t)uint64 { return [[self alloc] initWithUInt64: uint64]; } + newWithSize: (size_t)size { return [[self alloc] initWithSize: size]; } + newWithSSize: (ssize_t)ssize { return [[self alloc] initWithSSize: ssize]; } + newWithPtrDiff: (ptrdiff_t)ptrdiff { return [[self alloc] initWithPtrDiff: ptrdiff]; } + newWithIntPtr: (intptr_t)intptr { return [[self alloc] initWithIntPtr: intptr]; } + newWithFloat: (float)float_ { return [[self alloc] initWithFloat: float_]; } + newWithDouble: (double)double_ { return [[self alloc] initWithDouble: double_]; } + newWithLongDouble: (long double)longdouble { return [[self alloc] initWithLongDouble: longdouble]; } - initWithChar: (char)char_ { if ((self = [super init])) { value.char_ = char_; type = OF_NUMBER_CHAR; } return self; } - initWithShort: (short)short_ { if ((self = [super init])) { value.short_ = short_; type = OF_NUMBER_SHORT; } return self; } - initWithInt: (int)int_ { if ((self = [super init])) { value.int_ = int_; type = OF_NUMBER_INT; } return self; } - initWithLong: (long)long_ { if ((self = [super init])) { value.long_ = long_; type = OF_NUMBER_LONG; } return self; } - initWithUChar: (unsigned char)uchar { if ((self = [super init])) { value.uchar = uchar; type = OF_NUMBER_UCHAR; } return self; } - initWithUShort: (unsigned short)ushort { if ((self = [super init])) { value.ushort = ushort; type = OF_NUMBER_USHORT; } return self; } - initWithUInt: (unsigned int)uint { if ((self = [super init])) { value.uint = uint; type = OF_NUMBER_UINT; } return self; } - initWithULong: (unsigned long)ulong { if ((self = [super init])) { value.ulong = ulong; type = OF_NUMBER_ULONG; } return self; } - initWithInt8: (int8_t)int8 { if ((self = [super init])) { value.int8 = int8; type = OF_NUMBER_INT8; } return self; } - initWithInt16: (int16_t)int16 { if ((self = [super init])) { value.int16 = int16; type = OF_NUMBER_INT16; } return self; } - initWithInt32: (int32_t)int32 { if ((self = [super init])) { value.int32 = int32; type = OF_NUMBER_INT32; } return self; } - initWithInt64: (int64_t)int64 { if ((self = [super init])) { value.int64 = int64; type = OF_NUMBER_INT64; } return self; } - initWithUInt8: (uint8_t)uint8 { if ((self = [super init])) { value.uint8 = uint8; type = OF_NUMBER_UINT8; } return self; } - initWithUInt16: (uint16_t)uint16 { if ((self = [super init])) { value.uint16 = uint16; type = OF_NUMBER_UINT16; } return self; } - initWithUInt32: (uint32_t)uint32 { if ((self = [super init])) { value.uint32 = uint32; type = OF_NUMBER_UINT32; } return self; } - initWithUInt64: (uint64_t)uint64 { if ((self = [super init])) { value.uint64 = uint64; type = OF_NUMBER_UINT64; } return self; } - initWithSize: (size_t)size { if ((self = [super init])) { value.size = size; type = OF_NUMBER_SIZE; } return self; } - initWithSSize: (ssize_t)ssize { if ((self = [super init])) { value.ssize = ssize; type = OF_NUMBER_SSIZE; } return self; } - initWithPtrDiff: (ptrdiff_t)ptrdiff { if ((self = [super init])) { value.ptrdiff = ptrdiff; type = OF_NUMBER_PTRDIFF; } return self; } - initWithIntPtr: (intptr_t)intptr { if ((self = [super init])) { value.intptr = intptr; type = OF_NUMBER_INTPTR; } return self; } - initWithFloat: (float)float_ { if ((self = [super init])) { value.float_ = float_; type = OF_NUMBER_FLOAT; } return self; } - initWithDouble: (double)double_ { if ((self = [super init])) { value.double_ = double_; type = OF_NUMBER_DOUBLE; } return self; } - initWithLongDouble: (long double)longdouble { if ((self = [super init])) { value.longdouble = longdouble; type = OF_NUMBER_LONG_DOUBLE; } return self; } - (enum of_number_type)type { return type; } - (char)asChar { RETURN_AS(char) } - (short)asShort { RETURN_AS(short) } - (int)asInt { RETURN_AS(int) } - (long)asLong { RETURN_AS(long) } - (unsigned char)asUChar { RETURN_AS(unsigned char) } - (unsigned short)asUShort { RETURN_AS(unsigned short) } - (unsigned int)asUInt { RETURN_AS(unsigned int) } - (unsigned long)asULong { RETURN_AS(unsigned long) } - (int8_t)asInt8 { RETURN_AS(int8_t) } - (int16_t)asInt16 { RETURN_AS(int16_t) } - (int32_t)asInt32 { RETURN_AS(int32_t) } - (int64_t)asInt64 { RETURN_AS(int64_t) } - (uint8_t)asUInt8 { RETURN_AS(uint8_t) } - (uint16_t)asUInt16 { RETURN_AS(uint16_t) } - (uint32_t)asUInt32 { RETURN_AS(uint32_t) } - (uint64_t)asUInt64 { RETURN_AS(uint64_t) } - (size_t)asSize { RETURN_AS(size_t) } - (ssize_t)asSSize { RETURN_AS(ssize_t) } - (ptrdiff_t)asPtrDiff { RETURN_AS(ptrdiff_t) } - (intptr_t)asIntPtr { RETURN_AS(intptr_t) } - (float)asFloat { RETURN_AS(float) } - (double)asDouble { RETURN_AS(double) } - (long double)asLongDouble { RETURN_AS(long double) } @end |
Modified src/OFString.h from [3e60c38f22] to [23e156a28f].
︙ | ︙ | |||
105 106 107 108 109 110 111 | /** * Frees the OFString and sets it to the specified OFString. * * \param str An OFString to set the OFString to. * \return The new OFString */ | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | /** * Frees the OFString and sets it to the specified OFString. * * \param str An OFString to set the OFString to. * \return The new OFString */ - setTo: (OFString*)str; /** * Compares the OFString to another OFString. * * \param str An OFString to compare with * \return An integer which is the result of the comparison, see wcscmp */ |
︙ | ︙ |
Modified src/OFString.m from [384f44e40d] to [8055b56c32].
︙ | ︙ | |||
223 224 225 226 227 228 229 | } - (OFString*)clone { return [OFString newFromCString: string]; } | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | } - (OFString*)clone { return [OFString newFromCString: string]; } - setTo: (OFString*)str { [self free]; return (self = [str clone]); } - (int)compareTo: (OFString*)str { |
︙ | ︙ |