ICU 59.1  59.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 
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 
354  static MeasureUnit *createMilligramPerDeciliter(UErrorCode &status);
355 
362  static MeasureUnit *createMillimolePerLiter(UErrorCode &status);
363 
370  static MeasureUnit *createPartPerMillion(UErrorCode &status);
371 
378  static MeasureUnit *createLiterPer100Kilometers(UErrorCode &status);
379 
386  static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
387 
394  static MeasureUnit *createMilePerGallon(UErrorCode &status);
395 
402  static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
403 
404  /*
405  * The following were draft ICU 58, but have been withdrawn:
406  * static MeasureUnit *createEast(UErrorCode &status);
407  * static MeasureUnit *createNorth(UErrorCode &status);
408  * static MeasureUnit *createSouth(UErrorCode &status);
409  * static MeasureUnit *createWest(UErrorCode &status);
410  */
411 
418  static MeasureUnit *createBit(UErrorCode &status);
419 
426  static MeasureUnit *createByte(UErrorCode &status);
427 
434  static MeasureUnit *createGigabit(UErrorCode &status);
435 
442  static MeasureUnit *createGigabyte(UErrorCode &status);
443 
450  static MeasureUnit *createKilobit(UErrorCode &status);
451 
458  static MeasureUnit *createKilobyte(UErrorCode &status);
459 
466  static MeasureUnit *createMegabit(UErrorCode &status);
467 
474  static MeasureUnit *createMegabyte(UErrorCode &status);
475 
482  static MeasureUnit *createTerabit(UErrorCode &status);
483 
490  static MeasureUnit *createTerabyte(UErrorCode &status);
491 
498  static MeasureUnit *createCentury(UErrorCode &status);
499 
506  static MeasureUnit *createDay(UErrorCode &status);
507 
514  static MeasureUnit *createHour(UErrorCode &status);
515 
522  static MeasureUnit *createMicrosecond(UErrorCode &status);
523 
530  static MeasureUnit *createMillisecond(UErrorCode &status);
531 
538  static MeasureUnit *createMinute(UErrorCode &status);
539 
546  static MeasureUnit *createMonth(UErrorCode &status);
547 
554  static MeasureUnit *createNanosecond(UErrorCode &status);
555 
562  static MeasureUnit *createSecond(UErrorCode &status);
563 
570  static MeasureUnit *createWeek(UErrorCode &status);
571 
578  static MeasureUnit *createYear(UErrorCode &status);
579 
586  static MeasureUnit *createAmpere(UErrorCode &status);
587 
594  static MeasureUnit *createMilliampere(UErrorCode &status);
595 
602  static MeasureUnit *createOhm(UErrorCode &status);
603 
610  static MeasureUnit *createVolt(UErrorCode &status);
611 
618  static MeasureUnit *createCalorie(UErrorCode &status);
619 
626  static MeasureUnit *createFoodcalorie(UErrorCode &status);
627 
634  static MeasureUnit *createJoule(UErrorCode &status);
635 
642  static MeasureUnit *createKilocalorie(UErrorCode &status);
643 
650  static MeasureUnit *createKilojoule(UErrorCode &status);
651 
658  static MeasureUnit *createKilowattHour(UErrorCode &status);
659 
666  static MeasureUnit *createGigahertz(UErrorCode &status);
667 
674  static MeasureUnit *createHertz(UErrorCode &status);
675 
682  static MeasureUnit *createKilohertz(UErrorCode &status);
683 
690  static MeasureUnit *createMegahertz(UErrorCode &status);
691 
698  static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
699 
706  static MeasureUnit *createCentimeter(UErrorCode &status);
707 
714  static MeasureUnit *createDecimeter(UErrorCode &status);
715 
722  static MeasureUnit *createFathom(UErrorCode &status);
723 
730  static MeasureUnit *createFoot(UErrorCode &status);
731 
738  static MeasureUnit *createFurlong(UErrorCode &status);
739 
746  static MeasureUnit *createInch(UErrorCode &status);
747 
754  static MeasureUnit *createKilometer(UErrorCode &status);
755 
762  static MeasureUnit *createLightYear(UErrorCode &status);
763 
770  static MeasureUnit *createMeter(UErrorCode &status);
771 
778  static MeasureUnit *createMicrometer(UErrorCode &status);
779 
786  static MeasureUnit *createMile(UErrorCode &status);
787 
794  static MeasureUnit *createMileScandinavian(UErrorCode &status);
795 
802  static MeasureUnit *createMillimeter(UErrorCode &status);
803 
810  static MeasureUnit *createNanometer(UErrorCode &status);
811 
818  static MeasureUnit *createNauticalMile(UErrorCode &status);
819 
826  static MeasureUnit *createParsec(UErrorCode &status);
827 
834  static MeasureUnit *createPicometer(UErrorCode &status);
835 
836 #ifndef U_HIDE_DRAFT_API
837 
843  static MeasureUnit *createPoint(UErrorCode &status);
844 #endif /* U_HIDE_DRAFT_API */
845 
852  static MeasureUnit *createYard(UErrorCode &status);
853 
860  static MeasureUnit *createLux(UErrorCode &status);
861 
868  static MeasureUnit *createCarat(UErrorCode &status);
869 
876  static MeasureUnit *createGram(UErrorCode &status);
877 
884  static MeasureUnit *createKilogram(UErrorCode &status);
885 
892  static MeasureUnit *createMetricTon(UErrorCode &status);
893 
900  static MeasureUnit *createMicrogram(UErrorCode &status);
901 
908  static MeasureUnit *createMilligram(UErrorCode &status);
909 
916  static MeasureUnit *createOunce(UErrorCode &status);
917 
924  static MeasureUnit *createOunceTroy(UErrorCode &status);
925 
932  static MeasureUnit *createPound(UErrorCode &status);
933 
940  static MeasureUnit *createStone(UErrorCode &status);
941 
948  static MeasureUnit *createTon(UErrorCode &status);
949 
956  static MeasureUnit *createGigawatt(UErrorCode &status);
957 
964  static MeasureUnit *createHorsepower(UErrorCode &status);
965 
972  static MeasureUnit *createKilowatt(UErrorCode &status);
973 
980  static MeasureUnit *createMegawatt(UErrorCode &status);
981 
988  static MeasureUnit *createMilliwatt(UErrorCode &status);
989 
996  static MeasureUnit *createWatt(UErrorCode &status);
997 
1004  static MeasureUnit *createHectopascal(UErrorCode &status);
1005 
1012  static MeasureUnit *createInchHg(UErrorCode &status);
1013 
1020  static MeasureUnit *createMillibar(UErrorCode &status);
1021 
1028  static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1029 
1036  static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1037 
1044  static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1045 
1052  static MeasureUnit *createKnot(UErrorCode &status);
1053 
1060  static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1061 
1068  static MeasureUnit *createMilePerHour(UErrorCode &status);
1069 
1076  static MeasureUnit *createCelsius(UErrorCode &status);
1077 
1084  static MeasureUnit *createFahrenheit(UErrorCode &status);
1085 
1092  static MeasureUnit *createGenericTemperature(UErrorCode &status);
1093 
1100  static MeasureUnit *createKelvin(UErrorCode &status);
1101 
1108  static MeasureUnit *createAcreFoot(UErrorCode &status);
1109 
1116  static MeasureUnit *createBushel(UErrorCode &status);
1117 
1124  static MeasureUnit *createCentiliter(UErrorCode &status);
1125 
1132  static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1133 
1140  static MeasureUnit *createCubicFoot(UErrorCode &status);
1141 
1148  static MeasureUnit *createCubicInch(UErrorCode &status);
1149 
1156  static MeasureUnit *createCubicKilometer(UErrorCode &status);
1157 
1164  static MeasureUnit *createCubicMeter(UErrorCode &status);
1165 
1172  static MeasureUnit *createCubicMile(UErrorCode &status);
1173 
1180  static MeasureUnit *createCubicYard(UErrorCode &status);
1181 
1188  static MeasureUnit *createCup(UErrorCode &status);
1189 
1196  static MeasureUnit *createCupMetric(UErrorCode &status);
1197 
1204  static MeasureUnit *createDeciliter(UErrorCode &status);
1205 
1212  static MeasureUnit *createFluidOunce(UErrorCode &status);
1213 
1220  static MeasureUnit *createGallon(UErrorCode &status);
1221 
1228  static MeasureUnit *createGallonImperial(UErrorCode &status);
1229 
1236  static MeasureUnit *createHectoliter(UErrorCode &status);
1237 
1244  static MeasureUnit *createLiter(UErrorCode &status);
1245 
1252  static MeasureUnit *createMegaliter(UErrorCode &status);
1253 
1260  static MeasureUnit *createMilliliter(UErrorCode &status);
1261 
1268  static MeasureUnit *createPint(UErrorCode &status);
1269 
1276  static MeasureUnit *createPintMetric(UErrorCode &status);
1277 
1284  static MeasureUnit *createQuart(UErrorCode &status);
1285 
1292  static MeasureUnit *createTablespoon(UErrorCode &status);
1293 
1300  static MeasureUnit *createTeaspoon(UErrorCode &status);
1301 
1302 
1303 // End generated createXXX methods
1304 
1305  protected:
1306 
1307 #ifndef U_HIDE_INTERNAL_API
1308 
1312  void initTime(const char *timeId);
1313 
1318  void initCurrency(const char *isoCurrency);
1319 
1320 #endif /* U_HIDE_INTERNAL_API */
1321 
1322 private:
1323  int32_t fTypeId;
1324  int32_t fSubTypeId;
1325  char fCurrency[4];
1326 
1327  MeasureUnit(int32_t typeId, int32_t subTypeId) : fTypeId(typeId), fSubTypeId(subTypeId) {
1328  fCurrency[0] = 0;
1329  }
1330  void setTo(int32_t typeId, int32_t subTypeId);
1331  int32_t getOffset() const;
1332  static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
1333 };
1334 
1336 
1337 #endif // !UNCONFIG_NO_FORMATTING
1338 #endif // __MEASUREUNIT_H__
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:38
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UBool operator!=(const UObject &other) const
Inequality operator.
Definition: measunit.h:86
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:131
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
MeasureUnit()
Default constructor.
Definition: measunit.h:45
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
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