ICU 69.1 69.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
80 #ifndef U_HIDE_DRAFT_API
81
91 typedef enum UMeasurePrefix {
101 UMEASURE_PREFIX_ONE = 30 + 0,
102
108 UMEASURE_PREFIX_YOTTA = UMEASURE_PREFIX_ONE + 24,
109
115 UMEASURE_PREFIX_INTERNAL_MAX_SI = UMEASURE_PREFIX_YOTTA,
116
122 UMEASURE_PREFIX_ZETTA = UMEASURE_PREFIX_ONE + 21,
123
129 UMEASURE_PREFIX_EXA = UMEASURE_PREFIX_ONE + 18,
130
136 UMEASURE_PREFIX_PETA = UMEASURE_PREFIX_ONE + 15,
137
143 UMEASURE_PREFIX_TERA = UMEASURE_PREFIX_ONE + 12,
144
150 UMEASURE_PREFIX_GIGA = UMEASURE_PREFIX_ONE + 9,
151
157 UMEASURE_PREFIX_MEGA = UMEASURE_PREFIX_ONE + 6,
158
164 UMEASURE_PREFIX_KILO = UMEASURE_PREFIX_ONE + 3,
165
171 UMEASURE_PREFIX_HECTO = UMEASURE_PREFIX_ONE + 2,
172
178 UMEASURE_PREFIX_DEKA = UMEASURE_PREFIX_ONE + 1,
179
185 UMEASURE_PREFIX_DECI = UMEASURE_PREFIX_ONE + -1,
186
192 UMEASURE_PREFIX_CENTI = UMEASURE_PREFIX_ONE + -2,
193
199 UMEASURE_PREFIX_MILLI = UMEASURE_PREFIX_ONE + -3,
200
206 UMEASURE_PREFIX_MICRO = UMEASURE_PREFIX_ONE + -6,
207
213 UMEASURE_PREFIX_NANO = UMEASURE_PREFIX_ONE + -9,
214
220 UMEASURE_PREFIX_PICO = UMEASURE_PREFIX_ONE + -12,
221
227 UMEASURE_PREFIX_FEMTO = UMEASURE_PREFIX_ONE + -15,
228
234 UMEASURE_PREFIX_ATTO = UMEASURE_PREFIX_ONE + -18,
235
241 UMEASURE_PREFIX_ZEPTO = UMEASURE_PREFIX_ONE + -21,
242
248 UMEASURE_PREFIX_YOCTO = UMEASURE_PREFIX_ONE + -24,
249
250 #ifndef U_HIDE_INTERNAL_API
251
256 UMEASURE_PREFIX_INTERNAL_MIN_SI = UMEASURE_PREFIX_YOCTO,
257 #endif // U_HIDE_INTERNAL_API
258
259 // Cannot conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
260 // used in definitions of non-internal enum values
266 UMEASURE_PREFIX_INTERNAL_ONE_BIN = -60,
267
273 UMEASURE_PREFIX_KIBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 1,
274
275 #ifndef U_HIDE_INTERNAL_API
276
281 UMEASURE_PREFIX_INTERNAL_MIN_BIN = UMEASURE_PREFIX_KIBI,
282 #endif // U_HIDE_INTERNAL_API
283
289 UMEASURE_PREFIX_MEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 2,
290
296 UMEASURE_PREFIX_GIBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 3,
297
303 UMEASURE_PREFIX_TEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 4,
304
310 UMEASURE_PREFIX_PEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 5,
311
317 UMEASURE_PREFIX_EXBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 6,
318
324 UMEASURE_PREFIX_ZEBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 7,
325
331 UMEASURE_PREFIX_YOBI = UMEASURE_PREFIX_INTERNAL_ONE_BIN + 8,
332
333 #ifndef U_HIDE_INTERNAL_API
334
339 UMEASURE_PREFIX_INTERNAL_MAX_BIN = UMEASURE_PREFIX_YOBI,
340 #endif // U_HIDE_INTERNAL_API
341 } UMeasurePrefix;
342
350 U_CAPI int32_t U_EXPORT2 umeas_getPrefixBase(UMeasurePrefix unitPrefix);
351
358 U_CAPI int32_t U_EXPORT2 umeas_getPrefixPower(UMeasurePrefix unitPrefix);
359
360 #endif // U_HIDE_DRAFT_API
361
369 class U_I18N_API MeasureUnit: public UObject {
370 public:
371
377 MeasureUnit();
378
383 MeasureUnit(const MeasureUnit &other);
384
389 MeasureUnit(MeasureUnit &&other) noexcept;
390
404 static MeasureUnit forIdentifier(StringPiece identifier, UErrorCode& status);
405
410 MeasureUnit &operator=(const MeasureUnit &other);
411
416 MeasureUnit &operator=(MeasureUnit &&other) noexcept;
417
423 virtual MeasureUnit* clone() const;
424
429 virtual ~MeasureUnit();
430
436 virtual UBool operator==(const UObject& other) const;
437
443 UBool operator!=(const UObject& other) const {
444 return !(*this == other);
445 }
446
454 const char *getType() const;
455
463 const char *getSubtype() const;
464
471 const char* getIdentifier() const;
472
480 UMeasureUnitComplexity getComplexity(UErrorCode& status) const;
481
482 #ifndef U_HIDE_DRAFT_API
483
497 MeasureUnit withPrefix(UMeasurePrefix prefix, UErrorCode& status) const;
498
513 UMeasurePrefix getPrefix(UErrorCode& status) const;
514 #endif // U_HIDE_DRAFT_API
515
530 MeasureUnit withDimensionality(int32_t dimensionality, UErrorCode& status) const;
531
545 int32_t getDimensionality(UErrorCode& status) const;
546
559 MeasureUnit reciprocal(UErrorCode& status) const;
560
578 MeasureUnit product(const MeasureUnit& other, UErrorCode& status) const;
579
580 #ifndef U_HIDE_DRAFT_API
581
596 inline std::pair<LocalArray<MeasureUnit>, int32_t> splitToSingleUnits(UErrorCode& status) const;
597 #endif // U_HIDE_DRAFT_API
598
610 static int32_t getAvailable(
611 MeasureUnit *destArray,
612 int32_t destCapacity,
613 UErrorCode &errorCode);
614
627 static int32_t getAvailable(
628 const char *type,
629 MeasureUnit *destArray,
630 int32_t destCapacity,
631 UErrorCode &errorCode);
632
641 static StringEnumeration* getAvailableTypes(UErrorCode &errorCode);
642
654 static UClassID U_EXPORT2 getStaticClassID(void);
655
667 virtual UClassID getDynamicClassID(void) const;
668
669 #ifndef U_HIDE_INTERNAL_API
670
675 int32_t getOffset() const;
676 #endif /* U_HIDE_INTERNAL_API */
677
678 // All code between the "Start generated createXXX methods" comment and
679 // the "End generated createXXX methods" comment is auto generated code
680 // and must not be edited manually. For instructions on how to correctly
681 // update this code, refer to:
682 // docs/processes/release/tasks/updating-measure-unit.md
683 //
684 // Start generated createXXX methods
685
693 static MeasureUnit *createGForce(UErrorCode &status);
694
700 static MeasureUnit getGForce();
701
709 static MeasureUnit *createMeterPerSecondSquared(UErrorCode &status);
710
716 static MeasureUnit getMeterPerSecondSquared();
717
725 static MeasureUnit *createArcMinute(UErrorCode &status);
726
732 static MeasureUnit getArcMinute();
733
741 static MeasureUnit *createArcSecond(UErrorCode &status);
742
748 static MeasureUnit getArcSecond();
749
757 static MeasureUnit *createDegree(UErrorCode &status);
758
764 static MeasureUnit getDegree();
765
773 static MeasureUnit *createRadian(UErrorCode &status);
774
780 static MeasureUnit getRadian();
781
789 static MeasureUnit *createRevolutionAngle(UErrorCode &status);
790
796 static MeasureUnit getRevolutionAngle();
797
805 static MeasureUnit *createAcre(UErrorCode &status);
806
812 static MeasureUnit getAcre();
813
821 static MeasureUnit *createDunam(UErrorCode &status);
822
828 static MeasureUnit getDunam();
829
837 static MeasureUnit *createHectare(UErrorCode &status);
838
844 static MeasureUnit getHectare();
845
853 static MeasureUnit *createSquareCentimeter(UErrorCode &status);
854
860 static MeasureUnit getSquareCentimeter();
861
869 static MeasureUnit *createSquareFoot(UErrorCode &status);
870
876 static MeasureUnit getSquareFoot();
877
885 static MeasureUnit *createSquareInch(UErrorCode &status);
886
892 static MeasureUnit getSquareInch();
893
901 static MeasureUnit *createSquareKilometer(UErrorCode &status);
902
908 static MeasureUnit getSquareKilometer();
909
917 static MeasureUnit *createSquareMeter(UErrorCode &status);
918
924 static MeasureUnit getSquareMeter();
925
933 static MeasureUnit *createSquareMile(UErrorCode &status);
934
940 static MeasureUnit getSquareMile();
941
949 static MeasureUnit *createSquareYard(UErrorCode &status);
950
956 static MeasureUnit getSquareYard();
957
965 static MeasureUnit *createKarat(UErrorCode &status);
966
972 static MeasureUnit getKarat();
973
974 #ifndef U_HIDE_DRAFT_API
975
982 static MeasureUnit *createMilligramOfglucosePerDeciliter(UErrorCode &status);
983
989 static MeasureUnit getMilligramOfglucosePerDeciliter();
990 #endif /* U_HIDE_DRAFT_API */
991
999 static MeasureUnit *createMilligramPerDeciliter(UErrorCode &status);
1000
1006 static MeasureUnit getMilligramPerDeciliter();
1007
1015 static MeasureUnit *createMillimolePerLiter(UErrorCode &status);
1016
1022 static MeasureUnit getMillimolePerLiter();
1023
1031 static MeasureUnit *createMole(UErrorCode &status);
1032
1038 static MeasureUnit getMole();
1039
1047 static MeasureUnit *createPercent(UErrorCode &status);
1048
1054 static MeasureUnit getPercent();
1055
1063 static MeasureUnit *createPermille(UErrorCode &status);
1064
1070 static MeasureUnit getPermille();
1071
1079 static MeasureUnit *createPartPerMillion(UErrorCode &status);
1080
1086 static MeasureUnit getPartPerMillion();
1087
1095 static MeasureUnit *createPermyriad(UErrorCode &status);
1096
1102 static MeasureUnit getPermyriad();
1103
1111 static MeasureUnit *createLiterPer100Kilometers(UErrorCode &status);
1112
1118 static MeasureUnit getLiterPer100Kilometers();
1119
1127 static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
1128
1134 static MeasureUnit getLiterPerKilometer();
1135
1143 static MeasureUnit *createMilePerGallon(UErrorCode &status);
1144
1150 static MeasureUnit getMilePerGallon();
1151
1159 static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
1160
1166 static MeasureUnit getMilePerGallonImperial();
1167
1175 static MeasureUnit *createBit(UErrorCode &status);
1176
1182 static MeasureUnit getBit();
1183
1191 static MeasureUnit *createByte(UErrorCode &status);
1192
1198 static MeasureUnit getByte();
1199
1207 static MeasureUnit *createGigabit(UErrorCode &status);
1208
1214 static MeasureUnit getGigabit();
1215
1223 static MeasureUnit *createGigabyte(UErrorCode &status);
1224
1230 static MeasureUnit getGigabyte();
1231
1239 static MeasureUnit *createKilobit(UErrorCode &status);
1240
1246 static MeasureUnit getKilobit();
1247
1255 static MeasureUnit *createKilobyte(UErrorCode &status);
1256
1262 static MeasureUnit getKilobyte();
1263
1271 static MeasureUnit *createMegabit(UErrorCode &status);
1272
1278 static MeasureUnit getMegabit();
1279
1287 static MeasureUnit *createMegabyte(UErrorCode &status);
1288
1294 static MeasureUnit getMegabyte();
1295
1303 static MeasureUnit *createPetabyte(UErrorCode &status);
1304
1310 static MeasureUnit getPetabyte();
1311
1319 static MeasureUnit *createTerabit(UErrorCode &status);
1320
1326 static MeasureUnit getTerabit();
1327
1335 static MeasureUnit *createTerabyte(UErrorCode &status);
1336
1342 static MeasureUnit getTerabyte();
1343
1351 static MeasureUnit *createCentury(UErrorCode &status);
1352
1358 static MeasureUnit getCentury();
1359
1367 static MeasureUnit *createDay(UErrorCode &status);
1368
1374 static MeasureUnit getDay();
1375
1383 static MeasureUnit *createDayPerson(UErrorCode &status);
1384
1390 static MeasureUnit getDayPerson();
1391
1399 static MeasureUnit *createDecade(UErrorCode &status);
1400
1406 static MeasureUnit getDecade();
1407
1415 static MeasureUnit *createHour(UErrorCode &status);
1416
1422 static MeasureUnit getHour();
1423
1431 static MeasureUnit *createMicrosecond(UErrorCode &status);
1432
1438 static MeasureUnit getMicrosecond();
1439
1447 static MeasureUnit *createMillisecond(UErrorCode &status);
1448
1454 static MeasureUnit getMillisecond();
1455
1463 static MeasureUnit *createMinute(UErrorCode &status);
1464
1470 static MeasureUnit getMinute();
1471
1479 static MeasureUnit *createMonth(UErrorCode &status);
1480
1486 static MeasureUnit getMonth();
1487
1495 static MeasureUnit *createMonthPerson(UErrorCode &status);
1496
1502 static MeasureUnit getMonthPerson();
1503
1511 static MeasureUnit *createNanosecond(UErrorCode &status);
1512
1518 static MeasureUnit getNanosecond();
1519
1527 static MeasureUnit *createSecond(UErrorCode &status);
1528
1534 static MeasureUnit getSecond();
1535
1543 static MeasureUnit *createWeek(UErrorCode &status);
1544
1550 static MeasureUnit getWeek();
1551
1559 static MeasureUnit *createWeekPerson(UErrorCode &status);
1560
1566 static MeasureUnit getWeekPerson();
1567
1575 static MeasureUnit *createYear(UErrorCode &status);
1576
1582 static MeasureUnit getYear();
1583
1591 static MeasureUnit *createYearPerson(UErrorCode &status);
1592
1598 static MeasureUnit getYearPerson();
1599
1607 static MeasureUnit *createAmpere(UErrorCode &status);
1608
1614 static MeasureUnit getAmpere();
1615
1623 static MeasureUnit *createMilliampere(UErrorCode &status);
1624
1630 static MeasureUnit getMilliampere();
1631
1639 static MeasureUnit *createOhm(UErrorCode &status);
1640
1646 static MeasureUnit getOhm();
1647
1655 static MeasureUnit *createVolt(UErrorCode &status);
1656
1662 static MeasureUnit getVolt();
1663
1671 static MeasureUnit *createBritishThermalUnit(UErrorCode &status);
1672
1678 static MeasureUnit getBritishThermalUnit();
1679
1687 static MeasureUnit *createCalorie(UErrorCode &status);
1688
1694 static MeasureUnit getCalorie();
1695
1703 static MeasureUnit *createElectronvolt(UErrorCode &status);
1704
1710 static MeasureUnit getElectronvolt();
1711
1719 static MeasureUnit *createFoodcalorie(UErrorCode &status);
1720
1726 static MeasureUnit getFoodcalorie();
1727
1735 static MeasureUnit *createJoule(UErrorCode &status);
1736
1742 static MeasureUnit getJoule();
1743
1751 static MeasureUnit *createKilocalorie(UErrorCode &status);
1752
1758 static MeasureUnit getKilocalorie();
1759
1767 static MeasureUnit *createKilojoule(UErrorCode &status);
1768
1774 static MeasureUnit getKilojoule();
1775
1783 static MeasureUnit *createKilowattHour(UErrorCode &status);
1784
1790 static MeasureUnit getKilowattHour();
1791
1799 static MeasureUnit *createThermUs(UErrorCode &status);
1800
1806 static MeasureUnit getThermUs();
1807
1815 static MeasureUnit *createNewton(UErrorCode &status);
1816
1822 static MeasureUnit getNewton();
1823
1831 static MeasureUnit *createPoundForce(UErrorCode &status);
1832
1838 static MeasureUnit getPoundForce();
1839
1847 static MeasureUnit *createGigahertz(UErrorCode &status);
1848
1854 static MeasureUnit getGigahertz();
1855
1863 static MeasureUnit *createHertz(UErrorCode &status);
1864
1870 static MeasureUnit getHertz();
1871
1879 static MeasureUnit *createKilohertz(UErrorCode &status);
1880
1886 static MeasureUnit getKilohertz();
1887
1895 static MeasureUnit *createMegahertz(UErrorCode &status);
1896
1902 static MeasureUnit getMegahertz();
1903
1904 #ifndef U_HIDE_DRAFT_API
1905
1912 static MeasureUnit *createDot(UErrorCode &status);
1913
1919 static MeasureUnit getDot();
1920 #endif /* U_HIDE_DRAFT_API */
1921
1929 static MeasureUnit *createDotPerCentimeter(UErrorCode &status);
1930
1936 static MeasureUnit getDotPerCentimeter();
1937
1945 static MeasureUnit *createDotPerInch(UErrorCode &status);
1946
1952 static MeasureUnit getDotPerInch();
1953
1961 static MeasureUnit *createEm(UErrorCode &status);
1962
1968 static MeasureUnit getEm();
1969
1977 static MeasureUnit *createMegapixel(UErrorCode &status);
1978
1984 static MeasureUnit getMegapixel();
1985
1993 static MeasureUnit *createPixel(UErrorCode &status);
1994
2000 static MeasureUnit getPixel();
2001
2009 static MeasureUnit *createPixelPerCentimeter(UErrorCode &status);
2010
2016 static MeasureUnit getPixelPerCentimeter();
2017
2025 static MeasureUnit *createPixelPerInch(UErrorCode &status);
2026
2032 static MeasureUnit getPixelPerInch();
2033
2041 static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
2042
2048 static MeasureUnit getAstronomicalUnit();
2049
2057 static MeasureUnit *createCentimeter(UErrorCode &status);
2058
2064 static MeasureUnit getCentimeter();
2065
2073 static MeasureUnit *createDecimeter(UErrorCode &status);
2074
2080 static MeasureUnit getDecimeter();
2081
2082 #ifndef U_HIDE_DRAFT_API
2083
2090 static MeasureUnit *createEarthRadius(UErrorCode &status);
2091
2097 static MeasureUnit getEarthRadius();
2098 #endif /* U_HIDE_DRAFT_API */
2099
2107 static MeasureUnit *createFathom(UErrorCode &status);
2108
2114 static MeasureUnit getFathom();
2115
2123 static MeasureUnit *createFoot(UErrorCode &status);
2124
2130 static MeasureUnit getFoot();
2131
2139 static MeasureUnit *createFurlong(UErrorCode &status);
2140
2146 static MeasureUnit getFurlong();
2147
2155 static MeasureUnit *createInch(UErrorCode &status);
2156
2162 static MeasureUnit getInch();
2163
2171 static MeasureUnit *createKilometer(UErrorCode &status);
2172
2178 static MeasureUnit getKilometer();
2179
2187 static MeasureUnit *createLightYear(UErrorCode &status);
2188
2194 static MeasureUnit getLightYear();
2195
2203 static MeasureUnit *createMeter(UErrorCode &status);
2204
2210 static MeasureUnit getMeter();
2211
2219 static MeasureUnit *createMicrometer(UErrorCode &status);
2220
2226 static MeasureUnit getMicrometer();
2227
2235 static MeasureUnit *createMile(UErrorCode &status);
2236
2242 static MeasureUnit getMile();
2243
2251 static MeasureUnit *createMileScandinavian(UErrorCode &status);
2252
2258 static MeasureUnit getMileScandinavian();
2259
2267 static MeasureUnit *createMillimeter(UErrorCode &status);
2268
2274 static MeasureUnit getMillimeter();
2275
2283 static MeasureUnit *createNanometer(UErrorCode &status);
2284
2290 static MeasureUnit getNanometer();
2291
2299 static MeasureUnit *createNauticalMile(UErrorCode &status);
2300
2306 static MeasureUnit getNauticalMile();
2307
2315 static MeasureUnit *createParsec(UErrorCode &status);
2316
2322 static MeasureUnit getParsec();
2323
2331 static MeasureUnit *createPicometer(UErrorCode &status);
2332
2338 static MeasureUnit getPicometer();
2339
2347 static MeasureUnit *createPoint(UErrorCode &status);
2348
2354 static MeasureUnit getPoint();
2355
2363 static MeasureUnit *createSolarRadius(UErrorCode &status);
2364
2370 static MeasureUnit getSolarRadius();
2371
2379 static MeasureUnit *createYard(UErrorCode &status);
2380
2386 static MeasureUnit getYard();
2387
2388 #ifndef U_HIDE_DRAFT_API
2389
2396 static MeasureUnit *createCandela(UErrorCode &status);
2397
2403 static MeasureUnit getCandela();
2404 #endif /* U_HIDE_DRAFT_API */
2405
2406 #ifndef U_HIDE_DRAFT_API
2407
2414 static MeasureUnit *createLumen(UErrorCode &status);
2415
2421 static MeasureUnit getLumen();
2422 #endif /* U_HIDE_DRAFT_API */
2423
2431 static MeasureUnit *createLux(UErrorCode &status);
2432
2438 static MeasureUnit getLux();
2439
2447 static MeasureUnit *createSolarLuminosity(UErrorCode &status);
2448
2454 static MeasureUnit getSolarLuminosity();
2455
2463 static MeasureUnit *createCarat(UErrorCode &status);
2464
2470 static MeasureUnit getCarat();
2471
2479 static MeasureUnit *createDalton(UErrorCode &status);
2480
2486 static MeasureUnit getDalton();
2487
2495 static MeasureUnit *createEarthMass(UErrorCode &status);
2496
2502 static MeasureUnit getEarthMass();
2503
2504 #ifndef U_HIDE_DRAFT_API
2505
2512 static MeasureUnit *createGrain(UErrorCode &status);
2513
2519 static MeasureUnit getGrain();
2520 #endif /* U_HIDE_DRAFT_API */
2521
2529 static MeasureUnit *createGram(UErrorCode &status);
2530
2536 static MeasureUnit getGram();
2537
2545 static MeasureUnit *createKilogram(UErrorCode &status);
2546
2552 static MeasureUnit getKilogram();
2553
2561 static MeasureUnit *createMetricTon(UErrorCode &status);
2562
2568 static MeasureUnit getMetricTon();
2569
2577 static MeasureUnit *createMicrogram(UErrorCode &status);
2578
2584 static MeasureUnit getMicrogram();
2585
2593 static MeasureUnit *createMilligram(UErrorCode &status);
2594
2600 static MeasureUnit getMilligram();
2601
2609 static MeasureUnit *createOunce(UErrorCode &status);
2610
2616 static MeasureUnit getOunce();
2617
2625 static MeasureUnit *createOunceTroy(UErrorCode &status);
2626
2632 static MeasureUnit getOunceTroy();
2633
2641 static MeasureUnit *createPound(UErrorCode &status);
2642
2648 static MeasureUnit getPound();
2649
2657 static MeasureUnit *createSolarMass(UErrorCode &status);
2658
2664 static MeasureUnit getSolarMass();
2665
2673 static MeasureUnit *createStone(UErrorCode &status);
2674
2680 static MeasureUnit getStone();
2681
2689 static MeasureUnit *createTon(UErrorCode &status);
2690
2696 static MeasureUnit getTon();
2697
2705 static MeasureUnit *createGigawatt(UErrorCode &status);
2706
2712 static MeasureUnit getGigawatt();
2713
2721 static MeasureUnit *createHorsepower(UErrorCode &status);
2722
2728 static MeasureUnit getHorsepower();
2729
2737 static MeasureUnit *createKilowatt(UErrorCode &status);
2738
2744 static MeasureUnit getKilowatt();
2745
2753 static MeasureUnit *createMegawatt(UErrorCode &status);
2754
2760 static MeasureUnit getMegawatt();
2761
2769 static MeasureUnit *createMilliwatt(UErrorCode &status);
2770
2776 static MeasureUnit getMilliwatt();
2777
2785 static MeasureUnit *createWatt(UErrorCode &status);
2786
2792 static MeasureUnit getWatt();
2793
2801 static MeasureUnit *createAtmosphere(UErrorCode &status);
2802
2808 static MeasureUnit getAtmosphere();
2809
2817 static MeasureUnit *createBar(UErrorCode &status);
2818
2824 static MeasureUnit getBar();
2825
2833 static MeasureUnit *createHectopascal(UErrorCode &status);
2834
2840 static MeasureUnit getHectopascal();
2841
2849 static MeasureUnit *createInchHg(UErrorCode &status);
2850
2856 static MeasureUnit getInchHg();
2857
2865 static MeasureUnit *createKilopascal(UErrorCode &status);
2866
2872 static MeasureUnit getKilopascal();
2873
2881 static MeasureUnit *createMegapascal(UErrorCode &status);
2882
2888 static MeasureUnit getMegapascal();
2889
2897 static MeasureUnit *createMillibar(UErrorCode &status);
2898
2904 static MeasureUnit getMillibar();
2905
2913 static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
2914
2920 static MeasureUnit getMillimeterOfMercury();
2921
2929 static MeasureUnit *createPascal(UErrorCode &status);
2930
2936 static MeasureUnit getPascal();
2937
2945 static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
2946
2952 static MeasureUnit getPoundPerSquareInch();
2953
2961 static MeasureUnit *createKilometerPerHour(UErrorCode &status);
2962
2968 static MeasureUnit getKilometerPerHour();
2969
2977 static MeasureUnit *createKnot(UErrorCode &status);
2978
2984 static MeasureUnit getKnot();
2985
2993 static MeasureUnit *createMeterPerSecond(UErrorCode &status);
2994
3000 static MeasureUnit getMeterPerSecond();
3001
3009 static MeasureUnit *createMilePerHour(UErrorCode &status);
3010
3016 static MeasureUnit getMilePerHour();
3017
3025 static MeasureUnit *createCelsius(UErrorCode &status);
3026
3032 static MeasureUnit getCelsius();
3033
3041 static MeasureUnit *createFahrenheit(UErrorCode &status);
3042
3048 static MeasureUnit getFahrenheit();
3049
3057 static MeasureUnit *createGenericTemperature(UErrorCode &status);
3058
3064 static MeasureUnit getGenericTemperature();
3065
3073 static MeasureUnit *createKelvin(UErrorCode &status);
3074
3080 static MeasureUnit getKelvin();
3081
3089 static MeasureUnit *createNewtonMeter(UErrorCode &status);
3090
3096 static MeasureUnit getNewtonMeter();
3097
3105 static MeasureUnit *createPoundFoot(UErrorCode &status);
3106
3112 static MeasureUnit getPoundFoot();
3113
3121 static MeasureUnit *createAcreFoot(UErrorCode &status);
3122
3128 static MeasureUnit getAcreFoot();
3129
3137 static MeasureUnit *createBarrel(UErrorCode &status);
3138
3144 static MeasureUnit getBarrel();
3145
3153 static MeasureUnit *createBushel(UErrorCode &status);
3154
3160 static MeasureUnit getBushel();
3161
3169 static MeasureUnit *createCentiliter(UErrorCode &status);
3170
3176 static MeasureUnit getCentiliter();
3177
3185 static MeasureUnit *createCubicCentimeter(UErrorCode &status);
3186
3192 static MeasureUnit getCubicCentimeter();
3193
3201 static MeasureUnit *createCubicFoot(UErrorCode &status);
3202
3208 static MeasureUnit getCubicFoot();
3209
3217 static MeasureUnit *createCubicInch(UErrorCode &status);
3218
3224 static MeasureUnit getCubicInch();
3225
3233 static MeasureUnit *createCubicKilometer(UErrorCode &status);
3234
3240 static MeasureUnit getCubicKilometer();
3241
3249 static MeasureUnit *createCubicMeter(UErrorCode &status);
3250
3256 static MeasureUnit getCubicMeter();
3257
3265 static MeasureUnit *createCubicMile(UErrorCode &status);
3266
3272 static MeasureUnit getCubicMile();
3273
3281 static MeasureUnit *createCubicYard(UErrorCode &status);
3282
3288 static MeasureUnit getCubicYard();
3289
3297 static MeasureUnit *createCup(UErrorCode &status);
3298
3304 static MeasureUnit getCup();
3305
3313 static MeasureUnit *createCupMetric(UErrorCode &status);
3314
3320 static MeasureUnit getCupMetric();
3321
3329 static MeasureUnit *createDeciliter(UErrorCode &status);
3330
3336 static MeasureUnit getDeciliter();
3337
3338 #ifndef U_HIDE_DRAFT_API
3339
3346 static MeasureUnit *createDessertSpoon(UErrorCode &status);
3347
3353 static MeasureUnit getDessertSpoon();
3354 #endif /* U_HIDE_DRAFT_API */
3355
3356 #ifndef U_HIDE_DRAFT_API
3357
3364 static MeasureUnit *createDessertSpoonImperial(UErrorCode &status);
3365
3371 static MeasureUnit getDessertSpoonImperial();
3372 #endif /* U_HIDE_DRAFT_API */
3373
3374 #ifndef U_HIDE_DRAFT_API
3375
3382 static MeasureUnit *createDram(UErrorCode &status);
3383
3389 static MeasureUnit getDram();
3390 #endif /* U_HIDE_DRAFT_API */
3391
3392 #ifndef U_HIDE_DRAFT_API
3393
3400 static MeasureUnit *createDrop(UErrorCode &status);
3401
3407 static MeasureUnit getDrop();
3408 #endif /* U_HIDE_DRAFT_API */
3409
3417 static MeasureUnit *createFluidOunce(UErrorCode &status);
3418
3424 static MeasureUnit getFluidOunce();
3425
3433 static MeasureUnit *createFluidOunceImperial(UErrorCode &status);
3434
3440 static MeasureUnit getFluidOunceImperial();
3441
3449 static MeasureUnit *createGallon(UErrorCode &status);
3450
3456 static MeasureUnit getGallon();
3457
3465 static MeasureUnit *createGallonImperial(UErrorCode &status);
3466
3472 static MeasureUnit getGallonImperial();
3473
3481 static MeasureUnit *createHectoliter(UErrorCode &status);
3482
3488 static MeasureUnit getHectoliter();
3489
3490 #ifndef U_HIDE_DRAFT_API
3491
3498 static MeasureUnit *createJigger(UErrorCode &status);
3499
3505 static MeasureUnit getJigger();
3506 #endif /* U_HIDE_DRAFT_API */
3507
3515 static MeasureUnit *createLiter(UErrorCode &status);
3516
3522 static MeasureUnit getLiter();
3523
3531 static MeasureUnit *createMegaliter(UErrorCode &status);
3532
3538 static MeasureUnit getMegaliter();
3539
3547 static MeasureUnit *createMilliliter(UErrorCode &status);
3548
3554 static MeasureUnit getMilliliter();
3555
3556 #ifndef U_HIDE_DRAFT_API
3557
3564 static MeasureUnit *createPinch(UErrorCode &status);
3565
3571 static MeasureUnit getPinch();
3572 #endif /* U_HIDE_DRAFT_API */
3573
3581 static MeasureUnit *createPint(UErrorCode &status);
3582
3588 static MeasureUnit getPint();
3589
3597 static MeasureUnit *createPintMetric(UErrorCode &status);
3598
3604 static MeasureUnit getPintMetric();
3605
3613 static MeasureUnit *createQuart(UErrorCode &status);
3614
3620 static MeasureUnit getQuart();
3621
3622 #ifndef U_HIDE_DRAFT_API
3623
3630 static MeasureUnit *createQuartImperial(UErrorCode &status);
3631
3637 static MeasureUnit getQuartImperial();
3638 #endif /* U_HIDE_DRAFT_API */
3639
3647 static MeasureUnit *createTablespoon(UErrorCode &status);
3648
3654 static MeasureUnit getTablespoon();
3655
3663 static MeasureUnit *createTeaspoon(UErrorCode &status);
3664
3670 static MeasureUnit getTeaspoon();
3671
3672 // End generated createXXX methods
3673
3674 protected:
3675
3676 #ifndef U_HIDE_INTERNAL_API
3677
3681 void initTime(const char *timeId);
3682
3687 void initCurrency(StringPiece isoCurrency);
3688
3689 #endif /* U_HIDE_INTERNAL_API */
3690
3691 private:
3692
3693 // Used by new draft APIs in ICU 67. If non-null, fImpl is owned by the
3694 // MeasureUnit.
3695 MeasureUnitImpl* fImpl;
3696
3697 // An index into a static string list in measunit.cpp. If set to -1, fImpl
3698 // is in use instead of fTypeId and fSubTypeId.
3699 int16_t fSubTypeId;
3700 // An index into a static string list in measunit.cpp. If set to -1, fImpl
3701 // is in use instead of fTypeId and fSubTypeId.
3702 int8_t fTypeId;
3703
3704 MeasureUnit(int32_t typeId, int32_t subTypeId);
3705 MeasureUnit(MeasureUnitImpl&& impl);
3706 void setTo(int32_t typeId, int32_t subTypeId);
3707 static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
3708
3716 static bool findBySubType(StringPiece subType, MeasureUnit* output);
3717
3719 LocalArray<MeasureUnit> splitToSingleUnitsImpl(int32_t& outCount, UErrorCode& status) const;
3720
3721 friend class MeasureUnitImpl;
3722
3723 // For access to findBySubType
3724 friend class number::impl::LongNameHandler;
3725 };
3726
3727 #ifndef U_HIDE_DRAFT_API
3728 // inline impl of @draft ICU 68 method
3729 inline std::pair<LocalArray<MeasureUnit>, int32_t>
3730 MeasureUnit::splitToSingleUnits(UErrorCode& status) const {
3731 int32_t length;
3732 auto array = splitToSingleUnitsImpl(length, status);
3733 return std::make_pair(std::move(array), length);
3734 }
3735 #endif // U_HIDE_DRAFT_API
3736
3737 U_NAMESPACE_END
3738
3739 #endif // !UNCONFIG_NO_FORMATTING
3740
3741 #endif /* U_SHOW_CPLUSPLUS_API */
3742
3743 #endif // __MEASUREUNIT_H__
icu::UMEASURE_PREFIX_ATTO
@ UMEASURE_PREFIX_ATTO
SI prefix: atto, 10^-18.
Definition: measunit.h:234
icu::MeasureUnit
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:369
icu::UMEASURE_PREFIX_HECTO
@ UMEASURE_PREFIX_HECTO
SI prefix: hecto, 10^2.
Definition: measunit.h:171
icu::UMEASURE_PREFIX_KILO
@ UMEASURE_PREFIX_KILO
SI prefix: kilo, 10^3.
Definition: measunit.h:164
icu::UMEASURE_PREFIX_EXBI
@ UMEASURE_PREFIX_EXBI
Binary prefix: exbi, 1024^6.
Definition: measunit.h:317
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:227
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:310
icu::UMEASURE_PREFIX_DEKA
@ UMEASURE_PREFIX_DEKA
SI prefix: deka, 10^1.
Definition: measunit.h:178
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
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:199
icu::UMEASURE_PREFIX_GIBI
@ UMEASURE_PREFIX_GIBI
Binary prefix: gibi, 1024^3.
Definition: measunit.h:296
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:185
icu::UMEASURE_PREFIX_TERA
@ UMEASURE_PREFIX_TERA
SI prefix: tera, 10^12.
Definition: measunit.h:143
icu::UMEASURE_PREFIX_CENTI
@ UMEASURE_PREFIX_CENTI
SI prefix: centi, 10^-2.
Definition: measunit.h:192
icu::UMEASURE_PREFIX_MEGA
@ UMEASURE_PREFIX_MEGA
SI prefix: mega, 10^6.
Definition: measunit.h:157
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:241
icu::UMEASURE_PREFIX_MICRO
@ UMEASURE_PREFIX_MICRO
SI prefix: micro, 10^-6.
Definition: measunit.h:206
icu::UMEASURE_PREFIX_INTERNAL_MAX_BIN
@ UMEASURE_PREFIX_INTERNAL_MAX_BIN
ICU use only.
Definition: measunit.h:339
icu::UMEASURE_PREFIX_YOCTO
@ UMEASURE_PREFIX_YOCTO
SI prefix: yocto, 10^-24.
Definition: measunit.h:248
icu::UMEASURE_PREFIX_ZETTA
@ UMEASURE_PREFIX_ZETTA
SI prefix: zetta, 10^21.
Definition: measunit.h:122
icu::UMEASURE_PREFIX_NANO
@ UMEASURE_PREFIX_NANO
SI prefix: nano, 10^-9.
Definition: measunit.h:213
icu::UMEASURE_PREFIX_PICO
@ UMEASURE_PREFIX_PICO
SI prefix: pico, 10^-12.
Definition: measunit.h:220
icu::UMEASURE_PREFIX_MEBI
@ UMEASURE_PREFIX_MEBI
Binary prefix: mebi, 1024^2.
Definition: measunit.h:289
icu::MeasureUnit::operator!=
UBool operator!=(const UObject &other) const
Inequality operator.
Definition: measunit.h:443
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:129
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:150
icu::UMEASURE_PREFIX_TEBI
@ UMEASURE_PREFIX_TEBI
Binary prefix: tebi, 1024^4.
Definition: measunit.h:303
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:324
icu::UMEASURE_PREFIX_INTERNAL_MIN_SI
@ UMEASURE_PREFIX_INTERNAL_MIN_SI
ICU use only.
Definition: measunit.h:256
icu::UMEASURE_PREFIX_INTERNAL_ONE_BIN
@ UMEASURE_PREFIX_INTERNAL_ONE_BIN
ICU use only.
Definition: measunit.h:266
icu::UMeasurePrefix
UMeasurePrefix
Enumeration for SI and binary prefixes, e.g.
Definition: measunit.h:91
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:273
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:281
icu::UMEASURE_PREFIX_ONE
@ UMEASURE_PREFIX_ONE
The absence of an SI or binary prefix.
Definition: measunit.h:101
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:331
icu::UMEASURE_PREFIX_PETA
@ UMEASURE_PREFIX_PETA
SI prefix: peta, 10^15.
Definition: measunit.h:136
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:108