ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

measunit.h
Go to the documentation of this file.
1 // Copyright (C) 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 !UCONFIG_NO_FORMATTING
19
20 #include "unicode/unistr.h"
21
27 U_NAMESPACE_BEGIN
28
29 class StringEnumeration;
30
38 class U_I18N_API MeasureUnit: public UObject {
39 public:
40
45 MeasureUnit() : fTypeId(0), fSubTypeId(0) {
46 fCurrency[0] = 0;
47 }
48
53 MeasureUnit(const MeasureUnit &other);
54
59 MeasureUnit &operator=(const MeasureUnit &other);
60
66 virtual UObject* clone() const;
67
72 virtual ~MeasureUnit();
73
79 virtual UBool operator==(const UObject& other) const;
80
86 UBool operator!=(const UObject& other) const {
87 return !(*this == other);
88 }
89
94 const char *getType() const;
95
100 const char *getSubtype() const;
101
113 static int32_t getAvailable(
114 MeasureUnit *destArray,
115 int32_t destCapacity,
116 UErrorCode &errorCode);
117
130 static int32_t getAvailable(
131 const char *type,
132 MeasureUnit *destArray,
133 int32_t destCapacity,
134 UErrorCode &errorCode);
135
144 static StringEnumeration* getAvailableTypes(UErrorCode &errorCode);
145
157 static UClassID U_EXPORT2 getStaticClassID(void);
158
170 virtual UClassID getDynamicClassID(void) const;
171
172 #ifndef U_HIDE_INTERNAL_API
173
179 int32_t getIndex() const;
180
186 static int32_t getIndexCount();
187
194 static int32_t internalGetIndexForTypeAndSubtype(const char *type, const char *subtype);
195
200 static MeasureUnit *resolveUnitPerUnit(
201 const MeasureUnit &unit, const MeasureUnit &perUnit);
202 #endif /* U_HIDE_INTERNAL_API */
203
204 // All code between the "Start generated createXXX methods" comment and
205 // the "End generated createXXX methods" comment is auto generated code
206 // and must not be edited manually. For instructions on how to correctly
207 // update this code, refer to:
208 // http://site.icu-project.org/design/formatting/measureformat/updating-measure-unit
209 //
210 // Start generated createXXX methods
211
218 static MeasureUnit *createGForce(UErrorCode &status);
219
226 static MeasureUnit *createMeterPerSecondSquared(UErrorCode &status);
227
234 static MeasureUnit *createArcMinute(UErrorCode &status);
235
242 static MeasureUnit *createArcSecond(UErrorCode &status);
243
250 static MeasureUnit *createDegree(UErrorCode &status);
251
258 static MeasureUnit *createRadian(UErrorCode &status);
259
266 static MeasureUnit *createRevolutionAngle(UErrorCode &status);
267
274 static MeasureUnit *createAcre(UErrorCode &status);
275
282 static MeasureUnit *createHectare(UErrorCode &status);
283
290 static MeasureUnit *createSquareCentimeter(UErrorCode &status);
291
298 static MeasureUnit *createSquareFoot(UErrorCode &status);
299
306 static MeasureUnit *createSquareInch(UErrorCode &status);
307
314 static MeasureUnit *createSquareKilometer(UErrorCode &status);
315
322 static MeasureUnit *createSquareMeter(UErrorCode &status);
323
330 static MeasureUnit *createSquareMile(UErrorCode &status);
331
338 static MeasureUnit *createSquareYard(UErrorCode &status);
339
346 static MeasureUnit *createKarat(UErrorCode &status);
347
348 #ifndef U_HIDE_DRAFT_API
349
355 static MeasureUnit *createMilligramPerDeciliter(UErrorCode &status);
356 #endif /* U_HIDE_DRAFT_API */
357
358 #ifndef U_HIDE_DRAFT_API
359
365 static MeasureUnit *createMillimolePerLiter(UErrorCode &status);
366 #endif /* U_HIDE_DRAFT_API */
367
368 #ifndef U_HIDE_DRAFT_API
369
375 static MeasureUnit *createPartPerMillion(UErrorCode &status);
376 #endif /* U_HIDE_DRAFT_API */
377
384 static MeasureUnit *createLiterPer100Kilometers(UErrorCode &status);
385
392 static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
393
400 static MeasureUnit *createMilePerGallon(UErrorCode &status);
401
402 #ifndef U_HIDE_DRAFT_API
403
409 static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
410 #endif /* U_HIDE_DRAFT_API */
411
412 #ifndef U_HIDE_DRAFT_API
413
419 static MeasureUnit *createEast(UErrorCode &status);
420 #endif /* U_HIDE_DRAFT_API */
421
422 #ifndef U_HIDE_DRAFT_API
423
429 static MeasureUnit *createNorth(UErrorCode &status);
430 #endif /* U_HIDE_DRAFT_API */
431
432 #ifndef U_HIDE_DRAFT_API
433
439 static MeasureUnit *createSouth(UErrorCode &status);
440 #endif /* U_HIDE_DRAFT_API */
441
442 #ifndef U_HIDE_DRAFT_API
443
449 static MeasureUnit *createWest(UErrorCode &status);
450 #endif /* U_HIDE_DRAFT_API */
451
458 static MeasureUnit *createBit(UErrorCode &status);
459
466 static MeasureUnit *createByte(UErrorCode &status);
467
474 static MeasureUnit *createGigabit(UErrorCode &status);
475
482 static MeasureUnit *createGigabyte(UErrorCode &status);
483
490 static MeasureUnit *createKilobit(UErrorCode &status);
491
498 static MeasureUnit *createKilobyte(UErrorCode &status);
499
506 static MeasureUnit *createMegabit(UErrorCode &status);
507
514 static MeasureUnit *createMegabyte(UErrorCode &status);
515
522 static MeasureUnit *createTerabit(UErrorCode &status);
523
530 static MeasureUnit *createTerabyte(UErrorCode &status);
531
538 static MeasureUnit *createCentury(UErrorCode &status);
539
546 static MeasureUnit *createDay(UErrorCode &status);
547
554 static MeasureUnit *createHour(UErrorCode &status);
555
562 static MeasureUnit *createMicrosecond(UErrorCode &status);
563
570 static MeasureUnit *createMillisecond(UErrorCode &status);
571
578 static MeasureUnit *createMinute(UErrorCode &status);
579
586 static MeasureUnit *createMonth(UErrorCode &status);
587
594 static MeasureUnit *createNanosecond(UErrorCode &status);
595
602 static MeasureUnit *createSecond(UErrorCode &status);
603
610 static MeasureUnit *createWeek(UErrorCode &status);
611
618 static MeasureUnit *createYear(UErrorCode &status);
619
626 static MeasureUnit *createAmpere(UErrorCode &status);
627
634 static MeasureUnit *createMilliampere(UErrorCode &status);
635
642 static MeasureUnit *createOhm(UErrorCode &status);
643
650 static MeasureUnit *createVolt(UErrorCode &status);
651
658 static MeasureUnit *createCalorie(UErrorCode &status);
659
666 static MeasureUnit *createFoodcalorie(UErrorCode &status);
667
674 static MeasureUnit *createJoule(UErrorCode &status);
675
682 static MeasureUnit *createKilocalorie(UErrorCode &status);
683
690 static MeasureUnit *createKilojoule(UErrorCode &status);
691
698 static MeasureUnit *createKilowattHour(UErrorCode &status);
699
706 static MeasureUnit *createGigahertz(UErrorCode &status);
707
714 static MeasureUnit *createHertz(UErrorCode &status);
715
722 static MeasureUnit *createKilohertz(UErrorCode &status);
723
730 static MeasureUnit *createMegahertz(UErrorCode &status);
731
738 static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
739
746 static MeasureUnit *createCentimeter(UErrorCode &status);
747
754 static MeasureUnit *createDecimeter(UErrorCode &status);
755
762 static MeasureUnit *createFathom(UErrorCode &status);
763
770 static MeasureUnit *createFoot(UErrorCode &status);
771
778 static MeasureUnit *createFurlong(UErrorCode &status);
779
786 static MeasureUnit *createInch(UErrorCode &status);
787
794 static MeasureUnit *createKilometer(UErrorCode &status);
795
802 static MeasureUnit *createLightYear(UErrorCode &status);
803
810 static MeasureUnit *createMeter(UErrorCode &status);
811
818 static MeasureUnit *createMicrometer(UErrorCode &status);
819
826 static MeasureUnit *createMile(UErrorCode &status);
827
834 static MeasureUnit *createMileScandinavian(UErrorCode &status);
835
842 static MeasureUnit *createMillimeter(UErrorCode &status);
843
850 static MeasureUnit *createNanometer(UErrorCode &status);
851
858 static MeasureUnit *createNauticalMile(UErrorCode &status);
859
866 static MeasureUnit *createParsec(UErrorCode &status);
867
874 static MeasureUnit *createPicometer(UErrorCode &status);
875
882 static MeasureUnit *createYard(UErrorCode &status);
883
890 static MeasureUnit *createLux(UErrorCode &status);
891
898 static MeasureUnit *createCarat(UErrorCode &status);
899
906 static MeasureUnit *createGram(UErrorCode &status);
907
914 static MeasureUnit *createKilogram(UErrorCode &status);
915
922 static MeasureUnit *createMetricTon(UErrorCode &status);
923
930 static MeasureUnit *createMicrogram(UErrorCode &status);
931
938 static MeasureUnit *createMilligram(UErrorCode &status);
939
946 static MeasureUnit *createOunce(UErrorCode &status);
947
954 static MeasureUnit *createOunceTroy(UErrorCode &status);
955
962 static MeasureUnit *createPound(UErrorCode &status);
963
970 static MeasureUnit *createStone(UErrorCode &status);
971
978 static MeasureUnit *createTon(UErrorCode &status);
979
986 static MeasureUnit *createGigawatt(UErrorCode &status);
987
994 static MeasureUnit *createHorsepower(UErrorCode &status);
995
1002 static MeasureUnit *createKilowatt(UErrorCode &status);
1003
1010 static MeasureUnit *createMegawatt(UErrorCode &status);
1011
1018 static MeasureUnit *createMilliwatt(UErrorCode &status);
1019
1026 static MeasureUnit *createWatt(UErrorCode &status);
1027
1034 static MeasureUnit *createHectopascal(UErrorCode &status);
1035
1042 static MeasureUnit *createInchHg(UErrorCode &status);
1043
1050 static MeasureUnit *createMillibar(UErrorCode &status);
1051
1058 static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1059
1066 static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1067
1074 static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1075
1082 static MeasureUnit *createKnot(UErrorCode &status);
1083
1090 static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1091
1098 static MeasureUnit *createMilePerHour(UErrorCode &status);
1099
1106 static MeasureUnit *createCelsius(UErrorCode &status);
1107
1114 static MeasureUnit *createFahrenheit(UErrorCode &status);
1115
1122 static MeasureUnit *createGenericTemperature(UErrorCode &status);
1123
1130 static MeasureUnit *createKelvin(UErrorCode &status);
1131
1138 static MeasureUnit *createAcreFoot(UErrorCode &status);
1139
1146 static MeasureUnit *createBushel(UErrorCode &status);
1147
1154 static MeasureUnit *createCentiliter(UErrorCode &status);
1155
1162 static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1163
1170 static MeasureUnit *createCubicFoot(UErrorCode &status);
1171
1178 static MeasureUnit *createCubicInch(UErrorCode &status);
1179
1186 static MeasureUnit *createCubicKilometer(UErrorCode &status);
1187
1194 static MeasureUnit *createCubicMeter(UErrorCode &status);
1195
1202 static MeasureUnit *createCubicMile(UErrorCode &status);
1203
1210 static MeasureUnit *createCubicYard(UErrorCode &status);
1211
1218 static MeasureUnit *createCup(UErrorCode &status);
1219
1226 static MeasureUnit *createCupMetric(UErrorCode &status);
1227
1234 static MeasureUnit *createDeciliter(UErrorCode &status);
1235
1242 static MeasureUnit *createFluidOunce(UErrorCode &status);
1243
1250 static MeasureUnit *createGallon(UErrorCode &status);
1251
1252 #ifndef U_HIDE_DRAFT_API
1253
1259 static MeasureUnit *createGallonImperial(UErrorCode &status);
1260 #endif /* U_HIDE_DRAFT_API */
1261
1268 static MeasureUnit *createHectoliter(UErrorCode &status);
1269
1276 static MeasureUnit *createLiter(UErrorCode &status);
1277
1284 static MeasureUnit *createMegaliter(UErrorCode &status);
1285
1292 static MeasureUnit *createMilliliter(UErrorCode &status);
1293
1300 static MeasureUnit *createPint(UErrorCode &status);
1301
1308 static MeasureUnit *createPintMetric(UErrorCode &status);
1309
1316 static MeasureUnit *createQuart(UErrorCode &status);
1317
1324 static MeasureUnit *createTablespoon(UErrorCode &status);
1325
1332 static MeasureUnit *createTeaspoon(UErrorCode &status);
1333
1334
1335 // End generated createXXX methods
1336
1337 protected:
1338
1339 #ifndef U_HIDE_INTERNAL_API
1340
1344 void initTime(const char *timeId);
1345
1350 void initCurrency(const char *isoCurrency);
1351
1352 #endif /* U_HIDE_INTERNAL_API */
1353
1354 private:
1355 int32_t fTypeId;
1356 int32_t fSubTypeId;
1357 char fCurrency[4];
1358
1359 MeasureUnit(int32_t typeId, int32_t subTypeId) : fTypeId(typeId), fSubTypeId(subTypeId) {
1360 fCurrency[0] = 0;
1361 }
1362 void setTo(int32_t typeId, int32_t subTypeId);
1363 int32_t getOffset() const;
1364 static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
1365 };
1366
1367 U_NAMESPACE_END
1368
1369 #endif // !UNCONFIG_NO_FORMATTING
1370 #endif // __MEASUREUNIT_H__
icu::MeasureUnit::operator!=
UBool operator!=(const UObject &other) const
Inequality operator.
Definition: measunit.h:86
icu::MeasureUnit
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:38
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
unistr.h
C++ API: Unicode String.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
icu::StringEnumeration
Base class for &#39;pure&#39; C++ implementations of uenum api.
Definition: strenum.h:57
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
icu::MeasureUnit::MeasureUnit
MeasureUnit()
Default constructor.
Definition: measunit.h:45
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259