ICU 55.1 55.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
measunit.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (c) 2004-2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Author: Alan Liu
7 * Created: April 26, 2004
8 * Since: ICU 3.0
9 **********************************************************************
10 */
11 #ifndef __MEASUREUNIT_H__
12 #define __MEASUREUNIT_H__
13
14 #include "unicode/utypes.h"
15
16 #if !UCONFIG_NO_FORMATTING
17
18 #include "unicode/unistr.h"
19
25 U_NAMESPACE_BEGIN
26
27 class StringEnumeration;
28
36 class U_I18N_API MeasureUnit: public UObject {
37 public:
38
43 MeasureUnit() : fTypeId(0), fSubTypeId(0) {
44 fCurrency[0] = 0;
45 }
46
51 MeasureUnit(const MeasureUnit &other);
52
57 MeasureUnit &operator=(const MeasureUnit &other);
58
64 virtual UObject* clone() const;
65
70 virtual ~MeasureUnit();
71
77 virtual UBool operator==(const UObject& other) const;
78
84 UBool operator!=(const UObject& other) const {
85 return !(*this == other);
86 }
87
92 const char *getType() const;
93
98 const char *getSubtype() const;
99
111 static int32_t getAvailable(
112 MeasureUnit *destArray,
113 int32_t destCapacity,
114 UErrorCode &errorCode);
115
128 static int32_t getAvailable(
129 const char *type,
130 MeasureUnit *destArray,
131 int32_t destCapacity,
132 UErrorCode &errorCode);
133
142 static StringEnumeration* getAvailableTypes(UErrorCode &errorCode);
143
155 static UClassID U_EXPORT2 getStaticClassID(void);
156
168 virtual UClassID getDynamicClassID(void) const;
169
170 #ifndef U_HIDE_INTERNAL_API
171
177 int32_t getIndex() const;
178
184 static int32_t getIndexCount();
185
190 static MeasureUnit *resolveUnitPerUnit(
191 const MeasureUnit &unit, const MeasureUnit &perUnit);
192 #endif /* U_HIDE_INTERNAL_API */
193
194 // All code between the "Start generated createXXX methods" comment and
195 // the "End generated createXXX methods" comment is auto generated code
196 // and must not be edited manually. For instructions on how to correctly
197 // update this code, refer to:
198 // http://site.icu-project.org/design/formatting/measureformat/updating-measure-unit
199 //
200 // Start generated createXXX methods
201
208 static MeasureUnit *createGForce(UErrorCode &status);
209
210 #ifndef U_HIDE_DRAFT_API
211
217 static MeasureUnit *createMeterPerSecondSquared(UErrorCode &status);
218
219 #endif /* U_HIDE_DRAFT_API */
220
226 static MeasureUnit *createArcMinute(UErrorCode &status);
227
234 static MeasureUnit *createArcSecond(UErrorCode &status);
235
242 static MeasureUnit *createDegree(UErrorCode &status);
243
244 #ifndef U_HIDE_DRAFT_API
245
251 static MeasureUnit *createRadian(UErrorCode &status);
252
253 #endif /* U_HIDE_DRAFT_API */
254
260 static MeasureUnit *createAcre(UErrorCode &status);
261
268 static MeasureUnit *createHectare(UErrorCode &status);
269
270 #ifndef U_HIDE_DRAFT_API
271
277 static MeasureUnit *createSquareCentimeter(UErrorCode &status);
278
279 #endif /* U_HIDE_DRAFT_API */
280
286 static MeasureUnit *createSquareFoot(UErrorCode &status);
287
288 #ifndef U_HIDE_DRAFT_API
289
295 static MeasureUnit *createSquareInch(UErrorCode &status);
296
297 #endif /* U_HIDE_DRAFT_API */
298
304 static MeasureUnit *createSquareKilometer(UErrorCode &status);
305
312 static MeasureUnit *createSquareMeter(UErrorCode &status);
313
320 static MeasureUnit *createSquareMile(UErrorCode &status);
321
322 #ifndef U_HIDE_DRAFT_API
323
329 static MeasureUnit *createSquareYard(UErrorCode &status);
330
331 #endif /* U_HIDE_DRAFT_API */
332 #ifndef U_HIDE_DRAFT_API
333
339 static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
340
341 #endif /* U_HIDE_DRAFT_API */
342 #ifndef U_HIDE_DRAFT_API
343
349 static MeasureUnit *createMilePerGallon(UErrorCode &status);
350
351 #endif /* U_HIDE_DRAFT_API */
352 #ifndef U_HIDE_DRAFT_API
353
359 static MeasureUnit *createBit(UErrorCode &status);
360
361 #endif /* U_HIDE_DRAFT_API */
362 #ifndef U_HIDE_DRAFT_API
363
369 static MeasureUnit *createByte(UErrorCode &status);
370
371 #endif /* U_HIDE_DRAFT_API */
372 #ifndef U_HIDE_DRAFT_API
373
379 static MeasureUnit *createGigabit(UErrorCode &status);
380
381 #endif /* U_HIDE_DRAFT_API */
382 #ifndef U_HIDE_DRAFT_API
383
389 static MeasureUnit *createGigabyte(UErrorCode &status);
390
391 #endif /* U_HIDE_DRAFT_API */
392 #ifndef U_HIDE_DRAFT_API
393
399 static MeasureUnit *createKilobit(UErrorCode &status);
400
401 #endif /* U_HIDE_DRAFT_API */
402 #ifndef U_HIDE_DRAFT_API
403
409 static MeasureUnit *createKilobyte(UErrorCode &status);
410
411 #endif /* U_HIDE_DRAFT_API */
412 #ifndef U_HIDE_DRAFT_API
413
419 static MeasureUnit *createMegabit(UErrorCode &status);
420
421 #endif /* U_HIDE_DRAFT_API */
422 #ifndef U_HIDE_DRAFT_API
423
429 static MeasureUnit *createMegabyte(UErrorCode &status);
430
431 #endif /* U_HIDE_DRAFT_API */
432 #ifndef U_HIDE_DRAFT_API
433
439 static MeasureUnit *createTerabit(UErrorCode &status);
440
441 #endif /* U_HIDE_DRAFT_API */
442 #ifndef U_HIDE_DRAFT_API
443
449 static MeasureUnit *createTerabyte(UErrorCode &status);
450
451 #endif /* U_HIDE_DRAFT_API */
452
458 static MeasureUnit *createDay(UErrorCode &status);
459
466 static MeasureUnit *createHour(UErrorCode &status);
467
468 #ifndef U_HIDE_DRAFT_API
469
475 static MeasureUnit *createMicrosecond(UErrorCode &status);
476
477 #endif /* U_HIDE_DRAFT_API */
478
484 static MeasureUnit *createMillisecond(UErrorCode &status);
485
492 static MeasureUnit *createMinute(UErrorCode &status);
493
500 static MeasureUnit *createMonth(UErrorCode &status);
501
502 #ifndef U_HIDE_DRAFT_API
503
509 static MeasureUnit *createNanosecond(UErrorCode &status);
510
511 #endif /* U_HIDE_DRAFT_API */
512
518 static MeasureUnit *createSecond(UErrorCode &status);
519
526 static MeasureUnit *createWeek(UErrorCode &status);
527
534 static MeasureUnit *createYear(UErrorCode &status);
535
536 #ifndef U_HIDE_DRAFT_API
537
543 static MeasureUnit *createAmpere(UErrorCode &status);
544
545 #endif /* U_HIDE_DRAFT_API */
546 #ifndef U_HIDE_DRAFT_API
547
553 static MeasureUnit *createMilliampere(UErrorCode &status);
554
555 #endif /* U_HIDE_DRAFT_API */
556 #ifndef U_HIDE_DRAFT_API
557
563 static MeasureUnit *createOhm(UErrorCode &status);
564
565 #endif /* U_HIDE_DRAFT_API */
566 #ifndef U_HIDE_DRAFT_API
567
573 static MeasureUnit *createVolt(UErrorCode &status);
574
575 #endif /* U_HIDE_DRAFT_API */
576 #ifndef U_HIDE_DRAFT_API
577
583 static MeasureUnit *createCalorie(UErrorCode &status);
584
585 #endif /* U_HIDE_DRAFT_API */
586 #ifndef U_HIDE_DRAFT_API
587
593 static MeasureUnit *createFoodcalorie(UErrorCode &status);
594
595 #endif /* U_HIDE_DRAFT_API */
596 #ifndef U_HIDE_DRAFT_API
597
603 static MeasureUnit *createJoule(UErrorCode &status);
604
605 #endif /* U_HIDE_DRAFT_API */
606 #ifndef U_HIDE_DRAFT_API
607
613 static MeasureUnit *createKilocalorie(UErrorCode &status);
614
615 #endif /* U_HIDE_DRAFT_API */
616 #ifndef U_HIDE_DRAFT_API
617
623 static MeasureUnit *createKilojoule(UErrorCode &status);
624
625 #endif /* U_HIDE_DRAFT_API */
626 #ifndef U_HIDE_DRAFT_API
627
633 static MeasureUnit *createKilowattHour(UErrorCode &status);
634
635 #endif /* U_HIDE_DRAFT_API */
636 #ifndef U_HIDE_DRAFT_API
637
643 static MeasureUnit *createGigahertz(UErrorCode &status);
644
645 #endif /* U_HIDE_DRAFT_API */
646 #ifndef U_HIDE_DRAFT_API
647
653 static MeasureUnit *createHertz(UErrorCode &status);
654
655 #endif /* U_HIDE_DRAFT_API */
656 #ifndef U_HIDE_DRAFT_API
657
663 static MeasureUnit *createKilohertz(UErrorCode &status);
664
665 #endif /* U_HIDE_DRAFT_API */
666 #ifndef U_HIDE_DRAFT_API
667
673 static MeasureUnit *createMegahertz(UErrorCode &status);
674
675 #endif /* U_HIDE_DRAFT_API */
676 #ifndef U_HIDE_DRAFT_API
677
683 static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
684
685 #endif /* U_HIDE_DRAFT_API */
686
692 static MeasureUnit *createCentimeter(UErrorCode &status);
693
694 #ifndef U_HIDE_DRAFT_API
695
701 static MeasureUnit *createDecimeter(UErrorCode &status);
702
703 #endif /* U_HIDE_DRAFT_API */
704 #ifndef U_HIDE_DRAFT_API
705
711 static MeasureUnit *createFathom(UErrorCode &status);
712
713 #endif /* U_HIDE_DRAFT_API */
714
720 static MeasureUnit *createFoot(UErrorCode &status);
721
722 #ifndef U_HIDE_DRAFT_API
723
729 static MeasureUnit *createFurlong(UErrorCode &status);
730
731 #endif /* U_HIDE_DRAFT_API */
732
738 static MeasureUnit *createInch(UErrorCode &status);
739
746 static MeasureUnit *createKilometer(UErrorCode &status);
747
754 static MeasureUnit *createLightYear(UErrorCode &status);
755
762 static MeasureUnit *createMeter(UErrorCode &status);
763
764 #ifndef U_HIDE_DRAFT_API
765
771 static MeasureUnit *createMicrometer(UErrorCode &status);
772
773 #endif /* U_HIDE_DRAFT_API */
774
780 static MeasureUnit *createMile(UErrorCode &status);
781
788 static MeasureUnit *createMillimeter(UErrorCode &status);
789
790 #ifndef U_HIDE_DRAFT_API
791
797 static MeasureUnit *createNanometer(UErrorCode &status);
798
799 #endif /* U_HIDE_DRAFT_API */
800 #ifndef U_HIDE_DRAFT_API
801
807 static MeasureUnit *createNauticalMile(UErrorCode &status);
808
809 #endif /* U_HIDE_DRAFT_API */
810 #ifndef U_HIDE_DRAFT_API
811
817 static MeasureUnit *createParsec(UErrorCode &status);
818
819 #endif /* U_HIDE_DRAFT_API */
820
826 static MeasureUnit *createPicometer(UErrorCode &status);
827
834 static MeasureUnit *createYard(UErrorCode &status);
835
836 #ifndef U_HIDE_DRAFT_API
837
843 static MeasureUnit *createLux(UErrorCode &status);
844
845 #endif /* U_HIDE_DRAFT_API */
846 #ifndef U_HIDE_DRAFT_API
847
853 static MeasureUnit *createCarat(UErrorCode &status);
854
855 #endif /* U_HIDE_DRAFT_API */
856
862 static MeasureUnit *createGram(UErrorCode &status);
863
870 static MeasureUnit *createKilogram(UErrorCode &status);
871
872 #ifndef U_HIDE_DRAFT_API
873
879 static MeasureUnit *createMetricTon(UErrorCode &status);
880
881 #endif /* U_HIDE_DRAFT_API */
882 #ifndef U_HIDE_DRAFT_API
883
889 static MeasureUnit *createMicrogram(UErrorCode &status);
890
891 #endif /* U_HIDE_DRAFT_API */
892 #ifndef U_HIDE_DRAFT_API
893
899 static MeasureUnit *createMilligram(UErrorCode &status);
900
901 #endif /* U_HIDE_DRAFT_API */
902
908 static MeasureUnit *createOunce(UErrorCode &status);
909
910 #ifndef U_HIDE_DRAFT_API
911
917 static MeasureUnit *createOunceTroy(UErrorCode &status);
918
919 #endif /* U_HIDE_DRAFT_API */
920
926 static MeasureUnit *createPound(UErrorCode &status);
927
928 #ifndef U_HIDE_DRAFT_API
929
935 static MeasureUnit *createStone(UErrorCode &status);
936
937 #endif /* U_HIDE_DRAFT_API */
938 #ifndef U_HIDE_DRAFT_API
939
945 static MeasureUnit *createTon(UErrorCode &status);
946
947 #endif /* U_HIDE_DRAFT_API */
948 #ifndef U_HIDE_DRAFT_API
949
955 static MeasureUnit *createGigawatt(UErrorCode &status);
956
957 #endif /* U_HIDE_DRAFT_API */
958
964 static MeasureUnit *createHorsepower(UErrorCode &status);
965
972 static MeasureUnit *createKilowatt(UErrorCode &status);
973
974 #ifndef U_HIDE_DRAFT_API
975
981 static MeasureUnit *createMegawatt(UErrorCode &status);
982
983 #endif /* U_HIDE_DRAFT_API */
984 #ifndef U_HIDE_DRAFT_API
985
991 static MeasureUnit *createMilliwatt(UErrorCode &status);
992
993 #endif /* U_HIDE_DRAFT_API */
994
1000 static MeasureUnit *createWatt(UErrorCode &status);
1001
1008 static MeasureUnit *createHectopascal(UErrorCode &status);
1009
1016 static MeasureUnit *createInchHg(UErrorCode &status);
1017
1024 static MeasureUnit *createMillibar(UErrorCode &status);
1025
1026 #ifndef U_HIDE_DRAFT_API
1027
1033 static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1034
1035 #endif /* U_HIDE_DRAFT_API */
1036 #ifndef U_HIDE_DRAFT_API
1037
1043 static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1044
1045 #endif /* U_HIDE_DRAFT_API */
1046 #ifndef U_HIDE_DRAFT_API
1047
1053 static MeasureUnit *createKarat(UErrorCode &status);
1054
1055 #endif /* U_HIDE_DRAFT_API */
1056
1062 static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1063
1070 static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1071
1078 static MeasureUnit *createMilePerHour(UErrorCode &status);
1079
1086 static MeasureUnit *createCelsius(UErrorCode &status);
1087
1094 static MeasureUnit *createFahrenheit(UErrorCode &status);
1095
1096 #ifndef U_HIDE_DRAFT_API
1097
1103 static MeasureUnit *createKelvin(UErrorCode &status);
1104
1105 #endif /* U_HIDE_DRAFT_API */
1106 #ifndef U_HIDE_DRAFT_API
1107
1113 static MeasureUnit *createAcreFoot(UErrorCode &status);
1114
1115 #endif /* U_HIDE_DRAFT_API */
1116 #ifndef U_HIDE_DRAFT_API
1117
1123 static MeasureUnit *createBushel(UErrorCode &status);
1124
1125 #endif /* U_HIDE_DRAFT_API */
1126 #ifndef U_HIDE_DRAFT_API
1127
1133 static MeasureUnit *createCentiliter(UErrorCode &status);
1134
1135 #endif /* U_HIDE_DRAFT_API */
1136 #ifndef U_HIDE_DRAFT_API
1137
1143 static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1144
1145 #endif /* U_HIDE_DRAFT_API */
1146 #ifndef U_HIDE_DRAFT_API
1147
1153 static MeasureUnit *createCubicFoot(UErrorCode &status);
1154
1155 #endif /* U_HIDE_DRAFT_API */
1156 #ifndef U_HIDE_DRAFT_API
1157
1163 static MeasureUnit *createCubicInch(UErrorCode &status);
1164
1165 #endif /* U_HIDE_DRAFT_API */
1166
1172 static MeasureUnit *createCubicKilometer(UErrorCode &status);
1173
1174 #ifndef U_HIDE_DRAFT_API
1175
1181 static MeasureUnit *createCubicMeter(UErrorCode &status);
1182
1183 #endif /* U_HIDE_DRAFT_API */
1184
1190 static MeasureUnit *createCubicMile(UErrorCode &status);
1191
1192 #ifndef U_HIDE_DRAFT_API
1193
1199 static MeasureUnit *createCubicYard(UErrorCode &status);
1200
1201 #endif /* U_HIDE_DRAFT_API */
1202 #ifndef U_HIDE_DRAFT_API
1203
1209 static MeasureUnit *createCup(UErrorCode &status);
1210
1211 #endif /* U_HIDE_DRAFT_API */
1212 #ifndef U_HIDE_DRAFT_API
1213
1219 static MeasureUnit *createDeciliter(UErrorCode &status);
1220
1221 #endif /* U_HIDE_DRAFT_API */
1222 #ifndef U_HIDE_DRAFT_API
1223
1229 static MeasureUnit *createFluidOunce(UErrorCode &status);
1230
1231 #endif /* U_HIDE_DRAFT_API */
1232 #ifndef U_HIDE_DRAFT_API
1233
1239 static MeasureUnit *createGallon(UErrorCode &status);
1240
1241 #endif /* U_HIDE_DRAFT_API */
1242 #ifndef U_HIDE_DRAFT_API
1243
1249 static MeasureUnit *createHectoliter(UErrorCode &status);
1250
1251 #endif /* U_HIDE_DRAFT_API */
1252
1258 static MeasureUnit *createLiter(UErrorCode &status);
1259
1260 #ifndef U_HIDE_DRAFT_API
1261
1267 static MeasureUnit *createMegaliter(UErrorCode &status);
1268
1269 #endif /* U_HIDE_DRAFT_API */
1270 #ifndef U_HIDE_DRAFT_API
1271
1277 static MeasureUnit *createMilliliter(UErrorCode &status);
1278
1279 #endif /* U_HIDE_DRAFT_API */
1280 #ifndef U_HIDE_DRAFT_API
1281
1287 static MeasureUnit *createPint(UErrorCode &status);
1288
1289 #endif /* U_HIDE_DRAFT_API */
1290 #ifndef U_HIDE_DRAFT_API
1291
1297 static MeasureUnit *createQuart(UErrorCode &status);
1298
1299 #endif /* U_HIDE_DRAFT_API */
1300 #ifndef U_HIDE_DRAFT_API
1301
1307 static MeasureUnit *createTablespoon(UErrorCode &status);
1308
1309 #endif /* U_HIDE_DRAFT_API */
1310 #ifndef U_HIDE_DRAFT_API
1311
1317 static MeasureUnit *createTeaspoon(UErrorCode &status);
1318
1319 #endif /* U_HIDE_DRAFT_API */
1320
1321 // End generated createXXX methods
1322
1323 protected:
1324
1325 #ifndef U_HIDE_INTERNAL_API
1326
1330 void initTime(const char *timeId);
1331
1336 void initCurrency(const char *isoCurrency);
1337
1338 #endif /* U_HIDE_INTERNAL_API */
1339
1340 private:
1341 int32_t fTypeId;
1342 int32_t fSubTypeId;
1343 char fCurrency[4];
1344
1345 MeasureUnit(int32_t typeId, int32_t subTypeId) : fTypeId(typeId), fSubTypeId(subTypeId) {
1346 fCurrency[0] = 0;
1347 }
1348 void setTo(int32_t typeId, int32_t subTypeId);
1349 int32_t getOffset() const;
1350 static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
1351 };
1352
1353 U_NAMESPACE_END
1354
1355 #endif // !UNCONFIG_NO_FORMATTING
1356 #endif // __MEASUREUNIT_H__