• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 /**
23  * \file
24  * \brief C++ API: A unit for measuring a quantity.
25  */
26 
27 U_NAMESPACE_BEGIN
28 
29 class StringEnumeration;
30 
31 /**
32  * A unit such as length, mass, volume, currency, etc.  A unit is
33  * coupled with a numeric amount to produce a Measure.
34  *
35  * @author Alan Liu
36  * @stable ICU 3.0
37  */
38 class U_I18N_API MeasureUnit: public UObject {
39  public:
40 
41     /**
42      * Default constructor.
43      * Populates the instance with the base dimensionless unit.
44      * @stable ICU 3.0
45      */
46     MeasureUnit();
47 
48     /**
49      * Copy constructor.
50      * @stable ICU 3.0
51      */
52     MeasureUnit(const MeasureUnit &other);
53 
54     /**
55      * Assignment operator.
56      * @stable ICU 3.0
57      */
58     MeasureUnit &operator=(const MeasureUnit &other);
59 
60     /**
61      * Returns a polymorphic clone of this object.  The result will
62      * have the same class as returned by getDynamicClassID().
63      * @stable ICU 3.0
64      */
65     virtual UObject* clone() const;
66 
67     /**
68      * Destructor
69      * @stable ICU 3.0
70      */
71     virtual ~MeasureUnit();
72 
73     /**
74      * Equality operator.  Return true if this object is equal
75      * to the given object.
76      * @stable ICU 3.0
77      */
78     virtual UBool operator==(const UObject& other) const;
79 
80     /**
81      * Inequality operator.  Return true if this object is not equal
82      * to the given object.
83      * @stable ICU 53
84      */
85     UBool operator!=(const UObject& other) const {
86         return !(*this == other);
87     }
88 
89     /**
90      * Get the type.
91      * @stable ICU 53
92      */
93     const char *getType() const;
94 
95     /**
96      * Get the sub type.
97      * @stable ICU 53
98      */
99     const char *getSubtype() const;
100 
101     /**
102      * getAvailable gets all of the available units.
103      * If there are too many units to fit into destCapacity then the
104      * error code is set to U_BUFFER_OVERFLOW_ERROR.
105      *
106      * @param destArray destination buffer.
107      * @param destCapacity number of MeasureUnit instances available at dest.
108      * @param errorCode ICU error code.
109      * @return number of available units.
110      * @stable ICU 53
111      */
112     static int32_t getAvailable(
113             MeasureUnit *destArray,
114             int32_t destCapacity,
115             UErrorCode &errorCode);
116 
117     /**
118      * getAvailable gets all of the available units for a specific type.
119      * If there are too many units to fit into destCapacity then the
120      * error code is set to U_BUFFER_OVERFLOW_ERROR.
121      *
122      * @param type the type
123      * @param destArray destination buffer.
124      * @param destCapacity number of MeasureUnit instances available at dest.
125      * @param errorCode ICU error code.
126      * @return number of available units for type.
127      * @stable ICU 53
128      */
129     static int32_t getAvailable(
130             const char *type,
131             MeasureUnit *destArray,
132             int32_t destCapacity,
133             UErrorCode &errorCode);
134 
135     /**
136      * getAvailableTypes gets all of the available types. Caller owns the
137      * returned StringEnumeration and must delete it when finished using it.
138      *
139      * @param errorCode ICU error code.
140      * @return the types.
141      * @stable ICU 53
142      */
143     static StringEnumeration* getAvailableTypes(UErrorCode &errorCode);
144 
145     /**
146      * Return the class ID for this class. This is useful only for comparing to
147      * a return value from getDynamicClassID(). For example:
148      * <pre>
149      * .   Base* polymorphic_pointer = createPolymorphicObject();
150      * .   if (polymorphic_pointer->getDynamicClassID() ==
151      * .       Derived::getStaticClassID()) ...
152      * </pre>
153      * @return          The class ID for all objects of this class.
154      * @stable ICU 53
155      */
156     static UClassID U_EXPORT2 getStaticClassID(void);
157 
158     /**
159      * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
160      * method is to implement a simple version of RTTI, since not all C++
161      * compilers support genuine RTTI. Polymorphic operator==() and clone()
162      * methods call this method.
163      *
164      * @return          The class ID for this object. All objects of a
165      *                  given class have the same class ID.  Objects of
166      *                  other classes have different class IDs.
167      * @stable ICU 53
168      */
169     virtual UClassID getDynamicClassID(void) const;
170 
171 #ifndef U_HIDE_INTERNAL_API
172     /**
173      * ICU use only.
174      * Returns associated array index for this measure unit. Only valid for
175      * non-currency measure units.
176      * @internal
177      */
178     int32_t getIndex() const;
179 
180     /**
181      * ICU use only.
182      * Returns maximum value from getIndex plus 1.
183      * @internal
184      */
185     static int32_t getIndexCount();
186 
187     /**
188      * ICU use only.
189      * @return the unit.getIndex() of the unit which has this unit.getType() and unit.getSubtype(),
190      *         or a negative value if there is no such unit
191      * @internal
192      */
193     static int32_t internalGetIndexForTypeAndSubtype(const char *type, const char *subtype);
194 
195     /**
196      * ICU use only.
197      * @internal
198      */
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 
211     /**
212      * Returns unit of acceleration: g-force.
213      * Caller owns returned value and must free it.
214      * @param status ICU error code.
215      * @stable ICU 53
216      */
217     static MeasureUnit *createGForce(UErrorCode &status);
218 
219     /**
220      * Returns unit of acceleration: meter-per-second-squared.
221      * Caller owns returned value and must free it.
222      * @param status ICU error code.
223      * @stable ICU 54
224      */
225     static MeasureUnit *createMeterPerSecondSquared(UErrorCode &status);
226 
227     /**
228      * Returns unit of angle: arc-minute.
229      * Caller owns returned value and must free it.
230      * @param status ICU error code.
231      * @stable ICU 53
232      */
233     static MeasureUnit *createArcMinute(UErrorCode &status);
234 
235     /**
236      * Returns unit of angle: arc-second.
237      * Caller owns returned value and must free it.
238      * @param status ICU error code.
239      * @stable ICU 53
240      */
241     static MeasureUnit *createArcSecond(UErrorCode &status);
242 
243     /**
244      * Returns unit of angle: degree.
245      * Caller owns returned value and must free it.
246      * @param status ICU error code.
247      * @stable ICU 53
248      */
249     static MeasureUnit *createDegree(UErrorCode &status);
250 
251     /**
252      * Returns unit of angle: radian.
253      * Caller owns returned value and must free it.
254      * @param status ICU error code.
255      * @stable ICU 54
256      */
257     static MeasureUnit *createRadian(UErrorCode &status);
258 
259     /**
260      * Returns unit of angle: revolution.
261      * Caller owns returned value and must free it.
262      * @param status ICU error code.
263      * @stable ICU 56
264      */
265     static MeasureUnit *createRevolutionAngle(UErrorCode &status);
266 
267     /**
268      * Returns unit of area: acre.
269      * Caller owns returned value and must free it.
270      * @param status ICU error code.
271      * @stable ICU 53
272      */
273     static MeasureUnit *createAcre(UErrorCode &status);
274 
275     /**
276      * Returns unit of area: hectare.
277      * Caller owns returned value and must free it.
278      * @param status ICU error code.
279      * @stable ICU 53
280      */
281     static MeasureUnit *createHectare(UErrorCode &status);
282 
283     /**
284      * Returns unit of area: square-centimeter.
285      * Caller owns returned value and must free it.
286      * @param status ICU error code.
287      * @stable ICU 54
288      */
289     static MeasureUnit *createSquareCentimeter(UErrorCode &status);
290 
291     /**
292      * Returns unit of area: square-foot.
293      * Caller owns returned value and must free it.
294      * @param status ICU error code.
295      * @stable ICU 53
296      */
297     static MeasureUnit *createSquareFoot(UErrorCode &status);
298 
299     /**
300      * Returns unit of area: square-inch.
301      * Caller owns returned value and must free it.
302      * @param status ICU error code.
303      * @stable ICU 54
304      */
305     static MeasureUnit *createSquareInch(UErrorCode &status);
306 
307     /**
308      * Returns unit of area: square-kilometer.
309      * Caller owns returned value and must free it.
310      * @param status ICU error code.
311      * @stable ICU 53
312      */
313     static MeasureUnit *createSquareKilometer(UErrorCode &status);
314 
315     /**
316      * Returns unit of area: square-meter.
317      * Caller owns returned value and must free it.
318      * @param status ICU error code.
319      * @stable ICU 53
320      */
321     static MeasureUnit *createSquareMeter(UErrorCode &status);
322 
323     /**
324      * Returns unit of area: square-mile.
325      * Caller owns returned value and must free it.
326      * @param status ICU error code.
327      * @stable ICU 53
328      */
329     static MeasureUnit *createSquareMile(UErrorCode &status);
330 
331     /**
332      * Returns unit of area: square-yard.
333      * Caller owns returned value and must free it.
334      * @param status ICU error code.
335      * @stable ICU 54
336      */
337     static MeasureUnit *createSquareYard(UErrorCode &status);
338 
339     /**
340      * Returns unit of concentr: karat.
341      * Caller owns returned value and must free it.
342      * @param status ICU error code.
343      * @stable ICU 54
344      */
345     static MeasureUnit *createKarat(UErrorCode &status);
346 
347     /**
348      * Returns unit of concentr: milligram-per-deciliter.
349      * Caller owns returned value and must free it.
350      * @param status ICU error code.
351      * @stable ICU 57
352      */
353     static MeasureUnit *createMilligramPerDeciliter(UErrorCode &status);
354 
355     /**
356      * Returns unit of concentr: millimole-per-liter.
357      * Caller owns returned value and must free it.
358      * @param status ICU error code.
359      * @stable ICU 57
360      */
361     static MeasureUnit *createMillimolePerLiter(UErrorCode &status);
362 
363     /**
364      * Returns unit of concentr: part-per-million.
365      * Caller owns returned value and must free it.
366      * @param status ICU error code.
367      * @stable ICU 57
368      */
369     static MeasureUnit *createPartPerMillion(UErrorCode &status);
370 
371 #ifndef U_HIDE_DRAFT_API
372     /**
373      * Returns unit of concentr: percent.
374      * Caller owns returned value and must free it.
375      * @param status ICU error code.
376      * @draft ICU 63
377      */
378     static MeasureUnit *createPercent(UErrorCode &status);
379 #endif /* U_HIDE_DRAFT_API */
380 
381 #ifndef U_HIDE_DRAFT_API
382     /**
383      * Returns unit of concentr: permille.
384      * Caller owns returned value and must free it.
385      * @param status ICU error code.
386      * @draft ICU 63
387      */
388     static MeasureUnit *createPermille(UErrorCode &status);
389 #endif /* U_HIDE_DRAFT_API */
390 
391     /**
392      * Returns unit of consumption: liter-per-100kilometers.
393      * Caller owns returned value and must free it.
394      * @param status ICU error code.
395      * @stable ICU 56
396      */
397     static MeasureUnit *createLiterPer100Kilometers(UErrorCode &status);
398 
399     /**
400      * Returns unit of consumption: liter-per-kilometer.
401      * Caller owns returned value and must free it.
402      * @param status ICU error code.
403      * @stable ICU 54
404      */
405     static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
406 
407     /**
408      * Returns unit of consumption: mile-per-gallon.
409      * Caller owns returned value and must free it.
410      * @param status ICU error code.
411      * @stable ICU 54
412      */
413     static MeasureUnit *createMilePerGallon(UErrorCode &status);
414 
415     /**
416      * Returns unit of consumption: mile-per-gallon-imperial.
417      * Caller owns returned value and must free it.
418      * @param status ICU error code.
419      * @stable ICU 57
420      */
421     static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
422 
423     /**
424      * Returns unit of digital: bit.
425      * Caller owns returned value and must free it.
426      * @param status ICU error code.
427      * @stable ICU 54
428      */
429     static MeasureUnit *createBit(UErrorCode &status);
430 
431     /**
432      * Returns unit of digital: byte.
433      * Caller owns returned value and must free it.
434      * @param status ICU error code.
435      * @stable ICU 54
436      */
437     static MeasureUnit *createByte(UErrorCode &status);
438 
439     /**
440      * Returns unit of digital: gigabit.
441      * Caller owns returned value and must free it.
442      * @param status ICU error code.
443      * @stable ICU 54
444      */
445     static MeasureUnit *createGigabit(UErrorCode &status);
446 
447     /**
448      * Returns unit of digital: gigabyte.
449      * Caller owns returned value and must free it.
450      * @param status ICU error code.
451      * @stable ICU 54
452      */
453     static MeasureUnit *createGigabyte(UErrorCode &status);
454 
455     /**
456      * Returns unit of digital: kilobit.
457      * Caller owns returned value and must free it.
458      * @param status ICU error code.
459      * @stable ICU 54
460      */
461     static MeasureUnit *createKilobit(UErrorCode &status);
462 
463     /**
464      * Returns unit of digital: kilobyte.
465      * Caller owns returned value and must free it.
466      * @param status ICU error code.
467      * @stable ICU 54
468      */
469     static MeasureUnit *createKilobyte(UErrorCode &status);
470 
471     /**
472      * Returns unit of digital: megabit.
473      * Caller owns returned value and must free it.
474      * @param status ICU error code.
475      * @stable ICU 54
476      */
477     static MeasureUnit *createMegabit(UErrorCode &status);
478 
479     /**
480      * Returns unit of digital: megabyte.
481      * Caller owns returned value and must free it.
482      * @param status ICU error code.
483      * @stable ICU 54
484      */
485     static MeasureUnit *createMegabyte(UErrorCode &status);
486 
487 #ifndef U_HIDE_DRAFT_API
488     /**
489      * Returns unit of digital: petabyte.
490      * Caller owns returned value and must free it.
491      * @param status ICU error code.
492      * @draft ICU 63
493      */
494     static MeasureUnit *createPetabyte(UErrorCode &status);
495 #endif /* U_HIDE_DRAFT_API */
496 
497     /**
498      * Returns unit of digital: terabit.
499      * Caller owns returned value and must free it.
500      * @param status ICU error code.
501      * @stable ICU 54
502      */
503     static MeasureUnit *createTerabit(UErrorCode &status);
504 
505     /**
506      * Returns unit of digital: terabyte.
507      * Caller owns returned value and must free it.
508      * @param status ICU error code.
509      * @stable ICU 54
510      */
511     static MeasureUnit *createTerabyte(UErrorCode &status);
512 
513     /**
514      * Returns unit of duration: century.
515      * Caller owns returned value and must free it.
516      * @param status ICU error code.
517      * @stable ICU 56
518      */
519     static MeasureUnit *createCentury(UErrorCode &status);
520 
521     /**
522      * Returns unit of duration: day.
523      * Caller owns returned value and must free it.
524      * @param status ICU error code.
525      * @stable ICU 53
526      */
527     static MeasureUnit *createDay(UErrorCode &status);
528 
529     /**
530      * Returns unit of duration: hour.
531      * Caller owns returned value and must free it.
532      * @param status ICU error code.
533      * @stable ICU 53
534      */
535     static MeasureUnit *createHour(UErrorCode &status);
536 
537     /**
538      * Returns unit of duration: microsecond.
539      * Caller owns returned value and must free it.
540      * @param status ICU error code.
541      * @stable ICU 54
542      */
543     static MeasureUnit *createMicrosecond(UErrorCode &status);
544 
545     /**
546      * Returns unit of duration: millisecond.
547      * Caller owns returned value and must free it.
548      * @param status ICU error code.
549      * @stable ICU 53
550      */
551     static MeasureUnit *createMillisecond(UErrorCode &status);
552 
553     /**
554      * Returns unit of duration: minute.
555      * Caller owns returned value and must free it.
556      * @param status ICU error code.
557      * @stable ICU 53
558      */
559     static MeasureUnit *createMinute(UErrorCode &status);
560 
561     /**
562      * Returns unit of duration: month.
563      * Caller owns returned value and must free it.
564      * @param status ICU error code.
565      * @stable ICU 53
566      */
567     static MeasureUnit *createMonth(UErrorCode &status);
568 
569     /**
570      * Returns unit of duration: nanosecond.
571      * Caller owns returned value and must free it.
572      * @param status ICU error code.
573      * @stable ICU 54
574      */
575     static MeasureUnit *createNanosecond(UErrorCode &status);
576 
577     /**
578      * Returns unit of duration: second.
579      * Caller owns returned value and must free it.
580      * @param status ICU error code.
581      * @stable ICU 53
582      */
583     static MeasureUnit *createSecond(UErrorCode &status);
584 
585     /**
586      * Returns unit of duration: week.
587      * Caller owns returned value and must free it.
588      * @param status ICU error code.
589      * @stable ICU 53
590      */
591     static MeasureUnit *createWeek(UErrorCode &status);
592 
593     /**
594      * Returns unit of duration: year.
595      * Caller owns returned value and must free it.
596      * @param status ICU error code.
597      * @stable ICU 53
598      */
599     static MeasureUnit *createYear(UErrorCode &status);
600 
601     /**
602      * Returns unit of electric: ampere.
603      * Caller owns returned value and must free it.
604      * @param status ICU error code.
605      * @stable ICU 54
606      */
607     static MeasureUnit *createAmpere(UErrorCode &status);
608 
609     /**
610      * Returns unit of electric: milliampere.
611      * Caller owns returned value and must free it.
612      * @param status ICU error code.
613      * @stable ICU 54
614      */
615     static MeasureUnit *createMilliampere(UErrorCode &status);
616 
617     /**
618      * Returns unit of electric: ohm.
619      * Caller owns returned value and must free it.
620      * @param status ICU error code.
621      * @stable ICU 54
622      */
623     static MeasureUnit *createOhm(UErrorCode &status);
624 
625     /**
626      * Returns unit of electric: volt.
627      * Caller owns returned value and must free it.
628      * @param status ICU error code.
629      * @stable ICU 54
630      */
631     static MeasureUnit *createVolt(UErrorCode &status);
632 
633     /**
634      * Returns unit of energy: calorie.
635      * Caller owns returned value and must free it.
636      * @param status ICU error code.
637      * @stable ICU 54
638      */
639     static MeasureUnit *createCalorie(UErrorCode &status);
640 
641     /**
642      * Returns unit of energy: foodcalorie.
643      * Caller owns returned value and must free it.
644      * @param status ICU error code.
645      * @stable ICU 54
646      */
647     static MeasureUnit *createFoodcalorie(UErrorCode &status);
648 
649     /**
650      * Returns unit of energy: joule.
651      * Caller owns returned value and must free it.
652      * @param status ICU error code.
653      * @stable ICU 54
654      */
655     static MeasureUnit *createJoule(UErrorCode &status);
656 
657     /**
658      * Returns unit of energy: kilocalorie.
659      * Caller owns returned value and must free it.
660      * @param status ICU error code.
661      * @stable ICU 54
662      */
663     static MeasureUnit *createKilocalorie(UErrorCode &status);
664 
665     /**
666      * Returns unit of energy: kilojoule.
667      * Caller owns returned value and must free it.
668      * @param status ICU error code.
669      * @stable ICU 54
670      */
671     static MeasureUnit *createKilojoule(UErrorCode &status);
672 
673     /**
674      * Returns unit of energy: kilowatt-hour.
675      * Caller owns returned value and must free it.
676      * @param status ICU error code.
677      * @stable ICU 54
678      */
679     static MeasureUnit *createKilowattHour(UErrorCode &status);
680 
681     /**
682      * Returns unit of frequency: gigahertz.
683      * Caller owns returned value and must free it.
684      * @param status ICU error code.
685      * @stable ICU 54
686      */
687     static MeasureUnit *createGigahertz(UErrorCode &status);
688 
689     /**
690      * Returns unit of frequency: hertz.
691      * Caller owns returned value and must free it.
692      * @param status ICU error code.
693      * @stable ICU 54
694      */
695     static MeasureUnit *createHertz(UErrorCode &status);
696 
697     /**
698      * Returns unit of frequency: kilohertz.
699      * Caller owns returned value and must free it.
700      * @param status ICU error code.
701      * @stable ICU 54
702      */
703     static MeasureUnit *createKilohertz(UErrorCode &status);
704 
705     /**
706      * Returns unit of frequency: megahertz.
707      * Caller owns returned value and must free it.
708      * @param status ICU error code.
709      * @stable ICU 54
710      */
711     static MeasureUnit *createMegahertz(UErrorCode &status);
712 
713     /**
714      * Returns unit of length: astronomical-unit.
715      * Caller owns returned value and must free it.
716      * @param status ICU error code.
717      * @stable ICU 54
718      */
719     static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
720 
721     /**
722      * Returns unit of length: centimeter.
723      * Caller owns returned value and must free it.
724      * @param status ICU error code.
725      * @stable ICU 53
726      */
727     static MeasureUnit *createCentimeter(UErrorCode &status);
728 
729     /**
730      * Returns unit of length: decimeter.
731      * Caller owns returned value and must free it.
732      * @param status ICU error code.
733      * @stable ICU 54
734      */
735     static MeasureUnit *createDecimeter(UErrorCode &status);
736 
737     /**
738      * Returns unit of length: fathom.
739      * Caller owns returned value and must free it.
740      * @param status ICU error code.
741      * @stable ICU 54
742      */
743     static MeasureUnit *createFathom(UErrorCode &status);
744 
745     /**
746      * Returns unit of length: foot.
747      * Caller owns returned value and must free it.
748      * @param status ICU error code.
749      * @stable ICU 53
750      */
751     static MeasureUnit *createFoot(UErrorCode &status);
752 
753     /**
754      * Returns unit of length: furlong.
755      * Caller owns returned value and must free it.
756      * @param status ICU error code.
757      * @stable ICU 54
758      */
759     static MeasureUnit *createFurlong(UErrorCode &status);
760 
761     /**
762      * Returns unit of length: inch.
763      * Caller owns returned value and must free it.
764      * @param status ICU error code.
765      * @stable ICU 53
766      */
767     static MeasureUnit *createInch(UErrorCode &status);
768 
769     /**
770      * Returns unit of length: kilometer.
771      * Caller owns returned value and must free it.
772      * @param status ICU error code.
773      * @stable ICU 53
774      */
775     static MeasureUnit *createKilometer(UErrorCode &status);
776 
777     /**
778      * Returns unit of length: light-year.
779      * Caller owns returned value and must free it.
780      * @param status ICU error code.
781      * @stable ICU 53
782      */
783     static MeasureUnit *createLightYear(UErrorCode &status);
784 
785     /**
786      * Returns unit of length: meter.
787      * Caller owns returned value and must free it.
788      * @param status ICU error code.
789      * @stable ICU 53
790      */
791     static MeasureUnit *createMeter(UErrorCode &status);
792 
793     /**
794      * Returns unit of length: micrometer.
795      * Caller owns returned value and must free it.
796      * @param status ICU error code.
797      * @stable ICU 54
798      */
799     static MeasureUnit *createMicrometer(UErrorCode &status);
800 
801     /**
802      * Returns unit of length: mile.
803      * Caller owns returned value and must free it.
804      * @param status ICU error code.
805      * @stable ICU 53
806      */
807     static MeasureUnit *createMile(UErrorCode &status);
808 
809     /**
810      * Returns unit of length: mile-scandinavian.
811      * Caller owns returned value and must free it.
812      * @param status ICU error code.
813      * @stable ICU 56
814      */
815     static MeasureUnit *createMileScandinavian(UErrorCode &status);
816 
817     /**
818      * Returns unit of length: millimeter.
819      * Caller owns returned value and must free it.
820      * @param status ICU error code.
821      * @stable ICU 53
822      */
823     static MeasureUnit *createMillimeter(UErrorCode &status);
824 
825     /**
826      * Returns unit of length: nanometer.
827      * Caller owns returned value and must free it.
828      * @param status ICU error code.
829      * @stable ICU 54
830      */
831     static MeasureUnit *createNanometer(UErrorCode &status);
832 
833     /**
834      * Returns unit of length: nautical-mile.
835      * Caller owns returned value and must free it.
836      * @param status ICU error code.
837      * @stable ICU 54
838      */
839     static MeasureUnit *createNauticalMile(UErrorCode &status);
840 
841     /**
842      * Returns unit of length: parsec.
843      * Caller owns returned value and must free it.
844      * @param status ICU error code.
845      * @stable ICU 54
846      */
847     static MeasureUnit *createParsec(UErrorCode &status);
848 
849     /**
850      * Returns unit of length: picometer.
851      * Caller owns returned value and must free it.
852      * @param status ICU error code.
853      * @stable ICU 53
854      */
855     static MeasureUnit *createPicometer(UErrorCode &status);
856 
857     /**
858      * Returns unit of length: point.
859      * Caller owns returned value and must free it.
860      * @param status ICU error code.
861      * @stable ICU 59
862      */
863     static MeasureUnit *createPoint(UErrorCode &status);
864 
865     /**
866      * Returns unit of length: yard.
867      * Caller owns returned value and must free it.
868      * @param status ICU error code.
869      * @stable ICU 53
870      */
871     static MeasureUnit *createYard(UErrorCode &status);
872 
873     /**
874      * Returns unit of light: lux.
875      * Caller owns returned value and must free it.
876      * @param status ICU error code.
877      * @stable ICU 54
878      */
879     static MeasureUnit *createLux(UErrorCode &status);
880 
881     /**
882      * Returns unit of mass: carat.
883      * Caller owns returned value and must free it.
884      * @param status ICU error code.
885      * @stable ICU 54
886      */
887     static MeasureUnit *createCarat(UErrorCode &status);
888 
889     /**
890      * Returns unit of mass: gram.
891      * Caller owns returned value and must free it.
892      * @param status ICU error code.
893      * @stable ICU 53
894      */
895     static MeasureUnit *createGram(UErrorCode &status);
896 
897     /**
898      * Returns unit of mass: kilogram.
899      * Caller owns returned value and must free it.
900      * @param status ICU error code.
901      * @stable ICU 53
902      */
903     static MeasureUnit *createKilogram(UErrorCode &status);
904 
905     /**
906      * Returns unit of mass: metric-ton.
907      * Caller owns returned value and must free it.
908      * @param status ICU error code.
909      * @stable ICU 54
910      */
911     static MeasureUnit *createMetricTon(UErrorCode &status);
912 
913     /**
914      * Returns unit of mass: microgram.
915      * Caller owns returned value and must free it.
916      * @param status ICU error code.
917      * @stable ICU 54
918      */
919     static MeasureUnit *createMicrogram(UErrorCode &status);
920 
921     /**
922      * Returns unit of mass: milligram.
923      * Caller owns returned value and must free it.
924      * @param status ICU error code.
925      * @stable ICU 54
926      */
927     static MeasureUnit *createMilligram(UErrorCode &status);
928 
929     /**
930      * Returns unit of mass: ounce.
931      * Caller owns returned value and must free it.
932      * @param status ICU error code.
933      * @stable ICU 53
934      */
935     static MeasureUnit *createOunce(UErrorCode &status);
936 
937     /**
938      * Returns unit of mass: ounce-troy.
939      * Caller owns returned value and must free it.
940      * @param status ICU error code.
941      * @stable ICU 54
942      */
943     static MeasureUnit *createOunceTroy(UErrorCode &status);
944 
945     /**
946      * Returns unit of mass: pound.
947      * Caller owns returned value and must free it.
948      * @param status ICU error code.
949      * @stable ICU 53
950      */
951     static MeasureUnit *createPound(UErrorCode &status);
952 
953     /**
954      * Returns unit of mass: stone.
955      * Caller owns returned value and must free it.
956      * @param status ICU error code.
957      * @stable ICU 54
958      */
959     static MeasureUnit *createStone(UErrorCode &status);
960 
961     /**
962      * Returns unit of mass: ton.
963      * Caller owns returned value and must free it.
964      * @param status ICU error code.
965      * @stable ICU 54
966      */
967     static MeasureUnit *createTon(UErrorCode &status);
968 
969     /**
970      * Returns unit of power: gigawatt.
971      * Caller owns returned value and must free it.
972      * @param status ICU error code.
973      * @stable ICU 54
974      */
975     static MeasureUnit *createGigawatt(UErrorCode &status);
976 
977     /**
978      * Returns unit of power: horsepower.
979      * Caller owns returned value and must free it.
980      * @param status ICU error code.
981      * @stable ICU 53
982      */
983     static MeasureUnit *createHorsepower(UErrorCode &status);
984 
985     /**
986      * Returns unit of power: kilowatt.
987      * Caller owns returned value and must free it.
988      * @param status ICU error code.
989      * @stable ICU 53
990      */
991     static MeasureUnit *createKilowatt(UErrorCode &status);
992 
993     /**
994      * Returns unit of power: megawatt.
995      * Caller owns returned value and must free it.
996      * @param status ICU error code.
997      * @stable ICU 54
998      */
999     static MeasureUnit *createMegawatt(UErrorCode &status);
1000 
1001     /**
1002      * Returns unit of power: milliwatt.
1003      * Caller owns returned value and must free it.
1004      * @param status ICU error code.
1005      * @stable ICU 54
1006      */
1007     static MeasureUnit *createMilliwatt(UErrorCode &status);
1008 
1009     /**
1010      * Returns unit of power: watt.
1011      * Caller owns returned value and must free it.
1012      * @param status ICU error code.
1013      * @stable ICU 53
1014      */
1015     static MeasureUnit *createWatt(UErrorCode &status);
1016 
1017 #ifndef U_HIDE_DRAFT_API
1018     /**
1019      * Returns unit of pressure: atmosphere.
1020      * Caller owns returned value and must free it.
1021      * @param status ICU error code.
1022      * @draft ICU 63
1023      */
1024     static MeasureUnit *createAtmosphere(UErrorCode &status);
1025 #endif /* U_HIDE_DRAFT_API */
1026 
1027     /**
1028      * Returns unit of pressure: hectopascal.
1029      * Caller owns returned value and must free it.
1030      * @param status ICU error code.
1031      * @stable ICU 53
1032      */
1033     static MeasureUnit *createHectopascal(UErrorCode &status);
1034 
1035     /**
1036      * Returns unit of pressure: inch-hg.
1037      * Caller owns returned value and must free it.
1038      * @param status ICU error code.
1039      * @stable ICU 53
1040      */
1041     static MeasureUnit *createInchHg(UErrorCode &status);
1042 
1043     /**
1044      * Returns unit of pressure: millibar.
1045      * Caller owns returned value and must free it.
1046      * @param status ICU error code.
1047      * @stable ICU 53
1048      */
1049     static MeasureUnit *createMillibar(UErrorCode &status);
1050 
1051     /**
1052      * Returns unit of pressure: millimeter-of-mercury.
1053      * Caller owns returned value and must free it.
1054      * @param status ICU error code.
1055      * @stable ICU 54
1056      */
1057     static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1058 
1059     /**
1060      * Returns unit of pressure: pound-per-square-inch.
1061      * Caller owns returned value and must free it.
1062      * @param status ICU error code.
1063      * @stable ICU 54
1064      */
1065     static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1066 
1067     /**
1068      * Returns unit of speed: kilometer-per-hour.
1069      * Caller owns returned value and must free it.
1070      * @param status ICU error code.
1071      * @stable ICU 53
1072      */
1073     static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1074 
1075     /**
1076      * Returns unit of speed: knot.
1077      * Caller owns returned value and must free it.
1078      * @param status ICU error code.
1079      * @stable ICU 56
1080      */
1081     static MeasureUnit *createKnot(UErrorCode &status);
1082 
1083     /**
1084      * Returns unit of speed: meter-per-second.
1085      * Caller owns returned value and must free it.
1086      * @param status ICU error code.
1087      * @stable ICU 53
1088      */
1089     static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1090 
1091     /**
1092      * Returns unit of speed: mile-per-hour.
1093      * Caller owns returned value and must free it.
1094      * @param status ICU error code.
1095      * @stable ICU 53
1096      */
1097     static MeasureUnit *createMilePerHour(UErrorCode &status);
1098 
1099     /**
1100      * Returns unit of temperature: celsius.
1101      * Caller owns returned value and must free it.
1102      * @param status ICU error code.
1103      * @stable ICU 53
1104      */
1105     static MeasureUnit *createCelsius(UErrorCode &status);
1106 
1107     /**
1108      * Returns unit of temperature: fahrenheit.
1109      * Caller owns returned value and must free it.
1110      * @param status ICU error code.
1111      * @stable ICU 53
1112      */
1113     static MeasureUnit *createFahrenheit(UErrorCode &status);
1114 
1115     /**
1116      * Returns unit of temperature: generic.
1117      * Caller owns returned value and must free it.
1118      * @param status ICU error code.
1119      * @stable ICU 56
1120      */
1121     static MeasureUnit *createGenericTemperature(UErrorCode &status);
1122 
1123     /**
1124      * Returns unit of temperature: kelvin.
1125      * Caller owns returned value and must free it.
1126      * @param status ICU error code.
1127      * @stable ICU 54
1128      */
1129     static MeasureUnit *createKelvin(UErrorCode &status);
1130 
1131     /**
1132      * Returns unit of volume: acre-foot.
1133      * Caller owns returned value and must free it.
1134      * @param status ICU error code.
1135      * @stable ICU 54
1136      */
1137     static MeasureUnit *createAcreFoot(UErrorCode &status);
1138 
1139     /**
1140      * Returns unit of volume: bushel.
1141      * Caller owns returned value and must free it.
1142      * @param status ICU error code.
1143      * @stable ICU 54
1144      */
1145     static MeasureUnit *createBushel(UErrorCode &status);
1146 
1147     /**
1148      * Returns unit of volume: centiliter.
1149      * Caller owns returned value and must free it.
1150      * @param status ICU error code.
1151      * @stable ICU 54
1152      */
1153     static MeasureUnit *createCentiliter(UErrorCode &status);
1154 
1155     /**
1156      * Returns unit of volume: cubic-centimeter.
1157      * Caller owns returned value and must free it.
1158      * @param status ICU error code.
1159      * @stable ICU 54
1160      */
1161     static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1162 
1163     /**
1164      * Returns unit of volume: cubic-foot.
1165      * Caller owns returned value and must free it.
1166      * @param status ICU error code.
1167      * @stable ICU 54
1168      */
1169     static MeasureUnit *createCubicFoot(UErrorCode &status);
1170 
1171     /**
1172      * Returns unit of volume: cubic-inch.
1173      * Caller owns returned value and must free it.
1174      * @param status ICU error code.
1175      * @stable ICU 54
1176      */
1177     static MeasureUnit *createCubicInch(UErrorCode &status);
1178 
1179     /**
1180      * Returns unit of volume: cubic-kilometer.
1181      * Caller owns returned value and must free it.
1182      * @param status ICU error code.
1183      * @stable ICU 53
1184      */
1185     static MeasureUnit *createCubicKilometer(UErrorCode &status);
1186 
1187     /**
1188      * Returns unit of volume: cubic-meter.
1189      * Caller owns returned value and must free it.
1190      * @param status ICU error code.
1191      * @stable ICU 54
1192      */
1193     static MeasureUnit *createCubicMeter(UErrorCode &status);
1194 
1195     /**
1196      * Returns unit of volume: cubic-mile.
1197      * Caller owns returned value and must free it.
1198      * @param status ICU error code.
1199      * @stable ICU 53
1200      */
1201     static MeasureUnit *createCubicMile(UErrorCode &status);
1202 
1203     /**
1204      * Returns unit of volume: cubic-yard.
1205      * Caller owns returned value and must free it.
1206      * @param status ICU error code.
1207      * @stable ICU 54
1208      */
1209     static MeasureUnit *createCubicYard(UErrorCode &status);
1210 
1211     /**
1212      * Returns unit of volume: cup.
1213      * Caller owns returned value and must free it.
1214      * @param status ICU error code.
1215      * @stable ICU 54
1216      */
1217     static MeasureUnit *createCup(UErrorCode &status);
1218 
1219     /**
1220      * Returns unit of volume: cup-metric.
1221      * Caller owns returned value and must free it.
1222      * @param status ICU error code.
1223      * @stable ICU 56
1224      */
1225     static MeasureUnit *createCupMetric(UErrorCode &status);
1226 
1227     /**
1228      * Returns unit of volume: deciliter.
1229      * Caller owns returned value and must free it.
1230      * @param status ICU error code.
1231      * @stable ICU 54
1232      */
1233     static MeasureUnit *createDeciliter(UErrorCode &status);
1234 
1235     /**
1236      * Returns unit of volume: fluid-ounce.
1237      * Caller owns returned value and must free it.
1238      * @param status ICU error code.
1239      * @stable ICU 54
1240      */
1241     static MeasureUnit *createFluidOunce(UErrorCode &status);
1242 
1243     /**
1244      * Returns unit of volume: gallon.
1245      * Caller owns returned value and must free it.
1246      * @param status ICU error code.
1247      * @stable ICU 54
1248      */
1249     static MeasureUnit *createGallon(UErrorCode &status);
1250 
1251     /**
1252      * Returns unit of volume: gallon-imperial.
1253      * Caller owns returned value and must free it.
1254      * @param status ICU error code.
1255      * @stable ICU 57
1256      */
1257     static MeasureUnit *createGallonImperial(UErrorCode &status);
1258 
1259     /**
1260      * Returns unit of volume: hectoliter.
1261      * Caller owns returned value and must free it.
1262      * @param status ICU error code.
1263      * @stable ICU 54
1264      */
1265     static MeasureUnit *createHectoliter(UErrorCode &status);
1266 
1267     /**
1268      * Returns unit of volume: liter.
1269      * Caller owns returned value and must free it.
1270      * @param status ICU error code.
1271      * @stable ICU 53
1272      */
1273     static MeasureUnit *createLiter(UErrorCode &status);
1274 
1275     /**
1276      * Returns unit of volume: megaliter.
1277      * Caller owns returned value and must free it.
1278      * @param status ICU error code.
1279      * @stable ICU 54
1280      */
1281     static MeasureUnit *createMegaliter(UErrorCode &status);
1282 
1283     /**
1284      * Returns unit of volume: milliliter.
1285      * Caller owns returned value and must free it.
1286      * @param status ICU error code.
1287      * @stable ICU 54
1288      */
1289     static MeasureUnit *createMilliliter(UErrorCode &status);
1290 
1291     /**
1292      * Returns unit of volume: pint.
1293      * Caller owns returned value and must free it.
1294      * @param status ICU error code.
1295      * @stable ICU 54
1296      */
1297     static MeasureUnit *createPint(UErrorCode &status);
1298 
1299     /**
1300      * Returns unit of volume: pint-metric.
1301      * Caller owns returned value and must free it.
1302      * @param status ICU error code.
1303      * @stable ICU 56
1304      */
1305     static MeasureUnit *createPintMetric(UErrorCode &status);
1306 
1307     /**
1308      * Returns unit of volume: quart.
1309      * Caller owns returned value and must free it.
1310      * @param status ICU error code.
1311      * @stable ICU 54
1312      */
1313     static MeasureUnit *createQuart(UErrorCode &status);
1314 
1315     /**
1316      * Returns unit of volume: tablespoon.
1317      * Caller owns returned value and must free it.
1318      * @param status ICU error code.
1319      * @stable ICU 54
1320      */
1321     static MeasureUnit *createTablespoon(UErrorCode &status);
1322 
1323     /**
1324      * Returns unit of volume: teaspoon.
1325      * Caller owns returned value and must free it.
1326      * @param status ICU error code.
1327      * @stable ICU 54
1328      */
1329     static MeasureUnit *createTeaspoon(UErrorCode &status);
1330 
1331 
1332 // End generated createXXX methods
1333 
1334  protected:
1335 
1336 #ifndef U_HIDE_INTERNAL_API
1337     /**
1338      * For ICU use only.
1339      * @internal
1340      */
1341     void initTime(const char *timeId);
1342 
1343     /**
1344      * For ICU use only.
1345      * @internal
1346      */
1347     void initCurrency(const char *isoCurrency);
1348 
1349     /**
1350      * For ICU use only.
1351      * @internal
1352      */
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 
MeasureUnit(int32_t typeId,int32_t subTypeId)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__
1374