ICU 60.2 60.2

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

- File List
- Globals

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);
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
377 static MeasureUnit *createLiterPer100Kilometers(UErrorCode &status);
378
385 static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
386
393 static MeasureUnit *createMilePerGallon(UErrorCode &status);
394
401 static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
402
403 /*
404 * The following were draft ICU 58, but have been withdrawn:
405 * static MeasureUnit *createEast(UErrorCode &status);
406 * static MeasureUnit *createNorth(UErrorCode &status);
407 * static MeasureUnit *createSouth(UErrorCode &status);
408 * static MeasureUnit *createWest(UErrorCode &status);
409 */
410
417 static MeasureUnit *createBit(UErrorCode &status);
418
425 static MeasureUnit *createByte(UErrorCode &status);
426
433 static MeasureUnit *createGigabit(UErrorCode &status);
434
441 static MeasureUnit *createGigabyte(UErrorCode &status);
442
449 static MeasureUnit *createKilobit(UErrorCode &status);
450
457 static MeasureUnit *createKilobyte(UErrorCode &status);
458
465 static MeasureUnit *createMegabit(UErrorCode &status);
466
473 static MeasureUnit *createMegabyte(UErrorCode &status);
474
481 static MeasureUnit *createTerabit(UErrorCode &status);
482
489 static MeasureUnit *createTerabyte(UErrorCode &status);
490
497 static MeasureUnit *createCentury(UErrorCode &status);
498
505 static MeasureUnit *createDay(UErrorCode &status);
506
513 static MeasureUnit *createHour(UErrorCode &status);
514
521 static MeasureUnit *createMicrosecond(UErrorCode &status);
522
529 static MeasureUnit *createMillisecond(UErrorCode &status);
530
537 static MeasureUnit *createMinute(UErrorCode &status);
538
545 static MeasureUnit *createMonth(UErrorCode &status);
546
553 static MeasureUnit *createNanosecond(UErrorCode &status);
554
561 static MeasureUnit *createSecond(UErrorCode &status);
562
569 static MeasureUnit *createWeek(UErrorCode &status);
570
577 static MeasureUnit *createYear(UErrorCode &status);
578
585 static MeasureUnit *createAmpere(UErrorCode &status);
586
593 static MeasureUnit *createMilliampere(UErrorCode &status);
594
601 static MeasureUnit *createOhm(UErrorCode &status);
602
609 static MeasureUnit *createVolt(UErrorCode &status);
610
617 static MeasureUnit *createCalorie(UErrorCode &status);
618
625 static MeasureUnit *createFoodcalorie(UErrorCode &status);
626
633 static MeasureUnit *createJoule(UErrorCode &status);
634
641 static MeasureUnit *createKilocalorie(UErrorCode &status);
642
649 static MeasureUnit *createKilojoule(UErrorCode &status);
650
657 static MeasureUnit *createKilowattHour(UErrorCode &status);
658
665 static MeasureUnit *createGigahertz(UErrorCode &status);
666
673 static MeasureUnit *createHertz(UErrorCode &status);
674
681 static MeasureUnit *createKilohertz(UErrorCode &status);
682
689 static MeasureUnit *createMegahertz(UErrorCode &status);
690
697 static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
698
705 static MeasureUnit *createCentimeter(UErrorCode &status);
706
713 static MeasureUnit *createDecimeter(UErrorCode &status);
714
721 static MeasureUnit *createFathom(UErrorCode &status);
722
729 static MeasureUnit *createFoot(UErrorCode &status);
730
737 static MeasureUnit *createFurlong(UErrorCode &status);
738
745 static MeasureUnit *createInch(UErrorCode &status);
746
753 static MeasureUnit *createKilometer(UErrorCode &status);
754
761 static MeasureUnit *createLightYear(UErrorCode &status);
762
769 static MeasureUnit *createMeter(UErrorCode &status);
770
777 static MeasureUnit *createMicrometer(UErrorCode &status);
778
785 static MeasureUnit *createMile(UErrorCode &status);
786
793 static MeasureUnit *createMileScandinavian(UErrorCode &status);
794
801 static MeasureUnit *createMillimeter(UErrorCode &status);
802
809 static MeasureUnit *createNanometer(UErrorCode &status);
810
817 static MeasureUnit *createNauticalMile(UErrorCode &status);
818
825 static MeasureUnit *createParsec(UErrorCode &status);
826
833 static MeasureUnit *createPicometer(UErrorCode &status);
834
835 #ifndef U_HIDE_DRAFT_API
836
842 static MeasureUnit *createPoint(UErrorCode &status);
843 #endif /* U_HIDE_DRAFT_API */
844
851 static MeasureUnit *createYard(UErrorCode &status);
852
859 static MeasureUnit *createLux(UErrorCode &status);
860
867 static MeasureUnit *createCarat(UErrorCode &status);
868
875 static MeasureUnit *createGram(UErrorCode &status);
876
883 static MeasureUnit *createKilogram(UErrorCode &status);
884
891 static MeasureUnit *createMetricTon(UErrorCode &status);
892
899 static MeasureUnit *createMicrogram(UErrorCode &status);
900
907 static MeasureUnit *createMilligram(UErrorCode &status);
908
915 static MeasureUnit *createOunce(UErrorCode &status);
916
923 static MeasureUnit *createOunceTroy(UErrorCode &status);
924
931 static MeasureUnit *createPound(UErrorCode &status);
932
939 static MeasureUnit *createStone(UErrorCode &status);
940
947 static MeasureUnit *createTon(UErrorCode &status);
948
955 static MeasureUnit *createGigawatt(UErrorCode &status);
956
963 static MeasureUnit *createHorsepower(UErrorCode &status);
964
971 static MeasureUnit *createKilowatt(UErrorCode &status);
972
979 static MeasureUnit *createMegawatt(UErrorCode &status);
980
987 static MeasureUnit *createMilliwatt(UErrorCode &status);
988
995 static MeasureUnit *createWatt(UErrorCode &status);
996
1003 static MeasureUnit *createHectopascal(UErrorCode &status);
1004
1011 static MeasureUnit *createInchHg(UErrorCode &status);
1012
1019 static MeasureUnit *createMillibar(UErrorCode &status);
1020
1027 static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1028
1035 static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1036
1043 static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1044
1051 static MeasureUnit *createKnot(UErrorCode &status);
1052
1059 static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1060
1067 static MeasureUnit *createMilePerHour(UErrorCode &status);
1068
1075 static MeasureUnit *createCelsius(UErrorCode &status);
1076
1083 static MeasureUnit *createFahrenheit(UErrorCode &status);
1084
1091 static MeasureUnit *createGenericTemperature(UErrorCode &status);
1092
1099 static MeasureUnit *createKelvin(UErrorCode &status);
1100
1107 static MeasureUnit *createAcreFoot(UErrorCode &status);
1108
1115 static MeasureUnit *createBushel(UErrorCode &status);
1116
1123 static MeasureUnit *createCentiliter(UErrorCode &status);
1124
1131 static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1132
1139 static MeasureUnit *createCubicFoot(UErrorCode &status);
1140
1147 static MeasureUnit *createCubicInch(UErrorCode &status);
1148
1155 static MeasureUnit *createCubicKilometer(UErrorCode &status);
1156
1163 static MeasureUnit *createCubicMeter(UErrorCode &status);
1164
1171 static MeasureUnit *createCubicMile(UErrorCode &status);
1172
1179 static MeasureUnit *createCubicYard(UErrorCode &status);
1180
1187 static MeasureUnit *createCup(UErrorCode &status);
1188
1195 static MeasureUnit *createCupMetric(UErrorCode &status);
1196
1203 static MeasureUnit *createDeciliter(UErrorCode &status);
1204
1211 static MeasureUnit *createFluidOunce(UErrorCode &status);
1212
1219 static MeasureUnit *createGallon(UErrorCode &status);
1220
1227 static MeasureUnit *createGallonImperial(UErrorCode &status);
1228
1235 static MeasureUnit *createHectoliter(UErrorCode &status);
1236
1243 static MeasureUnit *createLiter(UErrorCode &status);
1244
1251 static MeasureUnit *createMegaliter(UErrorCode &status);
1252
1259 static MeasureUnit *createMilliliter(UErrorCode &status);
1260
1267 static MeasureUnit *createPint(UErrorCode &status);
1268
1275 static MeasureUnit *createPintMetric(UErrorCode &status);
1276
1283 static MeasureUnit *createQuart(UErrorCode &status);
1284
1291 static MeasureUnit *createTablespoon(UErrorCode &status);
1292
1299 static MeasureUnit *createTeaspoon(UErrorCode &status);
1300
1301
1302 // End generated createXXX methods
1303
1304 protected:
1305
1306 #ifndef U_HIDE_INTERNAL_API
1307
1311 void initTime(const char *timeId);
1312
1317 void initCurrency(const char *isoCurrency);
1318
1323 void initNoUnit(const char *subtype);
1324
1325 #endif /* U_HIDE_INTERNAL_API */
1326
1327 private:
1328 int32_t fTypeId;
1329 int32_t fSubTypeId;
1330 char fCurrency[4];
1331
1332 MeasureUnit(int32_t typeId, int32_t subTypeId) : fTypeId(typeId), fSubTypeId(subTypeId) {
1333 fCurrency[0] = 0;
1334 }
1335 void setTo(int32_t typeId, int32_t subTypeId);
1336 int32_t getOffset() const;
1337 static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
1338 };
1339
1340 U_NAMESPACE_END
1341
1342 #endif // !UNCONFIG_NO_FORMATTING
1343 #endif // __MEASUREUNIT_H__
icu::MeasureUnit::operator!=
UBool operator!=(const UObject &other) const
Inequality operator.
Definition: measunit.h:85
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
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:236