ICU 71.1 71.1

measunit.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (c) 2004-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 * Author: Alan Liu
9 * Created: April 26, 2004
10 * Since: ICU 3.0
11 **********************************************************************
12 */
13 #ifndef __MEASUREUNIT_H__
14 #define __MEASUREUNIT_H__
15
16 #include "unicode/utypes.h"
17
18 #if U_SHOW_CPLUSPLUS_API
19
20 #if !UCONFIG_NO_FORMATTING
21
22 #include "unicode/unistr.h"
23 #include "unicode/localpointer.h"
24
30 U_NAMESPACE_BEGIN
31
32 class StringEnumeration;
33 class MeasureUnitImpl;
34
35 namespace number {
36 namespace impl {
37 class LongNameHandler;
38 }
39 } // namespace number
40
56 enum UMeasureUnitComplexity {
62 UMEASURE_UNIT_SINGLE,
63
69 UMEASURE_UNIT_COMPOUND,
70
76 UMEASURE_UNIT_MIXED
77 };
78
79
90 typedef enum UMeasurePrefix {
100 UMEASURE_PREFIX_ONE = 30 + 0,
101
107 UMEASURE_PREFIX_YOTTA = UMEASURE_PREFIX_ONE + 24,
108
109 #ifndef U_HIDE_INTERNAL_API
110
115 UMEASURE_PREFIX_INTERNAL_MAX_SI = UMEASURE_PREFIX_YOTTA,
116 #endif /* U_HIDE_INTERNAL_API */
117
123 UMEASURE_PREFIX_ZETTA = UMEASURE_PREFIX_ONE + 21,
124
130 UMEASURE_PREFIX_EXA = UMEASURE_PREFIX_ONE + 18,
131
137 UMEASURE_PREFIX_PETA = UMEASURE_PREFIX_ONE + 15,
138
144 UMEASURE_PREFIX_TERA = UMEASURE_PREFIX_ONE + 12,
145
151 UMEASURE_PREFIX_GIGA = UMEASURE_PREFIX_ONE + 9,
152
158 UMEASURE_PREFIX_MEGA = UMEASURE_PREFIX_ONE + 6,
159
165 UMEASURE_PREFIX_KILO = UMEASURE_PREFIX_ONE + 3,
166
172 UMEASURE_PREFIX_HECTO = UMEASURE_PREFIX_ONE + 2,
173
179 UMEASURE_PREFIX_DEKA = UMEASURE_PREFIX_ONE + 1,
180
186 UMEASURE_PREFIX_DECI = UMEASURE_PREFIX_ONE + -1,
187
193 UMEASURE_PREFIX_CENTI = UMEASURE_PREFIX_ONE + -2,
194
200 UMEASURE_PREFIX_MILLI = UMEASURE_PREFIX_ONE + -3,
201
207 UMEASURE_PREFIX_MICRO = UMEASURE_PREFIX_ONE + -6,
208
214 UMEASURE_PREFIX_NANO = UMEASURE_PREFIX_ONE + -9,
215
221 UMEASURE_PREFIX_PICO = UMEASURE_PREFIX_ONE + -12,
222
228 UMEASURE_PREFIX_FEMTO = UMEASURE_PREFIX_ONE + -15,
229
235 UMEASURE_PREFIX_ATTO = UMEASURE_PREFIX_ONE + -18,
236
242 UMEASURE_PREFIX_ZEPTO = UMEASURE_PREFIX_ONE + -21,
243
249 UMEASURE_PREFIX_YOCTO = UMEASURE_PREFIX_ONE + -24,
250
251 #ifndef U_HIDE_INTERNAL_API
252
257 UMEASURE_PREFIX_INTERNAL_MIN_SI = UMEASURE_PREFIX_YOCTO,
258 #endif // U_HIDE_INTERNAL_API
259
260 // Cannot conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
261 // used in definitions of non-internal enum values
267 UMEASURE_PREFIX_INTERNAL_ONE_BIN = -60,
268
274 UMEASURE_PREFIX_KIBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 1,
275
276 #ifndef U_HIDE_INTERNAL_API
277
282 UMEASURE_PREFIX_INTERNAL_MIN_BIN = UMEASURE_PREFIX_KIBI,
283 #endif // U_HIDE_INTERNAL_API
284
290 UMEASURE_PREFIX_MEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 2,
291
297 UMEASURE_PREFIX_GIBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 3,
298
304 UMEASURE_PREFIX_TEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 4,
305
311 UMEASURE_PREFIX_PEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 5,
312
318 UMEASURE_PREFIX_EXBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 6,
319
325 UMEASURE_PREFIX_ZEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 7,
326
332 UMEASURE_PREFIX_YOBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 8,
333
334 #ifndef U_HIDE_INTERNAL_API
335
340 UMEASURE_PREFIX_INTERNAL_MAX_BIN = UMEASURE_PREFIX_YOBI,
341 #endif // U_HIDE_INTERNAL_API
342 } UMeasurePrefix;
343
351 U_CAPI int32_t U_EXPORT2 umeas_getPrefixBase(UMeasurePrefix unitPrefix);
352
359 U_CAPI int32_t U_EXPORT2 umeas_getPrefixPower(UMeasurePrefix unitPrefix);
360
368 class U_I18N_API MeasureUnit: public UObject {
369 public:
370
376 MeasureUnit();
377
382 MeasureUnit(const MeasureUnit &other);
383
388 MeasureUnit(MeasureUnit &&other) noexcept;
389
403 static MeasureUnit forIdentifier(StringPiece identifier, UErrorCode& status);
404
409 MeasureUnit &operator=(const MeasureUnit &other);
410
415 MeasureUnit &operator=(MeasureUnit &&other) noexcept;
416
422 virtual MeasureUnit* clone() const;
423
428 virtual ~MeasureUnit();
429
435 virtual bool operator==(const UObject& other) const;
436
442 bool operator!=(const UObject& other) const {
443 return !(*this == other);
444 }
445
453 const char *getType() const;
454
462 const char *getSubtype() const;
463
470 const char* getIdentifier() const;
471
479 UMeasureUnitComplexity getComplexity(UErrorCode& status) const;
480
495 MeasureUnit withPrefix(UMeasurePrefix prefix, UErrorCode& status) const;
496
511 UMeasurePrefix getPrefix(UErrorCode& status) const;
512
527 MeasureUnit withDimensionality(int32_t dimensionality, UErrorCode& status) const;
528
542 int32_t getDimensionality(UErrorCode& status) const;
543
556 MeasureUnit reciprocal(UErrorCode& status) const;
557
575 MeasureUnit product(const MeasureUnit& other, UErrorCode& status) const;
576
592 inline std::pair<LocalArray<MeasureUnit>, int32_t> splitToSingleUnits(UErrorCode& status) const;
593
605 static int32_t getAvailable(
606 MeasureUnit *destArray,
607 int32_t destCapacity,
608 UErrorCode &errorCode);
609
622 static int32_t getAvailable(
623 const char *type,
624 MeasureUnit *destArray,
625 int32_t destCapacity,
626 UErrorCode &errorCode);
627
636 static StringEnumeration* getAvailableTypes(UErrorCode &errorCode);
637
649 static UClassID U_EXPORT2 getStaticClassID(void);
650
662 virtual UClassID getDynamicClassID(void) const override;
663
664 #ifndef U_HIDE_INTERNAL_API
665
670 int32_t getOffset() const;
671 #endif /* U_HIDE_INTERNAL_API */
672
673 // All code between the "Start generated createXXX methods" comment and
674 // the "End generated createXXX methods" comment is auto generated code
675 // and must not be edited manually. For instructions on how to correctly
676 // update this code, refer to:
677 // docs/processes/release/tasks/updating-measure-unit.md
678 //
679 // Start generated createXXX methods
680
688 static MeasureUnit *createGForce(UErrorCode &status);
689
695 static MeasureUnit getGForce();
696
704 static MeasureUnit *createMeterPerSecondSquared(UErrorCode &status);
705
711 static MeasureUnit getMeterPerSecondSquared();
712
720 static MeasureUnit *createArcMinute(UErrorCode &status);
721
727 static MeasureUnit getArcMinute();
728
736 static MeasureUnit *createArcSecond(UErrorCode &status);
737
743 static MeasureUnit getArcSecond();
744
752 static MeasureUnit *createDegree(UErrorCode &status);
753
759 static MeasureUnit getDegree();
760
768 static MeasureUnit *createRadian(UErrorCode &status);
769
775 static MeasureUnit getRadian();
776
784 static MeasureUnit *createRevolutionAngle(UErrorCode &status);
785
791 static MeasureUnit getRevolutionAngle();
792
800 static MeasureUnit *createAcre(UErrorCode &status);
801
807 static MeasureUnit getAcre();
808
816 static MeasureUnit *createDunam(UErrorCode &status);
817
823 static MeasureUnit getDunam();
824
832 static MeasureUnit *createHectare(UErrorCode &status);
833
839 static MeasureUnit getHectare();
840
848 static MeasureUnit *createSquareCentimeter(UErrorCode &status);
849
855 static MeasureUnit getSquareCentimeter();
856
864 static MeasureUnit *createSquareFoot(UErrorCode &status);
865
871 static MeasureUnit getSquareFoot();
872
880 static MeasureUnit *createSquareInch(UErrorCode &status);
881
887 static MeasureUnit getSquareInch();
888
896 static MeasureUnit *createSquareKilometer(UErrorCode &status);
897
903 static MeasureUnit getSquareKilometer();
904
912 static MeasureUnit *createSquareMeter(UErrorCode &status);
913
919 static MeasureUnit getSquareMeter();
920
928 static MeasureUnit *createSquareMile(UErrorCode &status);
929
935 static MeasureUnit getSquareMile();
936
944 static MeasureUnit *createSquareYard(UErrorCode &status);
945
951 static MeasureUnit getSquareYard();
952
953 #ifndef U_HIDE_DRAFT_API
954
961 static MeasureUnit *createItem(UErrorCode &status);
962
968 static MeasureUnit getItem();
969 #endif /* U_HIDE_DRAFT_API */
970
978 static MeasureUnit *createKarat(UErrorCode &status);
979
985 static MeasureUnit getKarat();
986
994 static MeasureUnit *createMilligramOfglucosePerDeciliter(UErrorCode &status);
995
1001 static MeasureUnit getMilligramOfglucosePerDeciliter();
1002
1010 static MeasureUnit *createMilligramPerDeciliter(UErrorCode &status);
1011
1017 static MeasureUnit getMilligramPerDeciliter();
1018
1026 static MeasureUnit *createMillimolePerLiter(UErrorCode &status);
1027
1033 static MeasureUnit getMillimolePerLiter();
1034
1042 static MeasureUnit *createMole(UErrorCode &status);
1043
1049 static MeasureUnit getMole();
1050
1058 static MeasureUnit *createPercent(UErrorCode &status);
1059
1065 static MeasureUnit getPercent();
1066
1074 static MeasureUnit *createPermille(UErrorCode &status);
1075
1081 static MeasureUnit getPermille();
1082
1090 static MeasureUnit *createPartPerMillion(UErrorCode &status);
1091
1097 static MeasureUnit getPartPerMillion();
1098
1106 static MeasureUnit *createPermyriad(UErrorCode &status);
1107
1113 static MeasureUnit getPermyriad();
1114
1122 static MeasureUnit *createLiterPer100Kilometers(UErrorCode &status);
1123
1129 static MeasureUnit getLiterPer100Kilometers();
1130
1138 static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
1139
1145 static MeasureUnit getLiterPerKilometer();
1146
1154 static MeasureUnit *createMilePerGallon(UErrorCode &status);
1155
1161 static MeasureUnit getMilePerGallon();
1162
1170 static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
1171
1177 static MeasureUnit getMilePerGallonImperial();
1178
1186 static MeasureUnit *createBit(UErrorCode &status);
1187
1193 static MeasureUnit getBit();
1194
1202 static MeasureUnit *createByte(UErrorCode &status);
1203
1209 static MeasureUnit getByte();
1210
1218 static MeasureUnit *createGigabit(UErrorCode &status);
1219
1225 static MeasureUnit getGigabit();
1226
1234 static MeasureUnit *createGigabyte(UErrorCode &status);
1235
1241 static MeasureUnit getGigabyte();
1242
1250 static MeasureUnit *createKilobit(UErrorCode &status);
1251
1257 static MeasureUnit getKilobit();
1258
1266 static MeasureUnit *createKilobyte(UErrorCode &status);
1267
1273 static MeasureUnit getKilobyte();
1274
1282 static MeasureUnit *createMegabit(UErrorCode &status);
1283
1289 static MeasureUnit getMegabit();
1290
1298 static MeasureUnit *createMegabyte(UErrorCode &status);
1299
1305 static MeasureUnit getMegabyte();
1306
1314 static MeasureUnit *createPetabyte(UErrorCode &status);
1315
1321 static MeasureUnit getPetabyte();
1322
1330 static MeasureUnit *createTerabit(UErrorCode &status);
1331
1337 static MeasureUnit getTerabit();
1338
1346 static MeasureUnit *createTerabyte(UErrorCode &status);
1347
1353 static MeasureUnit getTerabyte();
1354
1362 static MeasureUnit *createCentury(UErrorCode &status);
1363
1369 static MeasureUnit getCentury();
1370
1378 static MeasureUnit *createDay(UErrorCode &status);
1379
1385 static MeasureUnit getDay();
1386
1394 static MeasureUnit *createDayPerson(UErrorCode &status);
1395
1401 static MeasureUnit getDayPerson();
1402
1410 static MeasureUnit *createDecade(UErrorCode &status);
1411
1417 static MeasureUnit getDecade();
1418
1426 static MeasureUnit *createHour(UErrorCode &status);
1427
1433 static MeasureUnit getHour();
1434
1442 static MeasureUnit *createMicrosecond(UErrorCode &status);
1443
1449 static MeasureUnit getMicrosecond();
1450
1458 static MeasureUnit *createMillisecond(UErrorCode &status);
1459
1465 static MeasureUnit getMillisecond();
1466
1474 static MeasureUnit *createMinute(UErrorCode &status);
1475
1481 static MeasureUnit getMinute();
1482
1490 static MeasureUnit *createMonth(UErrorCode &status);
1491
1497 static MeasureUnit getMonth();
1498
1506 static MeasureUnit *createMonthPerson(UErrorCode &status);
1507
1513 static MeasureUnit getMonthPerson();
1514
1522 static MeasureUnit *createNanosecond(UErrorCode &status);
1523
1529 static MeasureUnit getNanosecond();
1530
1538 static MeasureUnit *createSecond(UErrorCode &status);
1539
1545 static MeasureUnit getSecond();
1546
1554 static MeasureUnit *createWeek(UErrorCode &status);
1555
1561 static MeasureUnit getWeek();
1562
1570 static MeasureUnit *createWeekPerson(UErrorCode &status);
1571
1577 static MeasureUnit getWeekPerson();
1578
1586 static MeasureUnit *createYear(UErrorCode &status);
1587
1593 static MeasureUnit getYear();
1594
1602 static MeasureUnit *createYearPerson(UErrorCode &status);
1603
1609 static MeasureUnit getYearPerson();
1610
1618 static MeasureUnit *createAmpere(UErrorCode &status);
1619
1625 static MeasureUnit getAmpere();
1626
1634 static MeasureUnit *createMilliampere(UErrorCode &status);
1635
1641 static MeasureUnit getMilliampere();
1642
1650 static MeasureUnit *createOhm(UErrorCode &status);
1651
1657 static MeasureUnit getOhm();
1658
1666 static MeasureUnit *createVolt(UErrorCode &status);
1667
1673 static MeasureUnit getVolt();
1674
1682 static MeasureUnit *createBritishThermalUnit(UErrorCode &status);
1683
1689 static MeasureUnit getBritishThermalUnit();
1690
1698 static MeasureUnit *createCalorie(UErrorCode &status);
1699
1705 static MeasureUnit getCalorie();
1706
1714 static MeasureUnit *createElectronvolt(UErrorCode &status);
1715
1721 static MeasureUnit getElectronvolt();
1722
1730 static MeasureUnit *createFoodcalorie(UErrorCode &status);
1731
1737 static MeasureUnit getFoodcalorie();
1738
1746 static MeasureUnit *createJoule(UErrorCode &status);
1747
1753 static MeasureUnit getJoule();
1754
1762 static MeasureUnit *createKilocalorie(UErrorCode &status);
1763
1769 static MeasureUnit getKilocalorie();
1770
1778 static MeasureUnit *createKilojoule(UErrorCode &status);
1779
1785 static MeasureUnit getKilojoule();
1786
1794 static MeasureUnit *createKilowattHour(UErrorCode &status);
1795
1801 static MeasureUnit getKilowattHour();
1802
1810 static MeasureUnit *createThermUs(UErrorCode &status);
1811
1817 static MeasureUnit getThermUs();
1818
1819 #ifndef U_HIDE_DRAFT_API
1820
1827 static MeasureUnit *createKilowattHourPer100Kilometer(UErrorCode &status);
1828
1834 static MeasureUnit getKilowattHourPer100Kilometer();
1835 #endif /* U_HIDE_DRAFT_API */
1836
1844 static MeasureUnit *createNewton(UErrorCode &status);
1845
1851 static MeasureUnit getNewton();
1852
1860 static MeasureUnit *createPoundForce(UErrorCode &status);
1861
1867 static MeasureUnit getPoundForce();
1868
1876 static MeasureUnit *createGigahertz(UErrorCode &status);
1877
1883 static MeasureUnit getGigahertz();
1884
1892 static MeasureUnit *createHertz(UErrorCode &status);
1893
1899 static MeasureUnit getHertz();
1900
1908 static MeasureUnit *createKilohertz(UErrorCode &status);
1909
1915 static MeasureUnit getKilohertz();
1916
1924 static MeasureUnit *createMegahertz(UErrorCode &status);
1925
1931 static MeasureUnit getMegahertz();
1932
1940 static MeasureUnit *createDot(UErrorCode &status);
1941
1947 static MeasureUnit getDot();
1948
1956 static MeasureUnit *createDotPerCentimeter(UErrorCode &status);
1957
1963 static MeasureUnit getDotPerCentimeter();
1964
1972 static MeasureUnit *createDotPerInch(UErrorCode &status);
1973
1979 static MeasureUnit getDotPerInch();
1980
1988 static MeasureUnit *createEm(UErrorCode &status);
1989
1995 static MeasureUnit getEm();
1996
2004 static MeasureUnit *createMegapixel(UErrorCode &status);
2005
2011 static MeasureUnit getMegapixel();
2012
2020 static MeasureUnit *createPixel(UErrorCode &status);
2021
2027 static MeasureUnit getPixel();
2028
2036 static MeasureUnit *createPixelPerCentimeter(UErrorCode &status);
2037
2043 static MeasureUnit getPixelPerCentimeter();
2044
2052 static MeasureUnit *createPixelPerInch(UErrorCode &status);
2053
2059 static MeasureUnit getPixelPerInch();
2060
2068 static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
2069
2075 static MeasureUnit getAstronomicalUnit();
2076
2084 static MeasureUnit *createCentimeter(UErrorCode &status);
2085
2091 static MeasureUnit getCentimeter();
2092
2100 static MeasureUnit *createDecimeter(UErrorCode &status);
2101
2107 static MeasureUnit getDecimeter();
2108
2116 static MeasureUnit *createEarthRadius(UErrorCode &status);
2117
2123 static MeasureUnit getEarthRadius();
2124
2132 static MeasureUnit *createFathom(UErrorCode &status);
2133
2139 static MeasureUnit getFathom();
2140
2148 static MeasureUnit *createFoot(UErrorCode &status);
2149
2155 static MeasureUnit getFoot();
2156
2164 static MeasureUnit *createFurlong(UErrorCode &status);
2165
2171 static MeasureUnit getFurlong();
2172
2180 static MeasureUnit *createInch(UErrorCode &status);
2181
2187 static MeasureUnit getInch();
2188
2196 static MeasureUnit *createKilometer(UErrorCode &status);
2197
2203 static MeasureUnit getKilometer();
2204
2212 static MeasureUnit *createLightYear(UErrorCode &status);
2213
2219 static MeasureUnit getLightYear();
2220
2228 static MeasureUnit *createMeter(UErrorCode &status);
2229
2235 static MeasureUnit getMeter();
2236
2244 static MeasureUnit *createMicrometer(UErrorCode &status);
2245
2251 static MeasureUnit getMicrometer();
2252
2260 static MeasureUnit *createMile(UErrorCode &status);
2261
2267 static MeasureUnit getMile();
2268
2276 static MeasureUnit *createMileScandinavian(UErrorCode &status);
2277
2283 static MeasureUnit getMileScandinavian();
2284
2292 static MeasureUnit *createMillimeter(UErrorCode &status);
2293
2299 static MeasureUnit getMillimeter();
2300
2308 static MeasureUnit *createNanometer(UErrorCode &status);
2309
2315 static MeasureUnit getNanometer();
2316
2324 static MeasureUnit *createNauticalMile(UErrorCode &status);
2325
2331 static MeasureUnit getNauticalMile();
2332
2340 static MeasureUnit *createParsec(UErrorCode &status);
2341
2347 static MeasureUnit getParsec();
2348
2356 static MeasureUnit *createPicometer(UErrorCode &status);
2357
2363 static MeasureUnit getPicometer();
2364
2372 static MeasureUnit *createPoint(UErrorCode &status);
2373
2379 static MeasureUnit getPoint();
2380
2388 static MeasureUnit *createSolarRadius(UErrorCode &status);
2389
2395 static MeasureUnit getSolarRadius();
2396
2404 static MeasureUnit *createYard(UErrorCode &status);
2405
2411 static MeasureUnit getYard();
2412
2420 static MeasureUnit *createCandela(UErrorCode &status);
2421
2427 static MeasureUnit getCandela();
2428
2436 static MeasureUnit *createLumen(UErrorCode &status);
2437
2443 static MeasureUnit getLumen();
2444
2452 static MeasureUnit *createLux(UErrorCode &status);
2453
2459 static MeasureUnit getLux();
2460
2468 static MeasureUnit *createSolarLuminosity(UErrorCode &status);
2469
2475 static MeasureUnit getSolarLuminosity();
2476
2484 static MeasureUnit *createCarat(UErrorCode &status);
2485
2491 static MeasureUnit getCarat();
2492
2500 static MeasureUnit *createDalton(UErrorCode &status);
2501
2507 static MeasureUnit getDalton();
2508
2516 static MeasureUnit *createEarthMass(UErrorCode &status);
2517
2523 static MeasureUnit getEarthMass();
2524
2532 static MeasureUnit *createGrain(UErrorCode &status);
2533
2539 static MeasureUnit getGrain();
2540
2548 static MeasureUnit *createGram(UErrorCode &status);
2549
2555 static MeasureUnit getGram();
2556
2564 static MeasureUnit *createKilogram(UErrorCode &status);
2565
2571 static MeasureUnit getKilogram();
2572
2580 static MeasureUnit *createMetricTon(UErrorCode &status);
2581
2587 static MeasureUnit getMetricTon();
2588
2596 static MeasureUnit *createMicrogram(UErrorCode &status);
2597
2603 static MeasureUnit getMicrogram();
2604
2612 static MeasureUnit *createMilligram(UErrorCode &status);
2613
2619 static MeasureUnit getMilligram();
2620
2628 static MeasureUnit *createOunce(UErrorCode &status);
2629
2635 static MeasureUnit getOunce();
2636
2644 static MeasureUnit *createOunceTroy(UErrorCode &status);
2645
2651 static MeasureUnit getOunceTroy();
2652
2660 static MeasureUnit *createPound(UErrorCode &status);
2661
2667 static MeasureUnit getPound();
2668
2676 static MeasureUnit *createSolarMass(UErrorCode &status);
2677
2683 static MeasureUnit getSolarMass();
2684
2692 static MeasureUnit *createStone(UErrorCode &status);
2693
2699 static MeasureUnit getStone();
2700
2708 static MeasureUnit *createTon(UErrorCode &status);
2709
2715 static MeasureUnit getTon();
2716
2724 static MeasureUnit *createGigawatt(UErrorCode &status);
2725
2731 static MeasureUnit getGigawatt();
2732
2740 static MeasureUnit *createHorsepower(UErrorCode &status);
2741
2747 static MeasureUnit getHorsepower();
2748
2756 static MeasureUnit *createKilowatt(UErrorCode &status);
2757
2763 static MeasureUnit getKilowatt();
2764
2772 static MeasureUnit *createMegawatt(UErrorCode &status);
2773
2779 static MeasureUnit getMegawatt();
2780
2788 static MeasureUnit *createMilliwatt(UErrorCode &status);
2789
2795 static MeasureUnit getMilliwatt();
2796
2804 static MeasureUnit *createWatt(UErrorCode &status);
2805
2811 static MeasureUnit getWatt();
2812
2820 static MeasureUnit *createAtmosphere(UErrorCode &status);
2821
2827 static MeasureUnit getAtmosphere();
2828
2836 static MeasureUnit *createBar(UErrorCode &status);
2837
2843 static MeasureUnit getBar();
2844
2852 static MeasureUnit *createHectopascal(UErrorCode &status);
2853
2859 static MeasureUnit getHectopascal();
2860
2868 static MeasureUnit *createInchHg(UErrorCode &status);
2869
2875 static MeasureUnit getInchHg();
2876
2884 static MeasureUnit *createKilopascal(UErrorCode &status);
2885
2891 static MeasureUnit getKilopascal();
2892
2900 static MeasureUnit *createMegapascal(UErrorCode &status);
2901
2907 static MeasureUnit getMegapascal();
2908
2916 static MeasureUnit *createMillibar(UErrorCode &status);
2917
2923 static MeasureUnit getMillibar();
2924
2932 static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
2933
2939 static MeasureUnit getMillimeterOfMercury();
2940
2948 static MeasureUnit *createPascal(UErrorCode &status);
2949
2955 static MeasureUnit getPascal();
2956
2964 static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
2965
2971 static MeasureUnit getPoundPerSquareInch();
2972
2980 static MeasureUnit *createKilometerPerHour(UErrorCode &status);
2981
2987 static MeasureUnit getKilometerPerHour();
2988
2996 static MeasureUnit *createKnot(UErrorCode &status);
2997
3003 static MeasureUnit getKnot();
3004
3012 static MeasureUnit *createMeterPerSecond(UErrorCode &status);
3013
3019 static MeasureUnit getMeterPerSecond();
3020
3028 static MeasureUnit *createMilePerHour(UErrorCode &status);
3029
3035 static MeasureUnit getMilePerHour();
3036
3044 static MeasureUnit *createCelsius(UErrorCode &status);
3045
3051 static MeasureUnit getCelsius();
3052
3060 static MeasureUnit *createFahrenheit(UErrorCode &status);
3061
3067 static MeasureUnit getFahrenheit();
3068
3076 static MeasureUnit *createGenericTemperature(UErrorCode &status);
3077
3083 static MeasureUnit getGenericTemperature();
3084
3092 static MeasureUnit *createKelvin(UErrorCode &status);
3093
3099 static MeasureUnit getKelvin();
3100
3108 static MeasureUnit *createNewtonMeter(UErrorCode &status);
3109
3115 static MeasureUnit getNewtonMeter();
3116
3124 static MeasureUnit *createPoundFoot(UErrorCode &status);
3125
3131 static MeasureUnit getPoundFoot();
3132
3140 static MeasureUnit *createAcreFoot(UErrorCode &status);
3141
3147 static MeasureUnit getAcreFoot();
3148
3156 static MeasureUnit *createBarrel(UErrorCode &status);
3157
3163 static MeasureUnit getBarrel();
3164
3172 static MeasureUnit *createBushel(UErrorCode &status);
3173
3179 static MeasureUnit getBushel();
3180
3188 static MeasureUnit *createCentiliter(UErrorCode &status);
3189
3195 static MeasureUnit getCentiliter();
3196
3204 static MeasureUnit *createCubicCentimeter(UErrorCode &status);
3205
3211 static MeasureUnit getCubicCentimeter();
3212
3220 static MeasureUnit *createCubicFoot(UErrorCode &status);
3221
3227 static MeasureUnit getCubicFoot();
3228
3236 static MeasureUnit *createCubicInch(UErrorCode &status);
3237
3243 static MeasureUnit getCubicInch();
3244
3252 static MeasureUnit *createCubicKilometer(UErrorCode &status);
3253
3259 static MeasureUnit getCubicKilometer();
3260
3268 static MeasureUnit *createCubicMeter(UErrorCode &status);
3269
3275 static MeasureUnit getCubicMeter();
3276
3284 static MeasureUnit *createCubicMile(UErrorCode &status);
3285
3291 static MeasureUnit getCubicMile();
3292
3300 static MeasureUnit *createCubicYard(UErrorCode &status);
3301
3307 static MeasureUnit getCubicYard();
3308
3316 static MeasureUnit *createCup(UErrorCode &status);
3317
3323 static MeasureUnit getCup();
3324
3332 static MeasureUnit *createCupMetric(UErrorCode &status);
3333
3339 static MeasureUnit getCupMetric();
3340
3348 static MeasureUnit *createDeciliter(UErrorCode &status);
3349
3355 static MeasureUnit getDeciliter();
3356
3364 static MeasureUnit *createDessertSpoon(UErrorCode &status);
3365
3371 static MeasureUnit getDessertSpoon();
3372
3380 static MeasureUnit *createDessertSpoonImperial(UErrorCode &status);
3381
3387 static MeasureUnit getDessertSpoonImperial();
3388
3396 static MeasureUnit *createDram(UErrorCode &status);
3397
3403 static MeasureUnit getDram();
3404
3412 static MeasureUnit *createDrop(UErrorCode &status);
3413
3419 static MeasureUnit getDrop();
3420
3428 static MeasureUnit *createFluidOunce(UErrorCode &status);
3429
3435 static MeasureUnit getFluidOunce();
3436
3444 static MeasureUnit *createFluidOunceImperial(UErrorCode &status);
3445
3451 static MeasureUnit getFluidOunceImperial();
3452
3460 static MeasureUnit *createGallon(UErrorCode &status);
3461
3467 static MeasureUnit getGallon();
3468
3476 static MeasureUnit *createGallonImperial(UErrorCode &status);
3477
3483 static MeasureUnit getGallonImperial();
3484
3492 static MeasureUnit *createHectoliter(UErrorCode &status);
3493
3499 static MeasureUnit getHectoliter();
3500
3508 static MeasureUnit *createJigger(UErrorCode &status);
3509
3515 static MeasureUnit getJigger();
3516
3524 static MeasureUnit *createLiter(UErrorCode &status);
3525
3531 static MeasureUnit getLiter();
3532
3540 static MeasureUnit *createMegaliter(UErrorCode &status);
3541
3547 static MeasureUnit getMegaliter();
3548
3556 static MeasureUnit *createMilliliter(UErrorCode &status);
3557
3563 static MeasureUnit getMilliliter();
3564
3572 static MeasureUnit *createPinch(UErrorCode &status);
3573
3579 static MeasureUnit getPinch();
3580
3588 static MeasureUnit *createPint(UErrorCode &status);
3589
3595 static MeasureUnit getPint();
3596
3604 static MeasureUnit *createPintMetric(UErrorCode &status);
3605
3611 static MeasureUnit getPintMetric();
3612
3620 static MeasureUnit *createQuart(UErrorCode &status);
3621
3627 static MeasureUnit getQuart();
3628
3636 static MeasureUnit *createQuartImperial(UErrorCode &status);
3637
3643 static MeasureUnit getQuartImperial();
3644
3652 static MeasureUnit *createTablespoon(UErrorCode &status);
3653
3659 static MeasureUnit getTablespoon();
3660
3668 static MeasureUnit *createTeaspoon(UErrorCode &status);
3669
3675 static MeasureUnit getTeaspoon();
3676
3677 // End generated createXXX methods
3678
3679 protected:
3680
3681 #ifndef U_HIDE_INTERNAL_API
3682
3686 void initTime(const char *timeId);
3687
3692 void initCurrency(StringPiece isoCurrency);
3693
3694 #endif /* U_HIDE_INTERNAL_API */
3695
3696 private:
3697
3698 // Used by new draft APIs in ICU 67. If non-null, fImpl is owned by the
3699 // MeasureUnit.
3700 MeasureUnitImpl* fImpl;
3701
3702 // An index into a static string list in measunit.cpp. If set to -1, fImpl
3703 // is in use instead of fTypeId and fSubTypeId.
3704 int16_t fSubTypeId;
3705 // An index into a static string list in measunit.cpp. If set to -1, fImpl
3706 // is in use instead of fTypeId and fSubTypeId.
3707 int8_t fTypeId;
3708
3709 MeasureUnit(int32_t typeId, int32_t subTypeId);
3710 MeasureUnit(MeasureUnitImpl&& impl);
3711 void setTo(int32_t typeId, int32_t subTypeId);
3712 static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
3713
3721 static bool findBySubType(StringPiece subType, MeasureUnit* output);
3722
3724 LocalArray<MeasureUnit> splitToSingleUnitsImpl(int32_t& outCount, UErrorCode& status) const;
3725
3726 friend class MeasureUnitImpl;
3727
3728 // For access to findBySubType
3729 friend class number::impl::LongNameHandler;
3730 };
3731
3732 // inline impl of @stable ICU 68 method
3733 inline std::pair<LocalArray<MeasureUnit>, int32_t>
3734 MeasureUnit::splitToSingleUnits(UErrorCode& status) const {
3735 int32_t length;
3736 auto array = splitToSingleUnitsImpl(length, status);
3737 return std::make_pair(std::move(array), length);
3738 }
3739
3740 U_NAMESPACE_END
3741
3742 #endif // !UNCONFIG_NO_FORMATTING
3743
3744 #endif /* U_SHOW_CPLUSPLUS_API */
3745
3746 #endif // __MEASUREUNIT_H__
icu::UMEASURE_PREFIX_ATTO
@ UMEASURE_PREFIX_ATTO
SI prefix: atto, 10^-18.
Definition: measunit.h:235
icu::MeasureUnit
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:368
icu::UMEASURE_PREFIX_HECTO
@ UMEASURE_PREFIX_HECTO
SI prefix: hecto, 10^2.
Definition: measunit.h:172
icu::UMEASURE_PREFIX_KILO
@ UMEASURE_PREFIX_KILO
SI prefix: kilo, 10^3.
Definition: measunit.h:165
icu::UMEASURE_PREFIX_EXBI
@ UMEASURE_PREFIX_EXBI
Binary prefix: exbi, 1024^6.
Definition: measunit.h:318
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UMEASURE_PREFIX_FEMTO
@ UMEASURE_PREFIX_FEMTO
SI prefix: femto, 10^-15.
Definition: measunit.h:228
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
icu::UMEASURE_PREFIX_PEBI
@ UMEASURE_PREFIX_PEBI
Binary prefix: pebi, 1024^5.
Definition: measunit.h:311
icu::UMEASURE_PREFIX_DEKA
@ UMEASURE_PREFIX_DEKA
SI prefix: deka, 10^1.
Definition: measunit.h:179
icu::UMEASURE_UNIT_COMPOUND
@ UMEASURE_UNIT_COMPOUND
A compound unit, like meter-per-second.
Definition: measunit.h:69
icu::UMEASURE_PREFIX_MILLI
@ UMEASURE_PREFIX_MILLI
SI prefix: milli, 10^-3.
Definition: measunit.h:200
icu::UMEASURE_PREFIX_GIBI
@ UMEASURE_PREFIX_GIBI
Binary prefix: gibi, 1024^3.
Definition: measunit.h:297
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::UMEASURE_PREFIX_DECI
@ UMEASURE_PREFIX_DECI
SI prefix: deci, 10^-1.
Definition: measunit.h:186
icu::UMEASURE_PREFIX_TERA
@ UMEASURE_PREFIX_TERA
SI prefix: tera, 10^12.
Definition: measunit.h:144
icu::UMEASURE_PREFIX_CENTI
@ UMEASURE_PREFIX_CENTI
SI prefix: centi, 10^-2.
Definition: measunit.h:193
icu::UMEASURE_PREFIX_MEGA
@ UMEASURE_PREFIX_MEGA
SI prefix: mega, 10^6.
Definition: measunit.h:158
icu::UMEASURE_PREFIX_INTERNAL_MAX_SI
@ UMEASURE_PREFIX_INTERNAL_MAX_SI
ICU use only.
Definition: measunit.h:115
icu::UMEASURE_PREFIX_ZEPTO
@ UMEASURE_PREFIX_ZEPTO
SI prefix: zepto, 10^-21.
Definition: measunit.h:242
icu::UMEASURE_PREFIX_MICRO
@ UMEASURE_PREFIX_MICRO
SI prefix: micro, 10^-6.
Definition: measunit.h:207
icu::UMEASURE_PREFIX_INTERNAL_MAX_BIN
@ UMEASURE_PREFIX_INTERNAL_MAX_BIN
ICU use only.
Definition: measunit.h:340
icu::UMEASURE_PREFIX_YOCTO
@ UMEASURE_PREFIX_YOCTO
SI prefix: yocto, 10^-24.
Definition: measunit.h:249
icu::UMEASURE_PREFIX_ZETTA
@ UMEASURE_PREFIX_ZETTA
SI prefix: zetta, 10^21.
Definition: measunit.h:123
icu::UMEASURE_PREFIX_NANO
@ UMEASURE_PREFIX_NANO
SI prefix: nano, 10^-9.
Definition: measunit.h:214
icu::UMEASURE_PREFIX_PICO
@ UMEASURE_PREFIX_PICO
SI prefix: pico, 10^-12.
Definition: measunit.h:221
icu::UMEASURE_PREFIX_MEBI
@ UMEASURE_PREFIX_MEBI
Binary prefix: mebi, 1024^2.
Definition: measunit.h:290
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::UMEASURE_PREFIX_EXA
@ UMEASURE_PREFIX_EXA
SI prefix: exa, 10^18.
Definition: measunit.h:130
icu::umeas_getPrefixBase
U_CAPI int32_t umeas_getPrefixBase(UMeasurePrefix unitPrefix)
Returns the base of the factor associated with the given unit prefix: the base is 10 for SI prefixes ...
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:61
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
icu::UMEASURE_PREFIX_GIGA
@ UMEASURE_PREFIX_GIGA
SI prefix: giga, 10^9.
Definition: measunit.h:151
icu::MeasureUnit::operator!=
bool operator!=(const UObject &other) const
Inequality operator.
Definition: measunit.h:442
icu::UMEASURE_PREFIX_TEBI
@ UMEASURE_PREFIX_TEBI
Binary prefix: tebi, 1024^4.
Definition: measunit.h:304
icu::UMEASURE_UNIT_MIXED
@ UMEASURE_UNIT_MIXED
A mixed unit, like hour+minute.
Definition: measunit.h:76
icu::UMEASURE_PREFIX_ZEBI
@ UMEASURE_PREFIX_ZEBI
Binary prefix: zebi, 1024^7.
Definition: measunit.h:325
icu::UMEASURE_PREFIX_INTERNAL_MIN_SI
@ UMEASURE_PREFIX_INTERNAL_MIN_SI
ICU use only.
Definition: measunit.h:257
icu::UMEASURE_PREFIX_INTERNAL_ONE_BIN
@ UMEASURE_PREFIX_INTERNAL_ONE_BIN
ICU use only.
Definition: measunit.h:267
icu::UMeasurePrefix
UMeasurePrefix
Enumeration for SI and binary prefixes, e.g.
Definition: measunit.h:90
icu::UMeasurePrefix
enum icu::UMeasurePrefix UMeasurePrefix
Enumeration for SI and binary prefixes, e.g.
icu::UMEASURE_PREFIX_KIBI
@ UMEASURE_PREFIX_KIBI
Binary prefix: kibi, 1024^1.
Definition: measunit.h:274
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
icu::UMEASURE_UNIT_SINGLE
@ UMEASURE_UNIT_SINGLE
A single unit, like kilojoule.
Definition: measunit.h:62
icu::LocalArray
"Smart pointer" class, deletes objects via the C++ array delete[] operator.
Definition: localpointer.h:366
icu::UMEASURE_PREFIX_INTERNAL_MIN_BIN
@ UMEASURE_PREFIX_INTERNAL_MIN_BIN
ICU use only.
Definition: measunit.h:282
icu::UMEASURE_PREFIX_ONE
@ UMEASURE_PREFIX_ONE
The absence of an SI or binary prefix.
Definition: measunit.h:100
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:60
icu::umeas_getPrefixPower
U_CAPI int32_t umeas_getPrefixPower(UMeasurePrefix unitPrefix)
Returns the exponent of the factor associated with the given unit prefix, for example 3 for kilo,...
unistr.h
C++ API: Unicode String.
icu::UMEASURE_PREFIX_YOBI
@ UMEASURE_PREFIX_YOBI
Binary prefix: yobi, 1024^8.
Definition: measunit.h:332
icu::UMEASURE_PREFIX_PETA
@ UMEASURE_PREFIX_PETA
SI prefix: peta, 10^15.
Definition: measunit.h:137
icu::UMeasureUnitComplexity
UMeasureUnitComplexity
Enumeration for unit complexity.
Definition: measunit.h:56
icu::UMEASURE_PREFIX_YOTTA
@ UMEASURE_PREFIX_YOTTA
SI prefix: yotta, 10^24.
Definition: measunit.h:107