Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: source/i18n/measunit.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/measfmt.cpp ('k') | source/i18n/msgfmt.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ********************************************************************** 2 **********************************************************************
3 * Copyright (c) 2004-2014, International Business Machines 3 * Copyright (c) 2004-2015, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ********************************************************************** 5 **********************************************************************
6 * Author: Alan Liu 6 * Author: Alan Liu
7 * Created: April 26, 2004 7 * Created: April 26, 2004
8 * Since: ICU 3.0 8 * Since: ICU 3.0
9 ********************************************************************** 9 **********************************************************************
10 */ 10 */
11 #include "utypeinfo.h" // for 'typeid' to work 11 #include "utypeinfo.h" // for 'typeid' to work
12 12
13 #include "unicode/measunit.h" 13 #include "unicode/measunit.h"
14 14
15 #if !UCONFIG_NO_FORMATTING 15 #if !UCONFIG_NO_FORMATTING
16 16
17 #include "unicode/uenum.h" 17 #include "unicode/uenum.h"
18 #include "ustrenum.h" 18 #include "ustrenum.h"
19 #include "cstring.h" 19 #include "cstring.h"
20 #include "uassert.h" 20 #include "uassert.h"
21 21
22 U_NAMESPACE_BEGIN 22 U_NAMESPACE_BEGIN
23 23
24 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureUnit) 24 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureUnit)
25 25
26 // All code between the "Start generated code" comment and 26 // All code between the "Start generated code" comment and
27 // the "End generated code" comment is auto generated code 27 // the "End generated code" comment is auto generated code
28 // and must not be edited manually. For instructions on how to correctly 28 // and must not be edited manually. For instructions on how to correctly
29 // update this code, refer to: 29 // update this code, refer to:
30 // https://sites.google.com/site/icusite/design/formatting/measureformat/updatin g-measure-unit 30 // http://site.icu-project.org/design/formatting/measureformat/updating-measure- unit
31 // 31 //
32 // Start generated code 32 // Start generated code
33 33
34 static const int32_t gOffsets[] = { 34 static const int32_t gOffsets[] = {
35 0, 35 0,
36 2, 36 2,
37 6, 37 7,
38 15, 38 16,
39 17, 39 19,
40 277, 40 279,
41 287, 41 289,
42 297, 42 300,
43 301, 43 304,
44 307, 44 310,
45 311, 45 314,
46 329, 46 333,
47 330, 47 334,
48 341, 48 345,
49 347, 49 351,
50 352,
51 353,
52 356, 50 356,
53 359, 51 357,
54 381 52 361,
53 365,
54 389
55 }; 55 };
56 56
57 static const int32_t gIndexes[] = { 57 static const int32_t gIndexes[] = {
58 0, 58 0,
59 2, 59 2,
60 6, 60 7,
61 15, 61 16,
62 17, 62 19,
63 17, 63 19,
64 27, 64 29,
65 37, 65 40,
66 41, 66 44,
67 47, 67 50,
68 51, 68 54,
69 69, 69 73,
70 70, 70 74,
71 81, 71 85,
72 87, 72 91,
73 92,
74 93,
75 96, 73 96,
76 99, 74 97,
77 121 75 101,
76 105,
77 129
78 }; 78 };
79 79
80 // Must be sorted alphabetically.
80 static const char * const gTypes[] = { 81 static const char * const gTypes[] = {
81 "acceleration", 82 "acceleration",
82 "angle", 83 "angle",
83 "area", 84 "area",
84 "consumption", 85 "consumption",
85 "currency", 86 "currency",
86 "digital", 87 "digital",
87 "duration", 88 "duration",
88 "electric", 89 "electric",
89 "energy", 90 "energy",
90 "frequency", 91 "frequency",
91 "length", 92 "length",
92 "light", 93 "light",
93 "mass", 94 "mass",
94 "power", 95 "power",
95 "pressure", 96 "pressure",
96 "proportion", 97 "proportion",
97 "speed", 98 "speed",
98 "temperature", 99 "temperature",
99 "volume" 100 "volume"
100 }; 101 };
101 102
103 // Must be grouped by type and sorted alphabetically within each type.
102 static const char * const gSubTypes[] = { 104 static const char * const gSubTypes[] = {
103 "g-force", 105 "g-force",
104 "meter-per-second-squared", 106 "meter-per-second-squared",
105 "arc-minute", 107 "arc-minute",
106 "arc-second", 108 "arc-second",
107 "degree", 109 "degree",
108 "radian", 110 "radian",
111 "revolution",
109 "acre", 112 "acre",
110 "hectare", 113 "hectare",
111 "square-centimeter", 114 "square-centimeter",
112 "square-foot", 115 "square-foot",
113 "square-inch", 116 "square-inch",
114 "square-kilometer", 117 "square-kilometer",
115 "square-meter", 118 "square-meter",
116 "square-mile", 119 "square-mile",
117 "square-yard", 120 "square-yard",
121 "liter-per-100kilometers",
118 "liter-per-kilometer", 122 "liter-per-kilometer",
119 "mile-per-gallon", 123 "mile-per-gallon",
120 "ADP", 124 "ADP",
121 "AED", 125 "AED",
122 "AFA", 126 "AFA",
123 "AFN", 127 "AFN",
124 "ALL", 128 "ALL",
125 "AMD", 129 "AMD",
126 "ANG", 130 "ANG",
127 "AOA", 131 "AOA",
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 "bit", 384 "bit",
381 "byte", 385 "byte",
382 "gigabit", 386 "gigabit",
383 "gigabyte", 387 "gigabyte",
384 "kilobit", 388 "kilobit",
385 "kilobyte", 389 "kilobyte",
386 "megabit", 390 "megabit",
387 "megabyte", 391 "megabyte",
388 "terabit", 392 "terabit",
389 "terabyte", 393 "terabyte",
394 "century",
390 "day", 395 "day",
391 "hour", 396 "hour",
392 "microsecond", 397 "microsecond",
393 "millisecond", 398 "millisecond",
394 "minute", 399 "minute",
395 "month", 400 "month",
396 "nanosecond", 401 "nanosecond",
397 "second", 402 "second",
398 "week", 403 "week",
399 "year", 404 "year",
(...skipping 16 matching lines...) Expand all
416 "decimeter", 421 "decimeter",
417 "fathom", 422 "fathom",
418 "foot", 423 "foot",
419 "furlong", 424 "furlong",
420 "inch", 425 "inch",
421 "kilometer", 426 "kilometer",
422 "light-year", 427 "light-year",
423 "meter", 428 "meter",
424 "micrometer", 429 "micrometer",
425 "mile", 430 "mile",
431 "mile-scandinavian",
426 "millimeter", 432 "millimeter",
427 "nanometer", 433 "nanometer",
428 "nautical-mile", 434 "nautical-mile",
429 "parsec", 435 "parsec",
430 "picometer", 436 "picometer",
431 "yard", 437 "yard",
432 "lux", 438 "lux",
433 "carat", 439 "carat",
434 "gram", 440 "gram",
435 "kilogram", 441 "kilogram",
(...skipping 11 matching lines...) Expand all
447 "megawatt", 453 "megawatt",
448 "milliwatt", 454 "milliwatt",
449 "watt", 455 "watt",
450 "hectopascal", 456 "hectopascal",
451 "inch-hg", 457 "inch-hg",
452 "millibar", 458 "millibar",
453 "millimeter-of-mercury", 459 "millimeter-of-mercury",
454 "pound-per-square-inch", 460 "pound-per-square-inch",
455 "karat", 461 "karat",
456 "kilometer-per-hour", 462 "kilometer-per-hour",
463 "knot",
457 "meter-per-second", 464 "meter-per-second",
458 "mile-per-hour", 465 "mile-per-hour",
459 "celsius", 466 "celsius",
460 "fahrenheit", 467 "fahrenheit",
468 "generic",
461 "kelvin", 469 "kelvin",
462 "acre-foot", 470 "acre-foot",
463 "bushel", 471 "bushel",
464 "centiliter", 472 "centiliter",
465 "cubic-centimeter", 473 "cubic-centimeter",
466 "cubic-foot", 474 "cubic-foot",
467 "cubic-inch", 475 "cubic-inch",
468 "cubic-kilometer", 476 "cubic-kilometer",
469 "cubic-meter", 477 "cubic-meter",
470 "cubic-mile", 478 "cubic-mile",
471 "cubic-yard", 479 "cubic-yard",
472 "cup", 480 "cup",
481 "cup-metric",
473 "deciliter", 482 "deciliter",
474 "fluid-ounce", 483 "fluid-ounce",
475 "gallon", 484 "gallon",
476 "hectoliter", 485 "hectoliter",
477 "liter", 486 "liter",
478 "megaliter", 487 "megaliter",
479 "milliliter", 488 "milliliter",
480 "pint", 489 "pint",
490 "pint-metric",
481 "quart", 491 "quart",
482 "tablespoon", 492 "tablespoon",
483 "teaspoon" 493 "teaspoon"
484 }; 494 };
485 495
496 // Must be sorted by first value and then second value.
497 static int32_t unitPerUnitToSingleUnit[][4] = {
498 {321, 291, 16, 0},
499 {323, 297, 16, 2},
500 {325, 291, 16, 3},
501 {325, 379, 3, 2},
502 {342, 11, 14, 4},
503 {381, 321, 3, 1}
504 };
505
486 MeasureUnit *MeasureUnit::createGForce(UErrorCode &status) { 506 MeasureUnit *MeasureUnit::createGForce(UErrorCode &status) {
487 return MeasureUnit::create(0, 0, status); 507 return MeasureUnit::create(0, 0, status);
488 } 508 }
489 509
490 MeasureUnit *MeasureUnit::createMeterPerSecondSquared(UErrorCode &status) { 510 MeasureUnit *MeasureUnit::createMeterPerSecondSquared(UErrorCode &status) {
491 return MeasureUnit::create(0, 1, status); 511 return MeasureUnit::create(0, 1, status);
492 } 512 }
493 513
494 MeasureUnit *MeasureUnit::createArcMinute(UErrorCode &status) { 514 MeasureUnit *MeasureUnit::createArcMinute(UErrorCode &status) {
495 return MeasureUnit::create(1, 0, status); 515 return MeasureUnit::create(1, 0, status);
496 } 516 }
497 517
498 MeasureUnit *MeasureUnit::createArcSecond(UErrorCode &status) { 518 MeasureUnit *MeasureUnit::createArcSecond(UErrorCode &status) {
499 return MeasureUnit::create(1, 1, status); 519 return MeasureUnit::create(1, 1, status);
500 } 520 }
501 521
502 MeasureUnit *MeasureUnit::createDegree(UErrorCode &status) { 522 MeasureUnit *MeasureUnit::createDegree(UErrorCode &status) {
503 return MeasureUnit::create(1, 2, status); 523 return MeasureUnit::create(1, 2, status);
504 } 524 }
505 525
506 MeasureUnit *MeasureUnit::createRadian(UErrorCode &status) { 526 MeasureUnit *MeasureUnit::createRadian(UErrorCode &status) {
507 return MeasureUnit::create(1, 3, status); 527 return MeasureUnit::create(1, 3, status);
508 } 528 }
509 529
530 MeasureUnit *MeasureUnit::createRevolutionAngle(UErrorCode &status) {
531 return MeasureUnit::create(1, 4, status);
532 }
533
510 MeasureUnit *MeasureUnit::createAcre(UErrorCode &status) { 534 MeasureUnit *MeasureUnit::createAcre(UErrorCode &status) {
511 return MeasureUnit::create(2, 0, status); 535 return MeasureUnit::create(2, 0, status);
512 } 536 }
513 537
514 MeasureUnit *MeasureUnit::createHectare(UErrorCode &status) { 538 MeasureUnit *MeasureUnit::createHectare(UErrorCode &status) {
515 return MeasureUnit::create(2, 1, status); 539 return MeasureUnit::create(2, 1, status);
516 } 540 }
517 541
518 MeasureUnit *MeasureUnit::createSquareCentimeter(UErrorCode &status) { 542 MeasureUnit *MeasureUnit::createSquareCentimeter(UErrorCode &status) {
519 return MeasureUnit::create(2, 2, status); 543 return MeasureUnit::create(2, 2, status);
(...skipping 16 matching lines...) Expand all
536 } 560 }
537 561
538 MeasureUnit *MeasureUnit::createSquareMile(UErrorCode &status) { 562 MeasureUnit *MeasureUnit::createSquareMile(UErrorCode &status) {
539 return MeasureUnit::create(2, 7, status); 563 return MeasureUnit::create(2, 7, status);
540 } 564 }
541 565
542 MeasureUnit *MeasureUnit::createSquareYard(UErrorCode &status) { 566 MeasureUnit *MeasureUnit::createSquareYard(UErrorCode &status) {
543 return MeasureUnit::create(2, 8, status); 567 return MeasureUnit::create(2, 8, status);
544 } 568 }
545 569
546 MeasureUnit *MeasureUnit::createLiterPerKilometer(UErrorCode &status) { 570 MeasureUnit *MeasureUnit::createLiterPer100Kilometers(UErrorCode &status) {
547 return MeasureUnit::create(3, 0, status); 571 return MeasureUnit::create(3, 0, status);
548 } 572 }
549 573
574 MeasureUnit *MeasureUnit::createLiterPerKilometer(UErrorCode &status) {
575 return MeasureUnit::create(3, 1, status);
576 }
577
550 MeasureUnit *MeasureUnit::createMilePerGallon(UErrorCode &status) { 578 MeasureUnit *MeasureUnit::createMilePerGallon(UErrorCode &status) {
551 return MeasureUnit::create(3, 1, status); 579 return MeasureUnit::create(3, 2, status);
552 } 580 }
553 581
554 MeasureUnit *MeasureUnit::createBit(UErrorCode &status) { 582 MeasureUnit *MeasureUnit::createBit(UErrorCode &status) {
555 return MeasureUnit::create(5, 0, status); 583 return MeasureUnit::create(5, 0, status);
556 } 584 }
557 585
558 MeasureUnit *MeasureUnit::createByte(UErrorCode &status) { 586 MeasureUnit *MeasureUnit::createByte(UErrorCode &status) {
559 return MeasureUnit::create(5, 1, status); 587 return MeasureUnit::create(5, 1, status);
560 } 588 }
561 589
(...skipping 22 matching lines...) Expand all
584 } 612 }
585 613
586 MeasureUnit *MeasureUnit::createTerabit(UErrorCode &status) { 614 MeasureUnit *MeasureUnit::createTerabit(UErrorCode &status) {
587 return MeasureUnit::create(5, 8, status); 615 return MeasureUnit::create(5, 8, status);
588 } 616 }
589 617
590 MeasureUnit *MeasureUnit::createTerabyte(UErrorCode &status) { 618 MeasureUnit *MeasureUnit::createTerabyte(UErrorCode &status) {
591 return MeasureUnit::create(5, 9, status); 619 return MeasureUnit::create(5, 9, status);
592 } 620 }
593 621
594 MeasureUnit *MeasureUnit::createDay(UErrorCode &status) { 622 MeasureUnit *MeasureUnit::createCentury(UErrorCode &status) {
595 return MeasureUnit::create(6, 0, status); 623 return MeasureUnit::create(6, 0, status);
596 } 624 }
597 625
598 MeasureUnit *MeasureUnit::createHour(UErrorCode &status) { 626 MeasureUnit *MeasureUnit::createDay(UErrorCode &status) {
599 return MeasureUnit::create(6, 1, status); 627 return MeasureUnit::create(6, 1, status);
600 } 628 }
601 629
602 MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) { 630 MeasureUnit *MeasureUnit::createHour(UErrorCode &status) {
603 return MeasureUnit::create(6, 2, status); 631 return MeasureUnit::create(6, 2, status);
604 } 632 }
605 633
606 MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) { 634 MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) {
607 return MeasureUnit::create(6, 3, status); 635 return MeasureUnit::create(6, 3, status);
608 } 636 }
609 637
610 MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) { 638 MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) {
611 return MeasureUnit::create(6, 4, status); 639 return MeasureUnit::create(6, 4, status);
612 } 640 }
613 641
614 MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) { 642 MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) {
615 return MeasureUnit::create(6, 5, status); 643 return MeasureUnit::create(6, 5, status);
616 } 644 }
617 645
618 MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) { 646 MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) {
619 return MeasureUnit::create(6, 6, status); 647 return MeasureUnit::create(6, 6, status);
620 } 648 }
621 649
622 MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) { 650 MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) {
623 return MeasureUnit::create(6, 7, status); 651 return MeasureUnit::create(6, 7, status);
624 } 652 }
625 653
626 MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) { 654 MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) {
627 return MeasureUnit::create(6, 8, status); 655 return MeasureUnit::create(6, 8, status);
628 } 656 }
629 657
658 MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) {
659 return MeasureUnit::create(6, 9, status);
660 }
661
630 MeasureUnit *MeasureUnit::createYear(UErrorCode &status) { 662 MeasureUnit *MeasureUnit::createYear(UErrorCode &status) {
631 return MeasureUnit::create(6, 9, status); 663 return MeasureUnit::create(6, 10, status);
632 } 664 }
633 665
634 MeasureUnit *MeasureUnit::createAmpere(UErrorCode &status) { 666 MeasureUnit *MeasureUnit::createAmpere(UErrorCode &status) {
635 return MeasureUnit::create(7, 0, status); 667 return MeasureUnit::create(7, 0, status);
636 } 668 }
637 669
638 MeasureUnit *MeasureUnit::createMilliampere(UErrorCode &status) { 670 MeasureUnit *MeasureUnit::createMilliampere(UErrorCode &status) {
639 return MeasureUnit::create(7, 1, status); 671 return MeasureUnit::create(7, 1, status);
640 } 672 }
641 673
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 760 }
729 761
730 MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) { 762 MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) {
731 return MeasureUnit::create(10, 10, status); 763 return MeasureUnit::create(10, 10, status);
732 } 764 }
733 765
734 MeasureUnit *MeasureUnit::createMile(UErrorCode &status) { 766 MeasureUnit *MeasureUnit::createMile(UErrorCode &status) {
735 return MeasureUnit::create(10, 11, status); 767 return MeasureUnit::create(10, 11, status);
736 } 768 }
737 769
738 MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) { 770 MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) {
739 return MeasureUnit::create(10, 12, status); 771 return MeasureUnit::create(10, 12, status);
740 } 772 }
741 773
742 MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) { 774 MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) {
743 return MeasureUnit::create(10, 13, status); 775 return MeasureUnit::create(10, 13, status);
744 } 776 }
745 777
746 MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) { 778 MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) {
747 return MeasureUnit::create(10, 14, status); 779 return MeasureUnit::create(10, 14, status);
748 } 780 }
749 781
750 MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) { 782 MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) {
751 return MeasureUnit::create(10, 15, status); 783 return MeasureUnit::create(10, 15, status);
752 } 784 }
753 785
754 MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) { 786 MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) {
755 return MeasureUnit::create(10, 16, status); 787 return MeasureUnit::create(10, 16, status);
756 } 788 }
757 789
790 MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) {
791 return MeasureUnit::create(10, 17, status);
792 }
793
758 MeasureUnit *MeasureUnit::createYard(UErrorCode &status) { 794 MeasureUnit *MeasureUnit::createYard(UErrorCode &status) {
759 return MeasureUnit::create(10, 17, status); 795 return MeasureUnit::create(10, 18, status);
760 } 796 }
761 797
762 MeasureUnit *MeasureUnit::createLux(UErrorCode &status) { 798 MeasureUnit *MeasureUnit::createLux(UErrorCode &status) {
763 return MeasureUnit::create(11, 0, status); 799 return MeasureUnit::create(11, 0, status);
764 } 800 }
765 801
766 MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) { 802 MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) {
767 return MeasureUnit::create(12, 0, status); 803 return MeasureUnit::create(12, 0, status);
768 } 804 }
769 805
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 888 }
853 889
854 MeasureUnit *MeasureUnit::createKarat(UErrorCode &status) { 890 MeasureUnit *MeasureUnit::createKarat(UErrorCode &status) {
855 return MeasureUnit::create(15, 0, status); 891 return MeasureUnit::create(15, 0, status);
856 } 892 }
857 893
858 MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) { 894 MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) {
859 return MeasureUnit::create(16, 0, status); 895 return MeasureUnit::create(16, 0, status);
860 } 896 }
861 897
862 MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) { 898 MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) {
863 return MeasureUnit::create(16, 1, status); 899 return MeasureUnit::create(16, 1, status);
864 } 900 }
865 901
902 MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) {
903 return MeasureUnit::create(16, 2, status);
904 }
905
866 MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) { 906 MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) {
867 return MeasureUnit::create(16, 2, status); 907 return MeasureUnit::create(16, 3, status);
868 } 908 }
869 909
870 MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) { 910 MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) {
871 return MeasureUnit::create(17, 0, status); 911 return MeasureUnit::create(17, 0, status);
872 } 912 }
873 913
874 MeasureUnit *MeasureUnit::createFahrenheit(UErrorCode &status) { 914 MeasureUnit *MeasureUnit::createFahrenheit(UErrorCode &status) {
875 return MeasureUnit::create(17, 1, status); 915 return MeasureUnit::create(17, 1, status);
876 } 916 }
877 917
918 MeasureUnit *MeasureUnit::createGenericTemperature(UErrorCode &status) {
919 return MeasureUnit::create(17, 2, status);
920 }
921
878 MeasureUnit *MeasureUnit::createKelvin(UErrorCode &status) { 922 MeasureUnit *MeasureUnit::createKelvin(UErrorCode &status) {
879 return MeasureUnit::create(17, 2, status); 923 return MeasureUnit::create(17, 3, status);
880 } 924 }
881 925
882 MeasureUnit *MeasureUnit::createAcreFoot(UErrorCode &status) { 926 MeasureUnit *MeasureUnit::createAcreFoot(UErrorCode &status) {
883 return MeasureUnit::create(18, 0, status); 927 return MeasureUnit::create(18, 0, status);
884 } 928 }
885 929
886 MeasureUnit *MeasureUnit::createBushel(UErrorCode &status) { 930 MeasureUnit *MeasureUnit::createBushel(UErrorCode &status) {
887 return MeasureUnit::create(18, 1, status); 931 return MeasureUnit::create(18, 1, status);
888 } 932 }
889 933
(...skipping 26 matching lines...) Expand all
916 } 960 }
917 961
918 MeasureUnit *MeasureUnit::createCubicYard(UErrorCode &status) { 962 MeasureUnit *MeasureUnit::createCubicYard(UErrorCode &status) {
919 return MeasureUnit::create(18, 9, status); 963 return MeasureUnit::create(18, 9, status);
920 } 964 }
921 965
922 MeasureUnit *MeasureUnit::createCup(UErrorCode &status) { 966 MeasureUnit *MeasureUnit::createCup(UErrorCode &status) {
923 return MeasureUnit::create(18, 10, status); 967 return MeasureUnit::create(18, 10, status);
924 } 968 }
925 969
926 MeasureUnit *MeasureUnit::createDeciliter(UErrorCode &status) { 970 MeasureUnit *MeasureUnit::createCupMetric(UErrorCode &status) {
927 return MeasureUnit::create(18, 11, status); 971 return MeasureUnit::create(18, 11, status);
928 } 972 }
929 973
930 MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) { 974 MeasureUnit *MeasureUnit::createDeciliter(UErrorCode &status) {
931 return MeasureUnit::create(18, 12, status); 975 return MeasureUnit::create(18, 12, status);
932 } 976 }
933 977
934 MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) { 978 MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
935 return MeasureUnit::create(18, 13, status); 979 return MeasureUnit::create(18, 13, status);
936 } 980 }
937 981
938 MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) { 982 MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
939 return MeasureUnit::create(18, 14, status); 983 return MeasureUnit::create(18, 14, status);
940 } 984 }
941 985
942 MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) { 986 MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
943 return MeasureUnit::create(18, 15, status); 987 return MeasureUnit::create(18, 15, status);
944 } 988 }
945 989
946 MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) { 990 MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
947 return MeasureUnit::create(18, 16, status); 991 return MeasureUnit::create(18, 16, status);
948 } 992 }
949 993
950 MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) { 994 MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
951 return MeasureUnit::create(18, 17, status); 995 return MeasureUnit::create(18, 17, status);
952 } 996 }
953 997
954 MeasureUnit *MeasureUnit::createPint(UErrorCode &status) { 998 MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
955 return MeasureUnit::create(18, 18, status); 999 return MeasureUnit::create(18, 18, status);
956 } 1000 }
957 1001
958 MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) { 1002 MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
959 return MeasureUnit::create(18, 19, status); 1003 return MeasureUnit::create(18, 19, status);
960 } 1004 }
961 1005
962 MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) { 1006 MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
963 return MeasureUnit::create(18, 20, status); 1007 return MeasureUnit::create(18, 20, status);
964 } 1008 }
965 1009
1010 MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
1011 return MeasureUnit::create(18, 21, status);
1012 }
1013
1014 MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
1015 return MeasureUnit::create(18, 22, status);
1016 }
1017
966 MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) { 1018 MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
967 return MeasureUnit::create(18, 21, status); 1019 return MeasureUnit::create(18, 23, status);
968 } 1020 }
969 1021
970 // End generated code 1022 // End generated code
971 1023
972 static int32_t binarySearch( 1024 static int32_t binarySearch(
973 const char * const * array, int32_t start, int32_t end, const char * key ) { 1025 const char * const * array, int32_t start, int32_t end, const char * key ) {
974 while (start < end) { 1026 while (start < end) {
975 int32_t mid = (start + end) / 2; 1027 int32_t mid = (start + end) / 2;
976 int32_t cmp = uprv_strcmp(array[mid], key); 1028 int32_t cmp = uprv_strcmp(array[mid], key);
977 if (cmp < 0) { 1029 if (cmp < 0) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 uenum_close(uenum); 1145 uenum_close(uenum);
1094 return NULL; 1146 return NULL;
1095 } 1147 }
1096 return result; 1148 return result;
1097 } 1149 }
1098 1150
1099 int32_t MeasureUnit::getIndexCount() { 1151 int32_t MeasureUnit::getIndexCount() {
1100 return gIndexes[UPRV_LENGTHOF(gIndexes) - 1]; 1152 return gIndexes[UPRV_LENGTHOF(gIndexes) - 1];
1101 } 1153 }
1102 1154
1155 MeasureUnit *MeasureUnit::resolveUnitPerUnit(
1156 const MeasureUnit &unit, const MeasureUnit &perUnit) {
1157 int32_t unitOffset = unit.getOffset();
1158 int32_t perUnitOffset = perUnit.getOffset();
1159
1160 // binary search for (unitOffset, perUnitOffset)
1161 int32_t start = 0;
1162 int32_t end = UPRV_LENGTHOF(unitPerUnitToSingleUnit);
1163 while (start < end) {
1164 int32_t mid = (start + end) / 2;
1165 int32_t *midRow = unitPerUnitToSingleUnit[mid];
1166 if (unitOffset < midRow[0]) {
1167 end = mid;
1168 } else if (unitOffset > midRow[0]) {
1169 start = mid + 1;
1170 } else if (perUnitOffset < midRow[1]) {
1171 end = mid;
1172 } else if (perUnitOffset > midRow[1]) {
1173 start = mid + 1;
1174 } else {
1175 // We found a resolution for our unit / per-unit combo
1176 // return it.
1177 return new MeasureUnit(midRow[2], midRow[3]);
1178 }
1179 }
1180 return NULL;
1181 }
1182
1103 MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) { 1183 MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) {
1104 if (U_FAILURE(status)) { 1184 if (U_FAILURE(status)) {
1105 return NULL; 1185 return NULL;
1106 } 1186 }
1107 MeasureUnit *result = new MeasureUnit(typeId, subTypeId); 1187 MeasureUnit *result = new MeasureUnit(typeId, subTypeId);
1108 if (result == NULL) { 1188 if (result == NULL) {
1109 status = U_MEMORY_ALLOCATION_ERROR; 1189 status = U_MEMORY_ALLOCATION_ERROR;
1110 } 1190 }
1111 return result; 1191 return result;
1112 } 1192 }
(...skipping 26 matching lines...) Expand all
1139 fCurrency[0] = 0; 1219 fCurrency[0] = 0;
1140 } 1220 }
1141 1221
1142 int32_t MeasureUnit::getOffset() const { 1222 int32_t MeasureUnit::getOffset() const {
1143 return gOffsets[fTypeId] + fSubTypeId; 1223 return gOffsets[fTypeId] + fSubTypeId;
1144 } 1224 }
1145 1225
1146 U_NAMESPACE_END 1226 U_NAMESPACE_END
1147 1227
1148 #endif /* !UNCONFIG_NO_FORMATTING */ 1228 #endif /* !UNCONFIG_NO_FORMATTING */
OLDNEW
« no previous file with comments | « source/i18n/measfmt.cpp ('k') | source/i18n/msgfmt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698