ICU 61.1  61.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 
28 
29 class StringEnumeration;
30 
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 
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 
841  static MeasureUnit *createPoint(UErrorCode &status);
842 
849  static MeasureUnit *createYard(UErrorCode &status);
850 
857  static MeasureUnit *createLux(UErrorCode &status);
858 
865  static MeasureUnit *createCarat(UErrorCode &status);
866 
873  static MeasureUnit *createGram(UErrorCode &status);
874 
881  static MeasureUnit *createKilogram(UErrorCode &status);
882 
889  static MeasureUnit *createMetricTon(UErrorCode &status);
890 
897  static MeasureUnit *createMicrogram(UErrorCode &status);
898 
905  static MeasureUnit *createMilligram(UErrorCode &status);
906 
913  static MeasureUnit *createOunce(UErrorCode &status);
914 
921  static MeasureUnit *createOunceTroy(UErrorCode &status);
922 
929  static MeasureUnit *createPound(UErrorCode &status);
930 
937  static MeasureUnit *createStone(UErrorCode &status);
938 
945  static MeasureUnit *createTon(UErrorCode &status);
946 
953  static MeasureUnit *createGigawatt(UErrorCode &status);
954 
961  static MeasureUnit *createHorsepower(UErrorCode &status);
962 
969  static MeasureUnit *createKilowatt(UErrorCode &status);
970 
977  static MeasureUnit *createMegawatt(UErrorCode &status);
978 
985  static MeasureUnit *createMilliwatt(UErrorCode &status);
986 
993  static MeasureUnit *createWatt(UErrorCode &status);
994 
1001  static MeasureUnit *createHectopascal(UErrorCode &status);
1002 
1009  static MeasureUnit *createInchHg(UErrorCode &status);
1010 
1017  static MeasureUnit *createMillibar(UErrorCode &status);
1018 
1025  static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1026 
1033  static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1034 
1041  static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1042 
1049  static MeasureUnit *createKnot(UErrorCode &status);
1050 
1057  static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1058 
1065  static MeasureUnit *createMilePerHour(UErrorCode &status);
1066 
1073  static MeasureUnit *createCelsius(UErrorCode &status);
1074 
1081  static MeasureUnit *createFahrenheit(UErrorCode &status);
1082 
1089  static MeasureUnit *createGenericTemperature(UErrorCode &status);
1090 
1097  static MeasureUnit *createKelvin(UErrorCode &status);
1098 
1105  static MeasureUnit *createAcreFoot(UErrorCode &status);
1106 
1113  static MeasureUnit *createBushel(UErrorCode &status);
1114 
1121  static MeasureUnit *createCentiliter(UErrorCode &status);
1122 
1129  static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1130 
1137  static MeasureUnit *createCubicFoot(UErrorCode &status);
1138 
1145  static MeasureUnit *createCubicInch(UErrorCode &status);
1146 
1153  static MeasureUnit *createCubicKilometer(UErrorCode &status);
1154 
1161  static MeasureUnit *createCubicMeter(UErrorCode &status);
1162 
1169  static MeasureUnit *createCubicMile(UErrorCode &status);
1170 
1177  static MeasureUnit *createCubicYard(UErrorCode &status);
1178 
1185  static MeasureUnit *createCup(UErrorCode &status);
1186 
1193  static MeasureUnit *createCupMetric(UErrorCode &status);
1194 
1201  static MeasureUnit *createDeciliter(UErrorCode &status);
1202 
1209  static MeasureUnit *createFluidOunce(UErrorCode &status);
1210 
1217  static MeasureUnit *createGallon(UErrorCode &status);
1218 
1225  static MeasureUnit *createGallonImperial(UErrorCode &status);
1226 
1233  static MeasureUnit *createHectoliter(UErrorCode &status);
1234 
1241  static MeasureUnit *createLiter(UErrorCode &status);
1242 
1249  static MeasureUnit *createMegaliter(UErrorCode &status);
1250 
1257  static MeasureUnit *createMilliliter(UErrorCode &status);
1258 
1265  static MeasureUnit *createPint(UErrorCode &status);
1266 
1273  static MeasureUnit *createPintMetric(UErrorCode &status);
1274 
1281  static MeasureUnit *createQuart(UErrorCode &status);
1282 
1289  static MeasureUnit *createTablespoon(UErrorCode &status);
1290 
1297  static MeasureUnit *createTeaspoon(UErrorCode &status);
1298 
1299 
1300 // End generated createXXX methods
1301 
1302  protected:
1303 
1304 #ifndef U_HIDE_INTERNAL_API
1305 
1309  void initTime(const char *timeId);
1310 
1315  void initCurrency(const char *isoCurrency);
1316 
1321  void initNoUnit(const char *subtype);
1322 
1323 #endif /* U_HIDE_INTERNAL_API */
1324 
1325 private:
1326  int32_t fTypeId;
1327  int32_t fSubTypeId;
1328  char fCurrency[4];
1329 
1330  MeasureUnit(int32_t typeId, int32_t subTypeId) : fTypeId(typeId), fSubTypeId(subTypeId) {
1331  fCurrency[0] = 0;
1332  }
1333  void setTo(int32_t typeId, int32_t subTypeId);
1334  int32_t getOffset() const;
1335  static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
1336 };
1337 
1339 
1340 #endif // !UNCONFIG_NO_FORMATTING
1341 #endif // __MEASUREUNIT_H__
UBool operator!=(const UObject &other) const
Inequality operator.
Definition: measunit.h:85
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:38
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:93
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:57
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
Basic definitions for ICU, for both C and C++ APIs.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236