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