︙ | | |
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
-
-
-
+
+
+
|
#ifndef OF_NUMBER_M
OF_SUBCLASSING_RESTRICTED
#endif
@interface OFNumber: OFValue <OFComparing, OFSerialization,
OFJSONRepresentation, OFMessagePackRepresentation>
{
union of_number_value {
double float_;
intmax_t signed_;
uintmax_t unsigned_;
double float_;
long long signed_;
unsigned long long unsigned_;
} _value;
enum of_number_type {
OF_NUMBER_TYPE_FLOAT = 1,
OF_NUMBER_TYPE_SIGNED,
OF_NUMBER_TYPE_UNSIGNED
} _type;
const char *_typeEncoding;
|
︙ | | |
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
-
-
-
-
-
-
-
-
-
-
|
@property (readonly, nonatomic) size_t sizeValue;
/*!
* @brief The OFNumber as an `ssize_t`.
*/
@property (readonly, nonatomic) ssize_t sSizeValue;
/*!
* @brief The OFNumber as an `intmax_t`.
*/
@property (readonly, nonatomic) intmax_t intMaxValue;
/*!
* @brief The OFNumber as a `uintmax_t`.
*/
@property (readonly, nonatomic) uintmax_t uIntMaxValue;
/*!
* @brief The OFNumber as a `ptrdiff_t`.
*/
@property (readonly, nonatomic) ptrdiff_t ptrDiffValue;
/*!
* @brief The OFNumber as an `intptr_t`.
|
︙ | | |
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
|
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
+ (instancetype)valueWithDimension: (of_dimension_t)dimension OF_UNAVAILABLE;
+ (instancetype)valueWithRectangle: (of_rectangle_t)rectangle OF_UNAVAILABLE;
#endif
/*!
* @brief Creates a new OFNumber with the specified `bool`.
*
* @param bool_ A `bool` which the OFNumber should contain
* @param value The `bool` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithBool: (bool)bool_;
+ (instancetype)numberWithBool: (bool)value;
/*!
* @brief Creates a new OFNumber with the specified `signed char`.
*
* @param sChar A `signed char` which the OFNumber should contain
* @param value The `signed char` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithChar: (signed char)sChar;
+ (instancetype)numberWithChar: (signed char)value;
/*!
* @brief Creates a new OFNumber with the specified `short`.
*
* @param sShort A `short` which the OFNumber should contain
* @param value The `short` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithShort: (short)sShort;
+ (instancetype)numberWithShort: (short)value;
/*!
* @brief Creates a new OFNumber with the specified `int`.
*
* @param sInt An `int` which the OFNumber should contain
* @param value The `int` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithInt: (int)sInt;
+ (instancetype)numberWithInt: (int)value;
/*!
* @brief Creates a new OFNumber with the specified `long`.
*
* @param sLong A `long` which the OFNumber should contain
* @param value The `long` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithLong: (long)sLong;
+ (instancetype)numberWithLong: (long)value;
/*!
* @brief Creates a new OFNumber with the specified `long long`.
*
* @param sLongLong A `long long` which the OFNumber should contain
* @param value The `long long` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithLongLong: (long long)sLongLong;
+ (instancetype)numberWithLongLong: (long long)value;
/*!
* @brief Creates a new OFNumber with the specified `unsigned char`.
*
* @param uChar An `unsigned char` which the OFNumber should contain
* @param value The `unsigned char` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedChar: (unsigned char)uChar;
+ (instancetype)numberWithUnsignedChar: (unsigned char)value;
/*!
* @brief Creates a new OFNumber with the specified `unsigned short`.
*
* @param uShort An `unsigned short` which the OFNumber should contain
* @param value The `unsigned short` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedShort: (unsigned short)uShort;
+ (instancetype)numberWithUnsignedShort: (unsigned short)value;
/*!
* @brief Creates a new OFNumber with the specified `unsigned int`.
*
* @param uInt An `unsigned int` which the OFNumber should contain
* @param value The `unsigned int` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedInt: (unsigned int)uInt;
+ (instancetype)numberWithUnsignedInt: (unsigned int)value;
/*!
* @brief Creates a new OFNumber with the specified `unsigned long`.
*
* @param uLong An `unsigned long` which the OFNumber should contain
* @param value The `unsigned long` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedLong: (unsigned long)uLong;
+ (instancetype)numberWithUnsignedLong: (unsigned long)value;
/*!
* @brief Creates a new OFNumber with the specified `unsigned long long`.
*
* @param uLongLong An `unsigned long long` which the OFNumber should contain
* @param value The `unsigned long long` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)uLongLong;
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)value;
/*!
* @brief Creates a new OFNumber with the specified `int8_t`.
*
* @param int8 An `int8_t` which the OFNumber should contain
* @param value The `int8_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithInt8: (int8_t)int8;
+ (instancetype)numberWithInt8: (int8_t)value;
/*!
* @brief Creates a new OFNumber with the specified `int16_t`.
*
* @param int16 An `int16_t` which the OFNumber should contain
* @param value The `int16_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithInt16: (int16_t)int16;
+ (instancetype)numberWithInt16: (int16_t)value;
/*!
* @brief Creates a new OFNumber with the specified `int32_t`.
*
* @param int32 An `int32_t` which the OFNumber should contain
* @param value The `int32_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithInt32: (int32_t)int32;
+ (instancetype)numberWithInt32: (int32_t)value;
/*!
* @brief Creates a new OFNumber with the specified `int64_t`.
*
* @param int64 An `int64_t` which the OFNumber should contain
* @param value The `int64_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithInt64: (int64_t)int64;
+ (instancetype)numberWithInt64: (int64_t)value;
/*!
* @brief Creates a new OFNumber with the specified `uint8_t`.
*
* @param uInt8 A `uint8_t` which the OFNumber should contain
* @param value The `uint8_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt8: (uint8_t)uInt8;
+ (instancetype)numberWithUInt8: (uint8_t)value;
/*!
* @brief Creates a new OFNumber with the specified `uint16_t`.
*
* @param uInt16 A `uint16_t` which the OFNumber should contain
* @param value The `uint16_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt16: (uint16_t)uInt16;
+ (instancetype)numberWithUInt16: (uint16_t)value;
/*!
* @brief Creates a new OFNumber with the specified `uint32_t`.
*
* @param uInt32 A `uint32_t` which the OFNumber should contain
* @param value The `uint32_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt32: (uint32_t)uInt32;
+ (instancetype)numberWithUInt32: (uint32_t)value;
/*!
* @brief Creates a new OFNumber with the specified `uint64_t`.
*
* @param uInt64 A `uint64_t` which the OFNumber should contain
* @param value The `uint64_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt64: (uint64_t)uInt64;
+ (instancetype)numberWithUInt64: (uint64_t)value;
/*!
* @brief Creates a new OFNumber with the specified `size_t`.
*
* @param size A `size_t` which the OFNumber should contain
* @param value The `size_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithSize: (size_t)size;
+ (instancetype)numberWithSize: (size_t)value;
/*!
* @brief Creates a new OFNumber with the specified `ssize_t`.
*
* @param sSize An `ssize_t` which the OFNumber should contain
* @param value The `ssize_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithSSize: (ssize_t)sSize;
+ (instancetype)numberWithSSize: (ssize_t)value;
/*!
* @brief Creates a new OFNumber with the specified `intmax_t`.
*
* @param intMax An `intmax_t` which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithIntMax: (intmax_t)intMax;
/*!
* @brief Creates a new OFNumber with the specified `uintmax_t`.
*
* @param uIntMax A `uintmax_t` which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUIntMax: (uintmax_t)uIntMax;
/*!
* @brief Creates a new OFNumber with the specified `ptrdiff_t`.
*
* @param ptrDiff A `ptrdiff_t` which the OFNumber should contain
* @param value The `ptrdiff_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrDiff;
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)value;
/*!
* @brief Creates a new OFNumber with the specified `intptr_t`.
*
* @param intPtr An `intptr_t` which the OFNumber should contain
* @param value The `intptr_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithIntPtr: (intptr_t)intPtr;
+ (instancetype)numberWithIntPtr: (intptr_t)value;
/*!
* @brief Creates a new OFNumber with the specified `uintptr_t`.
*
* @param uIntPtr A `uintptr_t` which the OFNumber should contain
* @param value The `uintptr_t` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUIntPtr: (uintptr_t)uIntPtr;
+ (instancetype)numberWithUIntPtr: (uintptr_t)value;
/*!
* @brief Creates a new OFNumber with the specified `float`.
*
* @param float_ A `float` which the OFNumber should contain
* @param value The `float` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithFloat: (float)float_;
+ (instancetype)numberWithFloat: (float)value;
/*!
* @brief Creates a new OFNumber with the specified `double`.
*
* @param double_ A `double` which the OFNumber should contain
* @param value The `double` value which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithDouble: (double)double_;
+ (instancetype)numberWithDouble: (double)value;
- (instancetype)init OF_UNAVAILABLE;
#ifdef OF_HAVE_UNAVAILABLE
- (instancetype)initWithBytes: (const void *)bytes
objCType: (const char *)objCType OF_UNAVAILABLE;
- (instancetype)initWithPointer: (const void *)pointer OF_UNAVAILABLE;
- (instancetype)initWithNonretainedObject: (id)object OF_UNAVAILABLE;
- (instancetype)initWithRange: (of_range_t)range OF_UNAVAILABLE;
- (instancetype)initWithPoint: (of_point_t)point OF_UNAVAILABLE;
- (instancetype)initWithDimension: (of_dimension_t)dimension OF_UNAVAILABLE;
- (instancetype)initWithRectangle: (of_rectangle_t)rectangle OF_UNAVAILABLE;
#endif
/*!
* @brief Initializes an already allocated OFNumber with the specified `bool`.
*
* @param bool_ A `bool` which the OFNumber should contain
* @param value The `bool` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithBool: (bool)bool_;
- (instancetype)initWithBool: (bool)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `signed char`.
*
* @param sChar A `signed char` which the OFNumber should contain
* @param value The `signed char` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithChar: (signed char)sChar;
- (instancetype)initWithChar: (signed char)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified `short`.
*
* @param sShort A `short` which the OFNumber should contain
* @param value The `short` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithShort: (short)sShort;
- (instancetype)initWithShort: (short)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified `int`.
*
* @param sInt An `int` which the OFNumber should contain
* @param value The `int` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithInt: (int)sInt;
- (instancetype)initWithInt: (int)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified `long`.
*
* @param sLong A `long` which the OFNumber should contain
* @param value The `long` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithLong: (long)sLong;
- (instancetype)initWithLong: (long)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `long long`.
*
* @param sLongLong A `long long` which the OFNumber should contain
* @param value The `long long` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithLongLong: (long long)sLongLong;
- (instancetype)initWithLongLong: (long long)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `unsigned char`.
*
* @param uChar An `unsigned char` which the OFNumber should contain
* @param value The `unsigned char` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedChar: (unsigned char)uChar;
- (instancetype)initWithUnsignedChar: (unsigned char)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `unsigned short`.
*
* @param uShort An `unsigned short` which the OFNumber should contain
* @param value The `unsigned short` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedShort: (unsigned short)uShort;
- (instancetype)initWithUnsignedShort: (unsigned short)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `unsigned int`.
*
* @param uInt An `unsigned int` which the OFNumber should contain
* @param value The `unsigned int` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedInt: (unsigned int)uInt;
- (instancetype)initWithUnsignedInt: (unsigned int)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `unsigned long`.
*
* @param uLong An `unsigned long` which the OFNumber should contain
* @param value The `unsigned long` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedLong: (unsigned long)uLong;
- (instancetype)initWithUnsignedLong: (unsigned long)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `unsigned long long`.
*
* @param uLongLong An `unsigned long long` which the OFNumber should contain
* @param value The `unsigned long long` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong;
- (instancetype)initWithUnsignedLongLong: (unsigned long long)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified `int8_t`.
*
* @param int8 An `int8_t` which the OFNumber should contain
* @param value The `int8_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithInt8: (int8_t)int8;
- (instancetype)initWithInt8: (int8_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `int16_t`.
*
* @param int16 An `int16_t` which the OFNumber should contain
* @param value The `int16_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithInt16: (int16_t)int16;
- (instancetype)initWithInt16: (int16_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `int32_t`.
*
* @param int32 An `int32_t` which the OFNumber should contain
* @param value The `int32_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithInt32: (int32_t)int32;
- (instancetype)initWithInt32: (int32_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `int64_t`.
*
* @param int64 An `int64_t` which the OFNumber should contain
* @param value The `int64_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithInt64: (int64_t)int64;
- (instancetype)initWithInt64: (int64_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `uint8_t`.
*
* @param uInt8 A `uint8_t` which the OFNumber should contain
* @param value The `uint8_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt8: (uint8_t)uInt8;
- (instancetype)initWithUInt8: (uint8_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `uint16_t`.
*
* @param uInt16 A `uint16_t` which the OFNumber should contain
* @param value The `uint16_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt16: (uint16_t)uInt16;
- (instancetype)initWithUInt16: (uint16_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `uint32_t`.
*
* @param uInt32 A `uint32_t` which the OFNumber should contain
* @param value The `uint32_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt32: (uint32_t)uInt32;
- (instancetype)initWithUInt32: (uint32_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `uint64_t`.
*
* @param uInt64 A `uint64_t` which the OFNumber should contain
* @param value The `uint64_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt64: (uint64_t)uInt64;
- (instancetype)initWithUInt64: (uint64_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified `size_t`.
*
* @param size A `size_t` which the OFNumber should contain
* @param value The `size_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithSize: (size_t)size;
- (instancetype)initWithSize: (size_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `ssize_t`.
*
* @param sSize An `ssize_t` which the OFNumber should contain
* @param value The `ssize_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithSSize: (ssize_t)sSize;
- (instancetype)initWithSSize: (ssize_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `intmax_t`.
*
* @param intMax An `intmax_t` which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithIntMax: (intmax_t)intMax;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `uintmax_t`.
*
* @param uIntMax A `uintmax_t` which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUIntMax: (uintmax_t)uIntMax;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `ptrdiff_t`.
*
* @param ptrDiff A `ptrdiff_t` which the OFNumber should contain
* @param value The `ptrdiff_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff;
- (instancetype)initWithPtrDiff: (ptrdiff_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `intptr_t`.
*
* @param intPtr An `intptr_t` which the OFNumber should contain
* @param value The `intptr_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithIntPtr: (intptr_t)intPtr;
- (instancetype)initWithIntPtr: (intptr_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* `uintptr_t`.
*
* @param uIntPtr A `uintptr_t` which the OFNumber should contain
* @param value The `uintptr_t` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr;
- (instancetype)initWithUIntPtr: (uintptr_t)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified `float`.
*
* @param float_ A `float` which the OFNumber should contain
* @param value The `float` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithFloat: (float)float_;
- (instancetype)initWithFloat: (float)value;
/*!
* @brief Initializes an already allocated OFNumber with the specified `double`.
*
* @param double_ A `double` which the OFNumber should contain
* @param value The `double` value which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithDouble: (double)double_;
- (instancetype)initWithDouble: (double)value;
@end
OF_ASSUME_NONNULL_END
#if !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
/* Required for number literals to work */
@compatibility_alias NSNumber OFNumber;
#endif
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
+
-
-
-
-
+
+
-
+
-
+
-
-
+
+
-
-
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
-
+
+
-
-
-
+
+
-
+
-
+
-
-
-
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
-
+
-
+
-
-
+
+
-
-
-
+
-
+
-
-
-
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
|
static void
initFalseNumber(void)
{
falseNumber = [[OFNumberSingleton alloc] initWithBool: false];
}
@implementation OFNumberPlaceholder
- (instancetype)initWithBool: (bool)bool_
- (instancetype)initWithBool: (bool)value
{
if (bool_) {
if (value) {
static of_once_t once;
of_once(&once, initTrueNumber);
return (id)trueNumber;
} else {
static of_once_t once;
of_once(&once, initFalseNumber);
return (id)falseNumber;
}
}
- (instancetype)initWithChar: (signed char)sChar
- (instancetype)initWithChar: (signed char)value
{
if (sChar >= 0)
return [self initWithUnsignedChar: sChar];
if (value >= 0)
return [self initWithUnsignedChar: value];
return (id)[[OFNumber of_alloc] initWithChar: sChar];
return (id)[[OFNumber of_alloc] initWithChar: value];
}
- (instancetype)initWithShort: (short)sShort
- (instancetype)initWithShort: (short)value
{
if (sShort >= 0)
return [self initWithUnsignedShort: sShort];
if (sShort >= SCHAR_MIN)
return [self initWithChar: (signed char)sShort];
if (value >= 0)
return [self initWithUnsignedShort: value];
if (value >= SCHAR_MIN)
return [self initWithChar: (signed char)value];
return (id)[[OFNumber of_alloc] initWithShort: sShort];
return (id)[[OFNumber of_alloc] initWithShort: value];
}
- (instancetype)initWithInt: (int)sInt
- (instancetype)initWithInt: (int)value
{
if (sInt >= 0)
return [self initWithUnsignedInt: sInt];
if (sInt >= SHRT_MIN)
return [self initWithShort: (short)sInt];
if (value >= 0)
return [self initWithUnsignedInt: value];
if (value >= SHRT_MIN)
return [self initWithShort: (short)value];
return (id)[[OFNumber of_alloc] initWithInt: sInt];
return (id)[[OFNumber of_alloc] initWithInt: value];
}
- (instancetype)initWithLong: (long)sLong
- (instancetype)initWithLong: (long)value
{
if (sLong >= 0)
return [self initWithUnsignedLong: sLong];
if (sLong >= INT_MIN)
return [self initWithShort: (int)sLong];
if (value >= 0)
return [self initWithUnsignedLong: value];
if (value >= INT_MIN)
return [self initWithShort: (int)value];
return (id)[[OFNumber of_alloc] initWithLong: sLong];
return (id)[[OFNumber of_alloc] initWithLong: value];
}
- (instancetype)initWithLongLong: (long long)sLongLong
- (instancetype)initWithLongLong: (long long)value
{
if (sLongLong >= 0)
return [self initWithUnsignedLongLong: sLongLong];
if (sLongLong >= LONG_MIN)
return [self initWithLong: (long)sLongLong];
if (value >= 0)
return [self initWithUnsignedLongLong: value];
if (value >= LONG_MIN)
return [self initWithLong: (long)value];
return (id)[[OFNumber of_alloc] initWithLongLong: sLongLong];
return (id)[[OFNumber of_alloc] initWithLongLong: value];
}
- (instancetype)initWithUnsignedChar: (unsigned char)uChar
- (instancetype)initWithUnsignedChar: (unsigned char)value
{
switch (uChar) {
switch (value) {
case 0: {
static of_once_t once = OF_ONCE_INIT;
of_once(&once, initZeroNumber);
return (id)zeroNumber;
}
case 1: {
static of_once_t once = OF_ONCE_INIT;
of_once(&once, initOneNumber);
return (id)oneNumber;
}
case 2: {
static of_once_t once = OF_ONCE_INIT;
of_once(&once, initTwoNumber);
return (id)twoNumber;
}
}
return (id)[[OFNumber of_alloc] initWithUnsignedChar: uChar];
return (id)[[OFNumber of_alloc] initWithUnsignedChar: value];
}
- (instancetype)initWithUnsignedShort: (unsigned short)uShort
- (instancetype)initWithUnsignedShort: (unsigned short)value
{
if (uShort <= UCHAR_MAX)
return [self initWithUnsignedChar: (unsigned char)uShort];
if (value <= UCHAR_MAX)
return [self initWithUnsignedChar: (unsigned char)value];
return (id)[[OFNumber of_alloc] initWithUnsignedShort: uShort];
return (id)[[OFNumber of_alloc] initWithUnsignedShort: value];
}
- (instancetype)initWithUnsignedInt: (unsigned int)uInt
- (instancetype)initWithUnsignedInt: (unsigned int)value
{
if (uInt <= USHRT_MAX)
return [self initWithUnsignedShort: (unsigned short)uInt];
if (value <= USHRT_MAX)
return [self initWithUnsignedShort: (unsigned short)value];
return (id)[[OFNumber of_alloc] initWithUnsignedInt: uInt];
return (id)[[OFNumber of_alloc] initWithUnsignedInt: value];
}
- (instancetype)initWithUnsignedLong: (unsigned long)uLong
- (instancetype)initWithUnsignedLong: (unsigned long)value
{
if (uLong <= UINT_MAX)
return [self initWithUnsignedInt: (unsigned int)uLong];
if (value <= UINT_MAX)
return [self initWithUnsignedInt: (unsigned int)value];
return (id)[[OFNumber of_alloc] initWithUnsignedLong: uLong];
return (id)[[OFNumber of_alloc] initWithUnsignedLong: value];
}
- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong
- (instancetype)initWithUnsignedLongLong: (unsigned long long)value
{
if (uLongLong <= ULONG_MAX)
return [self initWithUnsignedLong: (unsigned long)uLongLong];
return (id)[[OFNumber of_alloc] initWithUnsignedLongLong: uLongLong];
}
{
- (instancetype)initWithInt8: (int8_t)int8
{
if (int8 >= 0)
return [self initWithUInt8: int8];
if (value <= ULONG_MAX)
return [self initWithUnsignedLong: (unsigned long)value];
return (id)[[OFNumber of_alloc] initWithInt8: int8];
return (id)[[OFNumber of_alloc] initWithUnsignedLongLong: value];
}
- (instancetype)initWithInt16: (int16_t)int16
- (instancetype)initWithInt8: (int8_t)value
{
if (int16 >= 0)
return [self initWithUInt16: int16];
if (value >= 0)
return [self initWithUInt8: value];
if (int16 >= INT8_MIN)
return [self initWithInt8: (int8_t)int16];
return (id)[[OFNumber of_alloc] initWithInt16: int16];
return (id)[[OFNumber of_alloc] initWithInt8: value];
}
- (instancetype)initWithInt32: (int32_t)int32
- (instancetype)initWithInt16: (int16_t)value
{
if (int32 >= 0)
return [self initWithUInt32: int32];
if (int32 >= INT16_MIN)
return [self initWithInt16: (int16_t)int32];
if (value >= 0)
return [self initWithUInt16: value];
if (value >= INT8_MIN)
return [self initWithInt8: (int8_t)value];
return (id)[[OFNumber of_alloc] initWithInt32: int32];
return (id)[[OFNumber of_alloc] initWithInt16: value];
}
- (instancetype)initWithInt64: (int64_t)int64
- (instancetype)initWithInt32: (int32_t)value
{
if (int64 >= 0)
return [self initWithUInt64: int64];
if (int64 >= INT32_MIN)
return [self initWithInt32: (int32_t)int64];
if (value >= 0)
return [self initWithUInt32: value];
if (value >= INT16_MIN)
return [self initWithInt16: (int16_t)value];
return (id)[[OFNumber of_alloc] initWithInt64: int64];
return (id)[[OFNumber of_alloc] initWithInt32: value];
}
- (instancetype)initWithUInt8: (uint8_t)uInt8
- (instancetype)initWithInt64: (int64_t)value
{
return (id)[[OFNumber of_alloc] initWithUInt8: uInt8];
}
- (instancetype)initWithUInt16: (uint16_t)uInt16
if (value >= 0)
return [self initWithUInt64: value];
{
if (uInt16 <= UINT8_MAX)
return [self initWithUInt8: (uint8_t)uInt16];
if (value >= INT32_MIN)
return [self initWithInt32: (int32_t)value];
return (id)[[OFNumber of_alloc] initWithUInt16: uInt16];
return (id)[[OFNumber of_alloc] initWithInt64: value];
}
- (instancetype)initWithUInt32: (uint32_t)uInt32
- (instancetype)initWithUInt8: (uint8_t)value
{
if (uInt32 <= UINT16_MAX)
return [self initWithUInt16: (uint16_t)uInt32];
return (id)[[OFNumber of_alloc] initWithUInt32: uInt32];
return (id)[[OFNumber of_alloc] initWithUInt8: value];
}
- (instancetype)initWithUInt64: (uint64_t)uInt64
- (instancetype)initWithUInt16: (uint16_t)value
{
if (uInt64 <= UINT32_MAX)
return [self initWithUInt32: (uint32_t)uInt64];
if (value <= UINT8_MAX)
return [self initWithUInt8: (uint8_t)value];
return (id)[[OFNumber of_alloc] initWithUInt64: uInt64];
return (id)[[OFNumber of_alloc] initWithUInt16: value];
}
- (instancetype)initWithSize: (size_t)size
- (instancetype)initWithUInt32: (uint32_t)value
{
if (size <= ULONG_MAX)
return [self initWithUnsignedLong: (unsigned long)size];
if (value <= UINT16_MAX)
return [self initWithUInt16: (uint16_t)value];
return (id)[[OFNumber of_alloc] initWithSize: size];
return (id)[[OFNumber of_alloc] initWithUInt32: value];
}
- (instancetype)initWithSSize: (ssize_t)sSize
- (instancetype)initWithUInt64: (uint64_t)value
{
if (sSize >= 0)
return [self initWithSize: sSize];
if (value <= UINT32_MAX)
return [self initWithUInt32: (uint32_t)value];
if (sSize <= LONG_MIN)
return [self initWithLong: (long)sSize];
return (id)[[OFNumber of_alloc] initWithSSize: sSize];
return (id)[[OFNumber of_alloc] initWithUInt64: value];
}
- (instancetype)initWithIntMax: (intmax_t)intMax
- (instancetype)initWithSize: (size_t)value
{
if (intMax >= 0)
return [self initWithUIntMax: intMax];
if (value <= ULONG_MAX)
return [self initWithUnsignedLong: (unsigned long)value];
if (intMax <= LLONG_MIN)
return [self initWithLongLong: (long long)intMax];
return (id)[[OFNumber of_alloc] initWithIntMax: intMax];
return (id)[[OFNumber of_alloc] initWithSize: value];
}
- (instancetype)initWithUIntMax: (uintmax_t)uIntMax
- (instancetype)initWithSSize: (ssize_t)value
{
if (uIntMax <= ULLONG_MAX)
return [self initWithUnsignedLongLong:
(unsigned long long)uIntMax];
if (value >= 0)
return [self initWithSize: value];
if (value <= LONG_MIN)
return [self initWithLong: (long)value];
return (id)[[OFNumber of_alloc] initWithUIntMax: uIntMax];
return (id)[[OFNumber of_alloc] initWithSSize: value];
}
#ifdef __clang__
/*
* This warning should probably not exist at all, as it prevents checking
* whether one type fits into another in a portable way.
*/
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
#endif
- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff
- (instancetype)initWithPtrDiff: (ptrdiff_t)value
{
if (ptrDiff >= LLONG_MIN && ptrDiff <= LLONG_MAX)
return [self initWithLongLong: (long long)ptrDiff];
if (value >= LLONG_MIN && value <= LLONG_MAX)
return [self initWithLongLong: (long long)value];
return (id)[[OFNumber of_alloc] initWithPtrDiff: ptrDiff];
return (id)[[OFNumber of_alloc] initWithPtrDiff: value];
}
- (instancetype)initWithIntPtr: (intptr_t)intPtr
- (instancetype)initWithIntPtr: (intptr_t)value
{
if (intPtr >= 0)
return [self initWithUIntPtr: intPtr];
if (intPtr >= LLONG_MIN)
return [self initWithLongLong: (long long)intPtr];
if (value >= 0)
return [self initWithUIntPtr: value];
if (value >= LLONG_MIN)
return [self initWithLongLong: (long long)value];
return (id)[[OFNumber of_alloc] initWithIntPtr: intPtr];
return (id)[[OFNumber of_alloc] initWithIntPtr: value];
}
- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr
- (instancetype)initWithUIntPtr: (uintptr_t)value
{
if (uIntPtr <= ULLONG_MAX)
if (value <= ULLONG_MAX)
return [self initWithUnsignedLongLong:
(unsigned long long)uIntPtr];
(unsigned long long)value];
return (id)[[OFNumber of_alloc] initWithUIntPtr: uIntPtr];
return (id)[[OFNumber of_alloc] initWithUIntPtr: value];
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
- (instancetype)initWithFloat: (float)float_
- (instancetype)initWithFloat: (float)value
{
if (float_ == (uintmax_t)float_)
return [self initWithUIntMax: (uintmax_t)float_];
if (float_ == (intmax_t)float_)
return [self initWithIntMax: (intmax_t)float_];
if (value == (unsigned long long)value)
return [self initWithUnsignedLongLong:
(unsigned long long)value];
if (value == (long long)value)
return [self initWithLongLong: (long long)value];
return (id)[[OFNumber of_alloc] initWithFloat: float_];
return (id)[[OFNumber of_alloc] initWithFloat: value];
}
- (instancetype)initWithDouble: (double)double_
- (instancetype)initWithDouble: (double)value
{
if (double_ == (uintmax_t)double_)
return [self initWithUIntMax: (uintmax_t)double_];
if (double_ == (intmax_t)double_)
return [self initWithIntMax: (intmax_t)double_];
if (double_ == (float)double_)
return [self initWithFloat: (float)double_];
if (value == (unsigned long long)value)
return [self initWithUnsignedLongLong:
(unsigned long long)value];
if (value == (long long)value)
return [self initWithLongLong: (long long)value];
if (value == (float)value)
return [self initWithFloat: (float)value];
return (id)[[OFNumber of_alloc] initWithDouble: double_];
return (id)[[OFNumber of_alloc] initWithDouble: value];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFNumber of_alloc] initWithSerialization: element];
}
@end
|
︙ | | |
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
|
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
+
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
{
if (self == [OFNumber class])
return (id)&placeholder;
return [super alloc];
}
+ (instancetype)numberWithBool: (bool)bool_
+ (instancetype)numberWithBool: (bool)value
{
return [[[self alloc] initWithBool: bool_] autorelease];
return [[[self alloc] initWithBool: value] autorelease];
}
+ (instancetype)numberWithChar: (signed char)sChar
+ (instancetype)numberWithChar: (signed char)value
{
return [[[self alloc] initWithChar: sChar] autorelease];
return [[[self alloc] initWithChar: value] autorelease];
}
+ (instancetype)numberWithShort: (short)sShort
+ (instancetype)numberWithShort: (short)value
{
return [[[self alloc] initWithShort: sShort] autorelease];
return [[[self alloc] initWithShort: value] autorelease];
}
+ (instancetype)numberWithInt: (int)sInt
+ (instancetype)numberWithInt: (int)value
{
return [[[self alloc] initWithInt: sInt] autorelease];
return [[[self alloc] initWithInt: value] autorelease];
}
+ (instancetype)numberWithLong: (long)sLong
+ (instancetype)numberWithLong: (long)value
{
return [[[self alloc] initWithLong: sLong] autorelease];
return [[[self alloc] initWithLong: value] autorelease];
}
+ (instancetype)numberWithLongLong: (long long)sLongLong
+ (instancetype)numberWithLongLong: (long long)value
{
return [[[self alloc] initWithLongLong: sLongLong] autorelease];
return [[[self alloc] initWithLongLong: value] autorelease];
}
+ (instancetype)numberWithUnsignedChar: (unsigned char)uChar
+ (instancetype)numberWithUnsignedChar: (unsigned char)value
{
return [[[self alloc] initWithUnsignedChar: uChar] autorelease];
}
{
+ (instancetype)numberWithUnsignedShort: (unsigned short)uShort
{
return [[[self alloc] initWithUnsignedShort: uShort] autorelease];
return [[[self alloc] initWithUnsignedChar: value] autorelease];
}
+ (instancetype)numberWithUnsignedInt: (unsigned int)uInt
+ (instancetype)numberWithUnsignedShort: (unsigned short)value
{
return [[[self alloc] initWithUnsignedInt: uInt] autorelease];
return [[[self alloc] initWithUnsignedShort: value] autorelease];
}
+ (instancetype)numberWithUnsignedLong: (unsigned long)uLong
+ (instancetype)numberWithUnsignedInt: (unsigned int)value
{
return [[[self alloc] initWithUnsignedLong: uLong] autorelease];
return [[[self alloc] initWithUnsignedInt: value] autorelease];
}
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)uLongLong
+ (instancetype)numberWithUnsignedLong: (unsigned long)value
{
return [[[self alloc] initWithUnsignedLongLong: uLongLong] autorelease];
return [[[self alloc] initWithUnsignedLong: value] autorelease];
}
+ (instancetype)numberWithInt8: (int8_t)int8
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)value
{
return [[[self alloc] initWithInt8: int8] autorelease];
return [[[self alloc] initWithUnsignedLongLong: value] autorelease];
}
+ (instancetype)numberWithInt16: (int16_t)int16
+ (instancetype)numberWithInt8: (int8_t)value
{
return [[[self alloc] initWithInt16: int16] autorelease];
return [[[self alloc] initWithInt8: value] autorelease];
}
+ (instancetype)numberWithInt32: (int32_t)int32
+ (instancetype)numberWithInt16: (int16_t)value
{
return [[[self alloc] initWithInt32: int32] autorelease];
return [[[self alloc] initWithInt16: value] autorelease];
}
+ (instancetype)numberWithInt64: (int64_t)int64
+ (instancetype)numberWithInt32: (int32_t)value
{
return [[[self alloc] initWithInt64: int64] autorelease];
return [[[self alloc] initWithInt32: value] autorelease];
}
+ (instancetype)numberWithUInt8: (uint8_t)uInt8
+ (instancetype)numberWithInt64: (int64_t)value
{
return [[[self alloc] initWithUInt8: uInt8] autorelease];
return [[[self alloc] initWithInt64: value] autorelease];
}
+ (instancetype)numberWithUInt16: (uint16_t)uInt16
+ (instancetype)numberWithUInt8: (uint8_t)value
{
return [[[self alloc] initWithUInt16: uInt16] autorelease];
return [[[self alloc] initWithUInt8: value] autorelease];
}
+ (instancetype)numberWithUInt32: (uint32_t)uInt32
+ (instancetype)numberWithUInt16: (uint16_t)value
{
return [[[self alloc] initWithUInt32: uInt32] autorelease];
return [[[self alloc] initWithUInt16: value] autorelease];
}
+ (instancetype)numberWithUInt64: (uint64_t)uInt64
+ (instancetype)numberWithUInt32: (uint32_t)value
{
return [[[self alloc] initWithUInt64: uInt64] autorelease];
return [[[self alloc] initWithUInt32: value] autorelease];
}
+ (instancetype)numberWithSize: (size_t)size
+ (instancetype)numberWithUInt64: (uint64_t)value
{
return [[[self alloc] initWithSize: size] autorelease];
return [[[self alloc] initWithUInt64: value] autorelease];
}
+ (instancetype)numberWithSSize: (ssize_t)sSize
{
return [[[self alloc] initWithSSize: sSize] autorelease];
}
+ (instancetype)numberWithIntMax: (intmax_t)intMax
+ (instancetype)numberWithSize: (size_t)value
{
return [[[self alloc] initWithIntMax: intMax] autorelease];
return [[[self alloc] initWithSize: value] autorelease];
}
+ (instancetype)numberWithUIntMax: (uintmax_t)uIntMax
+ (instancetype)numberWithSSize: (ssize_t)value
{
return [[[self alloc] initWithUIntMax: uIntMax] autorelease];
return [[[self alloc] initWithSSize: value] autorelease];
}
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrDiff
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)value
{
return [[[self alloc] initWithPtrDiff: ptrDiff] autorelease];
return [[[self alloc] initWithPtrDiff: value] autorelease];
}
+ (instancetype)numberWithIntPtr: (intptr_t)intPtr
+ (instancetype)numberWithIntPtr: (intptr_t)value
{
return [[[self alloc] initWithIntPtr: intPtr] autorelease];
return [[[self alloc] initWithIntPtr: value] autorelease];
}
+ (instancetype)numberWithUIntPtr: (uintptr_t)uIntPtr
+ (instancetype)numberWithUIntPtr: (uintptr_t)value
{
return [[[self alloc] initWithUIntPtr: uIntPtr] autorelease];
return [[[self alloc] initWithUIntPtr: value] autorelease];
}
+ (instancetype)numberWithFloat: (float)float_
+ (instancetype)numberWithFloat: (float)value
{
return [[[self alloc] initWithFloat: float_] autorelease];
return [[[self alloc] initWithFloat: value] autorelease];
}
+ (instancetype)numberWithDouble: (double)double_
+ (instancetype)numberWithDouble: (double)value
{
return [[[self alloc] initWithDouble: double_] autorelease];
return [[[self alloc] initWithDouble: value] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithBool: (bool)bool_
- (instancetype)initWithBool: (bool)value
{
self = [super init];
_value.unsigned_ = bool_;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(bool);
return self;
}
- (instancetype)initWithChar: (signed char)sChar
- (instancetype)initWithChar: (signed char)value
{
self = [super init];
_value.signed_ = sChar;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(signed char);
return self;
}
- (instancetype)initWithShort: (short)sShort
- (instancetype)initWithShort: (short)value
{
self = [super init];
_value.signed_ = sShort;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(short);
return self;
}
- (instancetype)initWithInt: (int)sInt
- (instancetype)initWithInt: (int)value
{
self = [super init];
_value.signed_ = sInt;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(int);
return self;
}
- (instancetype)initWithLong: (long)sLong
- (instancetype)initWithLong: (long)value
{
self = [super init];
_value.signed_ = sLong;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(long);
return self;
}
- (instancetype)initWithLongLong: (long long)sLongLong
- (instancetype)initWithLongLong: (long long)value
{
self = [super init];
_value.signed_ = sLongLong;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(long long);
return self;
}
- (instancetype)initWithUnsignedChar: (unsigned char)uChar
- (instancetype)initWithUnsignedChar: (unsigned char)value
{
self = [super init];
_value.unsigned_ = uChar;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(unsigned long);
return self;
}
- (instancetype)initWithUnsignedShort: (unsigned short)uShort
- (instancetype)initWithUnsignedShort: (unsigned short)value
{
self = [super init];
_value.unsigned_ = uShort;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(unsigned short);
return self;
}
- (instancetype)initWithUnsignedInt: (unsigned int)uInt
- (instancetype)initWithUnsignedInt: (unsigned int)value
{
self = [super init];
_value.unsigned_ = uInt;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(unsigned int);
return self;
}
- (instancetype)initWithUnsignedLong: (unsigned long)uLong
- (instancetype)initWithUnsignedLong: (unsigned long)value
{
self = [super init];
_value.unsigned_ = uLong;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(unsigned long);
return self;
}
- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong
- (instancetype)initWithUnsignedLongLong: (unsigned long long)value
{
self = [super init];
_value.unsigned_ = uLongLong;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(unsigned long long);
return self;
}
- (instancetype)initWithInt8: (int8_t)int8
- (instancetype)initWithInt8: (int8_t)value
{
self = [super init];
_value.signed_ = int8;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(int8_t);
return self;
}
- (instancetype)initWithInt16: (int16_t)int16
- (instancetype)initWithInt16: (int16_t)value
{
self = [super init];
_value.signed_ = int16;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(int16_t);
return self;
}
- (instancetype)initWithInt32: (int32_t)int32
- (instancetype)initWithInt32: (int32_t)value
{
self = [super init];
_value.signed_ = int32;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(int32_t);
return self;
}
- (instancetype)initWithInt64: (int64_t)int64
- (instancetype)initWithInt64: (int64_t)value
{
self = [super init];
_value.signed_ = int64;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(int64_t);
return self;
}
- (instancetype)initWithUInt8: (uint8_t)uInt8
- (instancetype)initWithUInt8: (uint8_t)value
{
self = [super init];
_value.unsigned_ = uInt8;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(uint8_t);
return self;
}
- (instancetype)initWithUInt16: (uint16_t)uInt16
- (instancetype)initWithUInt16: (uint16_t)value
{
self = [super init];
_value.unsigned_ = uInt16;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(uint16_t);
return self;
}
- (instancetype)initWithUInt32: (uint32_t)uInt32
- (instancetype)initWithUInt32: (uint32_t)value
{
self = [super init];
_value.unsigned_ = uInt32;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(uint32_t);
return self;
}
- (instancetype)initWithUInt64: (uint64_t)uInt64
- (instancetype)initWithUInt64: (uint64_t)value
{
self = [super init];
_value.unsigned_ = uInt64;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(uint64_t);
return self;
}
- (instancetype)initWithSize: (size_t)size
- (instancetype)initWithSize: (size_t)value
{
self = [super init];
_value.unsigned_ = size;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(size_t);
return self;
}
- (instancetype)initWithSSize: (ssize_t)sSize
- (instancetype)initWithSSize: (ssize_t)value
{
self = [super init];
_value.signed_ = sSize;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(ssize_t);
return self;
}
- (instancetype)initWithIntMax: (intmax_t)intMax
{
self = [super init];
_value.signed_ = intMax;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(intmax_t);
return self;
}
- (instancetype)initWithUIntMax: (uintmax_t)uIntMax
{
self = [super init];
_value.unsigned_ = uIntMax;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(uintmax_t);
return self;
}
- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff
- (instancetype)initWithPtrDiff: (ptrdiff_t)value
{
self = [super init];
_value.signed_ = ptrDiff;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(ptrdiff_t);
return self;
}
- (instancetype)initWithIntPtr: (intptr_t)intPtr
- (instancetype)initWithIntPtr: (intptr_t)value
{
self = [super init];
_value.signed_ = intPtr;
_value.signed_ = value;
_type = OF_NUMBER_TYPE_SIGNED;
_typeEncoding = @encode(intptr_t);
return self;
}
- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr
- (instancetype)initWithUIntPtr: (uintptr_t)value
{
self = [super init];
_value.unsigned_ = uIntPtr;
_value.unsigned_ = value;
_type = OF_NUMBER_TYPE_UNSIGNED;
_typeEncoding = @encode(uintptr_t);
return self;
}
- (instancetype)initWithFloat: (float)float_
- (instancetype)initWithFloat: (float)value
{
self = [super init];
_value.float_ = float_;
_value.float_ = value;
_type = OF_NUMBER_TYPE_FLOAT;
_typeEncoding = @encode(float);
return self;
}
- (instancetype)initWithDouble: (double)double_
- (instancetype)initWithDouble: (double)value
{
self = [super init];
_value.float_ = double_;
_value.float_ = value;
_type = OF_NUMBER_TYPE_FLOAT;
_typeEncoding = @encode(double);
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
|
︙ | | |
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
|
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
|
-
-
-
-
-
-
-
-
-
-
|
}
- (ssize_t)sSizeValue
{
RETURN_AS(ssize_t)
}
- (intmax_t)intMaxValue
{
RETURN_AS(intmax_t)
}
- (uintmax_t)uIntMaxValue
{
RETURN_AS(uintmax_t)
}
- (ptrdiff_t)ptrDiffValue
{
RETURN_AS(ptrdiff_t)
}
- (intptr_t)intPtrValue
{
|
︙ | | |
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
|
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
|
-
+
-
+
|
return false;
return (value1 == value2);
}
if (_type == OF_NUMBER_TYPE_SIGNED ||
number->_type == OF_NUMBER_TYPE_SIGNED)
return (number.intMaxValue == self.intMaxValue);
return (number.longLongValue == self.longLongValue);
return (number.uIntMaxValue == self.uIntMaxValue);
return (number.unsignedLongLongValue == self.unsignedLongLongValue);
}
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
OFNumber *number;
if (![(id)object isKindOfClass: [OFNumber class]])
|
︙ | | |
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
|
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
|
-
-
+
+
-
-
+
+
|
return OF_ORDERED_DESCENDING;
if (double1 < double2)
return OF_ORDERED_ASCENDING;
return OF_ORDERED_SAME;
} else if (_type == OF_NUMBER_TYPE_SIGNED ||
number->_type == OF_NUMBER_TYPE_SIGNED) {
intmax_t int1 = self.intMaxValue;
intmax_t int2 = number.intMaxValue;
long long int1 = self.longLongValue;
long long int2 = number.longLongValue;
if (int1 > int2)
return OF_ORDERED_DESCENDING;
if (int1 < int2)
return OF_ORDERED_ASCENDING;
return OF_ORDERED_SAME;
} else {
uintmax_t uint1 = self.uIntMaxValue;
uintmax_t uint2 = number.uIntMaxValue;
unsigned long long uint1 = self.unsignedLongLongValue;
unsigned long long uint2 = number.unsignedLongLongValue;
if (uint1 > uint2)
return OF_ORDERED_DESCENDING;
if (uint1 < uint2)
return OF_ORDERED_ASCENDING;
return OF_ORDERED_SAME;
|
︙ | | |
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
|
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
|
-
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
|
return 0;
d = OF_BSWAP_DOUBLE_IF_BE(self.doubleValue);
for (uint_fast8_t i = 0; i < sizeof(double); i++)
OF_HASH_ADD(hash, ((char *)&d)[i]);
} else if (type == OF_NUMBER_TYPE_SIGNED) {
intmax_t v = self.intMaxValue * -1;
long long value = self.longLongValue * -1;
while (v != 0) {
OF_HASH_ADD(hash, v & 0xFF);
v >>= 8;
while (value != 0) {
OF_HASH_ADD(hash, value & 0xFF);
value >>= 8;
}
OF_HASH_ADD(hash, 1);
} else if (type == OF_NUMBER_TYPE_UNSIGNED) {
uintmax_t v = self.uIntMaxValue;
unsigned long long value = self.unsignedLongLongValue;
while (v != 0) {
OF_HASH_ADD(hash, v & 0xFF);
v >>= 8;
while (value != 0) {
OF_HASH_ADD(hash, value & 0xFF);
value >>= 8;
}
} else
@throw [OFInvalidFormatException exception];
OF_HASH_FINALIZE(hash);
return hash;
|
︙ | | |
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
|
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
|
-
+
-
+
|
- (OFString *)stringValue
{
if (*_typeEncoding == 'B')
return (_value.unsigned_ ? @"true" : @"false");
if (_type == OF_NUMBER_TYPE_FLOAT)
return [OFString stringWithFormat: @"%g", _value.float_];
if (_type == OF_NUMBER_TYPE_SIGNED)
return [OFString stringWithFormat: @"%jd", _value.signed_];
return [OFString stringWithFormat: @"%lld", _value.signed_];
if (_type == OF_NUMBER_TYPE_UNSIGNED)
return [OFString stringWithFormat: @"%ju", _value.unsigned_];
return [OFString stringWithFormat: @"%llu", _value.unsigned_];
@throw [OFInvalidFormatException exception];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
|
︙ | | |
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
|
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
|
-
+
|
data = [OFMutableData dataWithItemSize: 1
capacity: 9];
[data addItem: &type];
[data addItems: &tmp
count: sizeof(tmp)];
} else if (_type == OF_NUMBER_TYPE_SIGNED) {
intmax_t value = self.intMaxValue;
long long value = self.longLongValue;
if (value >= -32 && value < 0) {
uint8_t tmp = 0xE0 | ((uint8_t)(value - 32) & 0x1F);
data = [OFMutableData dataWithItems: &tmp
count: 1];
} else if (value >= INT8_MIN && value <= INT8_MAX) {
|
︙ | | |
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
|
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
|
-
+
|
[data addItem: &type];
[data addItems: &tmp
count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
} else if (_type == OF_NUMBER_TYPE_UNSIGNED) {
uintmax_t value = self.uIntMaxValue;
unsigned long long value = self.unsignedLongLongValue;
if (value <= 127) {
uint8_t tmp = ((uint8_t)value & 0x7F);
data = [OFMutableData dataWithItems: &tmp
count: 1];
} else if (value <= UINT8_MAX) {
|
︙ | | |
︙ | | |
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
-
+
|
* @brief The decimal value of the string as a `long long`.
*
* Leading and trailing whitespaces are ignored.
*
* If the string contains any non-number characters, an
* @ref OFInvalidFormatException is thrown.
*
* If the number is too big to fit into an `long long`, an
* If the number is too big to fit into a `long long`, an
* @ref OFOutOfRangeException is thrown.
*/
@property (readonly, nonatomic) long long longLongValue;
/*!
* @brief The decimal value of the string as an `unsigned long long`.
*
|
︙ | | |
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
|
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
|
-
+
|
* @brief The value of the string in the specified base as a `long long`.
*
* Leading and trailing whitespaces are ignored.
*
* If the string contains any non-number characters, an
* @ref OFInvalidFormatException is thrown.
*
* If the number is too big to fit into an `long long`, an
* If the number is too big to fit into a `long long`, an
* @ref OFOutOfRangeException is thrown.
*
* @param base The base to use. If the base is 0, base 16 is assumed if the
* string starts with 0x (after stripping white spaces). If the
* string starts with 0, base 8 is assumed. Otherwise, base 10 is
* assumed.
* @return The value of the string in the specified base
|
︙ | | |
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
|
EXPECT_EXCEPTION(@"Detection of truncated boolean",
OFTruncatedDataException, [[OFData dataWithItems: "\x01\x01"
count: 2] ASN1DERValue])
/* Integer */
TEST(@"Parsing of integer",
[[[OFData dataWithItems: "\x02\x00"
count: 2] ASN1DERValue] integerValue] == 0 &&
count: 2] ASN1DERValue] longLongValue] == 0 &&
[[[OFData dataWithItems: "\x02\x01\x01"
count: 3] ASN1DERValue] integerValue] == 1 &&
count: 3] ASN1DERValue] longLongValue] == 1 &&
[[[OFData dataWithItems: "\x02\x02\x01\x04"
count: 4] ASN1DERValue] integerValue] == 260 &&
count: 4] ASN1DERValue] longLongValue] == 260 &&
[[[OFData dataWithItems: "\x02\x01\xFF"
count: 3] ASN1DERValue] integerValue] == -1 &&
count: 3] ASN1DERValue] longLongValue] == -1 &&
[[[OFData dataWithItems: "\x02\x03\xFF\x00\x00"
count: 5] ASN1DERValue] integerValue] == -65536 &&
(uintmax_t)[[[OFData dataWithItems: "\x02\x09\x00\xFF\xFF\xFF\xFF"
"\xFF\xFF\xFF\xFF"
count: 11] ASN1DERValue]
integerValue] == UINTMAX_MAX)
count: 5] ASN1DERValue] longLongValue] ==
-65536 &&
(unsigned long long)[[[OFData dataWithItems: "\x02\x09\x00\xFF\xFF"
"\xFF\xFF\xFF\xFF\xFF"
"\xFF"
count: 11] ASN1DERValue]
longLongValue] == ULLONG_MAX)
EXPECT_EXCEPTION(@"Detection of invalid integer #1",
OFInvalidFormatException, [[OFData dataWithItems: "\x02\x02\x00\x00"
count: 4] ASN1DERValue])
EXPECT_EXCEPTION(@"Detection of invalid integer #2",
OFInvalidFormatException, [[OFData dataWithItems: "\x02\x02\x00\x7F"
|
︙ | | |
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
|
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
|
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
|
count: 3] ASN1DERValue])
/* Object Identifier */
TEST(@"Parsing of Object Identifier",
(array = [[[OFData dataWithItems: "\x06\x01\x27"
count: 3] ASN1DERValue]
subidentifiers]) && array.count == 2 &&
[[array objectAtIndex: 0] uIntMaxValue] == 0 &&
[[array objectAtIndex: 1] uIntMaxValue] == 39 &&
[[array objectAtIndex: 0] unsignedLongLongValue] == 0 &&
[[array objectAtIndex: 1] unsignedLongLongValue] == 39 &&
(array = [[[OFData dataWithItems: "\x06\x01\x4F"
count: 3] ASN1DERValue]
subidentifiers]) && array.count == 2 &&
[[array objectAtIndex: 0] uIntMaxValue] == 1 &&
[[array objectAtIndex: 1] uIntMaxValue] == 39 &&
[[array objectAtIndex: 0] unsignedLongLongValue] == 1 &&
[[array objectAtIndex: 1] unsignedLongLongValue] == 39 &&
(array = [[[OFData dataWithItems: "\x06\x02\x88\x37"
count: 4] ASN1DERValue]
subidentifiers]) && array.count == 2 &&
[[array objectAtIndex: 0] uIntMaxValue] == 2 &&
[[array objectAtIndex: 1] uIntMaxValue] == 999 &&
[[array objectAtIndex: 0] unsignedLongLongValue] == 2 &&
[[array objectAtIndex: 1] unsignedLongLongValue] == 999 &&
(array = [[[OFData dataWithItems: "\x06\x09\x2A\x86\x48\x86\xF7\x0D"
"\x01\x01\x0B"
count: 11] ASN1DERValue]
subidentifiers]) && array.count == 7 &&
[[array objectAtIndex: 0] uIntMaxValue] == 1 &&
[[array objectAtIndex: 1] uIntMaxValue] == 2 &&
[[array objectAtIndex: 2] uIntMaxValue] == 840 &&
[[array objectAtIndex: 3] uIntMaxValue] == 113549 &&
[[array objectAtIndex: 4] uIntMaxValue] == 1 &&
[[array objectAtIndex: 5] uIntMaxValue] == 1 &&
[[array objectAtIndex: 6] uIntMaxValue] == 11)
[[array objectAtIndex: 0] unsignedLongLongValue] == 1 &&
[[array objectAtIndex: 1] unsignedLongLongValue] == 2 &&
[[array objectAtIndex: 2] unsignedLongLongValue] == 840 &&
[[array objectAtIndex: 3] unsignedLongLongValue] == 113549 &&
[[array objectAtIndex: 4] unsignedLongLongValue] == 1 &&
[[array objectAtIndex: 5] unsignedLongLongValue] == 1 &&
[[array objectAtIndex: 6] unsignedLongLongValue] == 11)
EXPECT_EXCEPTION(@"Detection of invalid Object Identifier #1",
OFInvalidFormatException, [[OFData dataWithItems: "\x06\x01\x81"
count: 3] ASN1DERValue])
EXPECT_EXCEPTION(@"Detection of invalid Object Identifier #2",
OFInvalidFormatException, [[OFData dataWithItems: "\x06\x02\x80\x01"
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
|
EXPECT_EXCEPTION(@"Detection of truncated Object Identifier",
OFTruncatedDataException, [[OFData dataWithItems: "\x06\x02\x00"
count: 3] ASN1DERValue])
/* Enumerated */
TEST(@"Parsing of enumerated",
[[[OFData dataWithItems: "\x0A\x00"
count: 2] ASN1DERValue] integerValue] == 0 &&
count: 2] ASN1DERValue] longLongValue] == 0 &&
[[[OFData dataWithItems: "\x0A\x01\x01"
count: 3] ASN1DERValue] integerValue] == 1 &&
count: 3] ASN1DERValue] longLongValue] == 1 &&
[[[OFData dataWithItems: "\x0A\x02\x01\x04"
count: 4] ASN1DERValue] integerValue] == 260 &&
count: 4] ASN1DERValue] longLongValue] == 260 &&
[[[OFData dataWithItems: "\x0A\x01\xFF"
count: 3] ASN1DERValue] integerValue] == -1 &&
count: 3] ASN1DERValue] longLongValue] == -1 &&
[[[OFData dataWithItems: "\x0A\x03\xFF\x00\x00"
count: 5] ASN1DERValue] integerValue] == -65536 &&
(uintmax_t)[[[OFData dataWithItems: "\x0A\x09\x00\xFF\xFF\xFF\xFF"
"\xFF\xFF\xFF\xFF"
count: 11] ASN1DERValue]
integerValue] == UINTMAX_MAX)
count: 5] ASN1DERValue] longLongValue] ==
-65536 &&
(unsigned long long)[[[OFData dataWithItems: "\x0A\x09\x00\xFF\xFF"
"\xFF\xFF\xFF\xFF\xFF"
"\xFF"
count: 11] ASN1DERValue]
longLongValue] == ULLONG_MAX)
EXPECT_EXCEPTION(@"Detection of invalid enumerated #1",
OFInvalidFormatException, [[OFData dataWithItems: "\x0A\x02\x00\x00"
count: 4] ASN1DERValue])
EXPECT_EXCEPTION(@"Detection of invalid enumerated #2",
OFInvalidFormatException, [[OFData dataWithItems: "\x0A\x02\x00\x7F"
|
︙ | | |
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
|
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
|
-
+
-
+
|
TEST(@"Parsing of sequence",
(array = [[OFData dataWithItems: "\x30\x00"
count: 2] ASN1DERValue]) &&
[array isKindOfClass: [OFArray class]] && array.count == 0 &&
(array = [[OFData dataWithItems: "\x30\x09\x02\x01\x7B\x0C\x04Test"
count: 11] ASN1DERValue]) &&
[array isKindOfClass: [OFArray class]] && array.count == 2 &&
[[array objectAtIndex: 0] integerValue] == 123 &&
[[array objectAtIndex: 0] longLongValue] == 123 &&
[[[array objectAtIndex: 1] stringValue] isEqual: @"Test"])
EXPECT_EXCEPTION(@"Detection of truncated sequence #1",
OFTruncatedDataException, [[OFData dataWithItems: "\x30\x01"
count: 2] ASN1DERValue])
EXPECT_EXCEPTION(@"Detection of truncated sequence #2",
OFTruncatedDataException,
[[OFData dataWithItems: "\x30\x04\x02\x01\x01\x00\x00"
count: 7] ASN1DERValue])
/* Set */
TEST(@"Parsing of set",
(set = [[OFData dataWithItems: "\x31\x00"
count: 2] ASN1DERValue]) &&
[set isKindOfClass: [OFSet class]] && set.count == 0 &&
(set = [[OFData dataWithItems: "\x31\x09\x02\x01\x7B\x0C\x04Test"
count: 11] ASN1DERValue]) &&
[set isKindOfClass: [OFSet class]] && set.count == 2 &&
(enumerator = [set objectEnumerator]) &&
[[enumerator nextObject] integerValue] == 123 &&
[[enumerator nextObject] longLongValue] == 123 &&
[[[enumerator nextObject] stringValue] isEqual: @"Test"])
EXPECT_EXCEPTION(@"Detection of invalid set",
OFInvalidFormatException,
[[OFData dataWithItems: "\x31\x06\x02\x01\x02\x02\x01\x01"
count: 8] ASN1DERValue])
|
︙ | | |