ICU 63.1 63.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 !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
46 MeasureUnit();
47
52 MeasureUnit(const MeasureUnit &other);
53
58 MeasureUnit &operator=(const MeasureUnit &other);
59
65 virtual UObject* clone() const;
66
71 virtual ~MeasureUnit();
72
78 virtual UBool operator==(const UObject& other) const;
79
85 UBool operator!=(const UObject& other) const {
86 return !(*this == other);
87 }
88
93 const char *getType() const;
94
99 const char *getSubtype() const;
100
112 static int32_t getAvailable(
113 MeasureUnit *destArray,
114 int32_t destCapacity,
115 UErrorCode &errorCode);
116
129 static int32_t getAvailable(
130 const char *type,
131 MeasureUnit *destArray,
132 int32_t destCapacity,
133 UErrorCode &errorCode);
134
143 static StringEnumeration* getAvailableTypes(UErrorCode &errorCode);
144
156 static UClassID U_EXPORT2 getStaticClassID(void);
157
169 virtual UClassID getDynamicClassID(void) const;
170
171 #ifndef U_HIDE_INTERNAL_API
172
178 int32_t getIndex() const;
179
185 static int32_t getIndexCount();
186
193 static int32_t internalGetIndexForTypeAndSubtype(const char *type, const char *subtype);
194
199 static MeasureUnit resolveUnitPerUnit(
200 const MeasureUnit &unit, const MeasureUnit &perUnit, bool* isResolved);
201 #endif /* U_HIDE_INTERNAL_API */
202
203 // All code between the "Start generated createXXX methods" comment and
204 // the "End generated createXXX methods" comment is auto generated code
205 // and must not be edited manually. For instructions on how to correctly
206 // update this code, refer to:
207 // http://site.icu-project.org/design/formatting/measureformat/updating-measure-unit
208 //
209 // Start generated createXXX methods
210
217 static MeasureUnit *createGForce(UErrorCode &status);
218
225 static MeasureUnit *createMeterPerSecondSquared(UErrorCode &status);
226
233 static MeasureUnit *createArcMinute(UErrorCode &status);
234
241 static MeasureUnit *createArcSecond(UErrorCode &status);
242
249 static MeasureUnit *createDegree(UErrorCode &status);
250
257 static MeasureUnit *createRadian(UErrorCode &status);
258
265 static MeasureUnit *createRevolutionAngle(UErrorCode &status);
266
273 static MeasureUnit *createAcre(UErrorCode &status);
274
281 static MeasureUnit *createHectare(UErrorCode &status);
282
289 static MeasureUnit *createSquareCentimeter(UErrorCode &status);
290
297 static MeasureUnit *createSquareFoot(UErrorCode &status);
298
305 static MeasureUnit *createSquareInch(UErrorCode &status);
306
313 static MeasureUnit *createSquareKilometer(UErrorCode &status);
314
321 static MeasureUnit *createSquareMeter(UErrorCode &status);
322
329 static MeasureUnit *createSquareMile(UErrorCode &status);
330
337 static MeasureUnit *createSquareYard(UErrorCode &status);
338
345 static MeasureUnit *createKarat(UErrorCode &status);
346
353 static MeasureUnit *createMilligramPerDeciliter(UErrorCode &status);
354
361 static MeasureUnit *createMillimolePerLiter(UErrorCode &status);
362
369 static MeasureUnit *createPartPerMillion(UErrorCode &status);
370
371 #ifndef U_HIDE_DRAFT_API
372
378 static MeasureUnit *createPercent(UErrorCode &status);
379 #endif /* U_HIDE_DRAFT_API */
380
381 #ifndef U_HIDE_DRAFT_API
382
388 static MeasureUnit *createPermille(UErrorCode &status);
389 #endif /* U_HIDE_DRAFT_API */
390
397 static MeasureUnit *createLiterPer100Kilometers(UErrorCode &status);
398
405 static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
406
413 static MeasureUnit *createMilePerGallon(UErrorCode &status);
414
421 static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
422
429 static MeasureUnit *createBit(UErrorCode &status);
430
437 static MeasureUnit *createByte(UErrorCode &status);
438
445 static MeasureUnit *createGigabit(UErrorCode &status);
446
453 static MeasureUnit *createGigabyte(UErrorCode &status);
454
461 static MeasureUnit *createKilobit(UErrorCode &status);
462
469 static MeasureUnit *createKilobyte(UErrorCode &status);
470
477 static MeasureUnit *createMegabit(UErrorCode &status);
478
485 static MeasureUnit *createMegabyte(UErrorCode &status);
486
487 #ifndef U_HIDE_DRAFT_API
488
494 static MeasureUnit *createPetabyte(UErrorCode &status);
495 #endif /* U_HIDE_DRAFT_API */
496
503 static MeasureUnit *createTerabit(UErrorCode &status);
504
511 static MeasureUnit *createTerabyte(UErrorCode &status);
512
519 static MeasureUnit *createCentury(UErrorCode &status);
520
527 static MeasureUnit *createDay(UErrorCode &status);
528
535 static MeasureUnit *createHour(UErrorCode &status);
536
543 static MeasureUnit *createMicrosecond(UErrorCode &status);
544
551 static MeasureUnit *createMillisecond(UErrorCode &status);
552
559 static MeasureUnit *createMinute(UErrorCode &status);
560
567 static MeasureUnit *createMonth(UErrorCode &status);
568
575 static MeasureUnit *createNanosecond(UErrorCode &status);
576
583 static MeasureUnit *createSecond(UErrorCode &status);
584
591 static MeasureUnit *createWeek(UErrorCode &status);
592
599 static MeasureUnit *createYear(UErrorCode &status);
600
607 static MeasureUnit *createAmpere(UErrorCode &status);
608
615 static MeasureUnit *createMilliampere(UErrorCode &status);
616
623 static MeasureUnit *createOhm(UErrorCode &status);
624
631 static MeasureUnit *createVolt(UErrorCode &status);
632
639 static MeasureUnit *createCalorie(UErrorCode &status);
640
647 static MeasureUnit *createFoodcalorie(UErrorCode &status);
648
655 static MeasureUnit *createJoule(UErrorCode &status);
656
663 static MeasureUnit *createKilocalorie(UErrorCode &status);
664
671 static MeasureUnit *createKilojoule(UErrorCode &status);
672
679 static MeasureUnit *createKilowattHour(UErrorCode &status);
680
687 static MeasureUnit *createGigahertz(UErrorCode &status);
688
695 static MeasureUnit *createHertz(UErrorCode &status);
696
703 static MeasureUnit *createKilohertz(UErrorCode &status);
704
711 static MeasureUnit *createMegahertz(UErrorCode &status);
712
719 static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
720
727 static MeasureUnit *createCentimeter(UErrorCode &status);
728
735 static MeasureUnit *createDecimeter(UErrorCode &status);
736
743 static MeasureUnit *createFathom(UErrorCode &status);
744
751 static MeasureUnit *createFoot(UErrorCode &status);
752
759 static MeasureUnit *createFurlong(UErrorCode &status);
760
767 static MeasureUnit *createInch(UErrorCode &status);
768
775 static MeasureUnit *createKilometer(UErrorCode &status);
776
783 static MeasureUnit *createLightYear(UErrorCode &status);
784
791 static MeasureUnit *createMeter(UErrorCode &status);
792
799 static MeasureUnit *createMicrometer(UErrorCode &status);
800
807 static MeasureUnit *createMile(UErrorCode &status);
808
815 static MeasureUnit *createMileScandinavian(UErrorCode &status);
816
823 static MeasureUnit *createMillimeter(UErrorCode &status);
824
831 static MeasureUnit *createNanometer(UErrorCode &status);
832
839 static MeasureUnit *createNauticalMile(UErrorCode &status);
840
847 static MeasureUnit *createParsec(UErrorCode &status);
848
855 static MeasureUnit *createPicometer(UErrorCode &status);
856
863 static MeasureUnit *createPoint(UErrorCode &status);
864
871 static MeasureUnit *createYard(UErrorCode &status);
872
879 static MeasureUnit *createLux(UErrorCode &status);
880
887 static MeasureUnit *createCarat(UErrorCode &status);
888
895 static MeasureUnit *createGram(UErrorCode &status);
896
903 static MeasureUnit *createKilogram(UErrorCode &status);
904
911 static MeasureUnit *createMetricTon(UErrorCode &status);
912
919 static MeasureUnit *createMicrogram(UErrorCode &status);
920
927 static MeasureUnit *createMilligram(UErrorCode &status);
928
935 static MeasureUnit *createOunce(UErrorCode &status);
936
943 static MeasureUnit *createOunceTroy(UErrorCode &status);
944
951 static MeasureUnit *createPound(UErrorCode &status);
952
959 static MeasureUnit *createStone(UErrorCode &status);
960
967 static MeasureUnit *createTon(UErrorCode &status);
968
975 static MeasureUnit *createGigawatt(UErrorCode &status);
976
983 static MeasureUnit *createHorsepower(UErrorCode &status);
984
991 static MeasureUnit *createKilowatt(UErrorCode &status);
992
999 static MeasureUnit *createMegawatt(UErrorCode &status);
1000
1007 static MeasureUnit *createMilliwatt(UErrorCode &status);
1008
1015 static MeasureUnit *createWatt(UErrorCode &status);
1016
1017 #ifndef U_HIDE_DRAFT_API
1018
1024 static MeasureUnit *createAtmosphere(UErrorCode &status);
1025 #endif /* U_HIDE_DRAFT_API */
1026
1033 static MeasureUnit *createHectopascal(UErrorCode &status);
1034
1041 static MeasureUnit *createInchHg(UErrorCode &status);
1042
1049 static MeasureUnit *createMillibar(UErrorCode &status);
1050
1057 static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1058
1065 static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1066
1073 static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1074
1081 static MeasureUnit *createKnot(UErrorCode &status);
1082
1089 static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1090
1097 static MeasureUnit *createMilePerHour(UErrorCode &status);
1098
1105 static MeasureUnit *createCelsius(UErrorCode &status);
1106
1113 static MeasureUnit *createFahrenheit(UErrorCode &status);
1114
1121 static MeasureUnit *createGenericTemperature(UErrorCode &status);
1122
1129 static MeasureUnit *createKelvin(UErrorCode &status);
1130
1137 static MeasureUnit *createAcreFoot(UErrorCode &status);
1138
1145 static MeasureUnit *createBushel(UErrorCode &status);
1146
1153 static MeasureUnit *createCentiliter(UErrorCode &status);
1154
1161 static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1162
1169 static MeasureUnit *createCubicFoot(UErrorCode &status);
1170
1177 static MeasureUnit *createCubicInch(UErrorCode &status);
1178
1185 static MeasureUnit *createCubicKilometer(UErrorCode &status);
1186
1193 static MeasureUnit *createCubicMeter(UErrorCode &status);
1194
1201 static MeasureUnit *createCubicMile(UErrorCode &status);
1202
1209 static MeasureUnit *createCubicYard(UErrorCode &status);
1210
1217 static MeasureUnit *createCup(UErrorCode &status);
1218
1225 static MeasureUnit *createCupMetric(UErrorCode &status);
1226
1233 static MeasureUnit *createDeciliter(UErrorCode &status);
1234
1241 static MeasureUnit *createFluidOunce(UErrorCode &status);
1242
1249 static MeasureUnit *createGallon(UErrorCode &status);
1250
1257 static MeasureUnit *createGallonImperial(UErrorCode &status);
1258
1265 static MeasureUnit *createHectoliter(UErrorCode &status);
1266
1273 static MeasureUnit *createLiter(UErrorCode &status);
1274
1281 static MeasureUnit *createMegaliter(UErrorCode &status);
1282
1289 static MeasureUnit *createMilliliter(UErrorCode &status);
1290
1297 static MeasureUnit *createPint(UErrorCode &status);
1298
1305 static MeasureUnit *createPintMetric(UErrorCode &status);
1306
1313 static MeasureUnit *createQuart(UErrorCode &status);
1314
1321 static MeasureUnit *createTablespoon(UErrorCode &status);
1322
1329 static MeasureUnit *createTeaspoon(UErrorCode &status);
1330
1331
1332 // End generated createXXX methods
1333
1334 protected:
1335
1336 #ifndef U_HIDE_INTERNAL_API
1337
1341 void initTime(const char *timeId);
1342
1347 void initCurrency(const char *isoCurrency);
1348
1353 void initNoUnit(const char *subtype);
1354
1355 #endif /* U_HIDE_INTERNAL_API */
1356
1357 private:
1358 int32_t fTypeId;
1359 int32_t fSubTypeId;
1360 char fCurrency[4];
1361
1362 MeasureUnit(int32_t typeId, int32_t subTypeId) : fTypeId(typeId), fSubTypeId(subTypeId) {
1363 fCurrency[0] = 0;
1364 }
1365 void setTo(int32_t typeId, int32_t subTypeId);
1366 int32_t getOffset() const;
1367 static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
1368 };
1369
1370 U_NAMESPACE_END
1371
1372 #endif // !UNCONFIG_NO_FORMATTING
1373 #endif // __MEASUREUNIT_H__
icu::MeasureUnit
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:38
unistr.h
C++ API: Unicode String.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::MeasureUnit::operator!=
UBool operator!=(const UObject &other) const
Inequality operator.
Definition: measunit.h:85
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:90
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:301
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:220
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225