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      * @internal
189      */
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 
202     /**
203      * Returns unit of acceleration: g-force.
204      * Caller owns returned value and must free it.
205      * @param status ICU error code.
206      * @stable ICU 53
207      */
208     static MeasureUnit *createGForce(UErrorCode &status);
209 
210 #ifndef U_HIDE_DRAFT_API
211     /**
212      * Returns unit of acceleration: meter-per-second-squared.
213      * Caller owns returned value and must free it.
214      * @param status ICU error code.
215      * @draft ICU 54
216      */
217     static MeasureUnit *createMeterPerSecondSquared(UErrorCode &status);
218 
219 #endif /* U_HIDE_DRAFT_API */
220     /**
221      * Returns unit of angle: arc-minute.
222      * Caller owns returned value and must free it.
223      * @param status ICU error code.
224      * @stable ICU 53
225      */
226     static MeasureUnit *createArcMinute(UErrorCode &status);
227 
228     /**
229      * Returns unit of angle: arc-second.
230      * Caller owns returned value and must free it.
231      * @param status ICU error code.
232      * @stable ICU 53
233      */
234     static MeasureUnit *createArcSecond(UErrorCode &status);
235 
236     /**
237      * Returns unit of angle: degree.
238      * Caller owns returned value and must free it.
239      * @param status ICU error code.
240      * @stable ICU 53
241      */
242     static MeasureUnit *createDegree(UErrorCode &status);
243 
244 #ifndef U_HIDE_DRAFT_API
245     /**
246      * Returns unit of angle: radian.
247      * Caller owns returned value and must free it.
248      * @param status ICU error code.
249      * @draft ICU 54
250      */
251     static MeasureUnit *createRadian(UErrorCode &status);
252 
253 #endif /* U_HIDE_DRAFT_API */
254     /**
255      * Returns unit of area: acre.
256      * Caller owns returned value and must free it.
257      * @param status ICU error code.
258      * @stable ICU 53
259      */
260     static MeasureUnit *createAcre(UErrorCode &status);
261 
262     /**
263      * Returns unit of area: hectare.
264      * Caller owns returned value and must free it.
265      * @param status ICU error code.
266      * @stable ICU 53
267      */
268     static MeasureUnit *createHectare(UErrorCode &status);
269 
270 #ifndef U_HIDE_DRAFT_API
271     /**
272      * Returns unit of area: square-centimeter.
273      * Caller owns returned value and must free it.
274      * @param status ICU error code.
275      * @draft ICU 54
276      */
277     static MeasureUnit *createSquareCentimeter(UErrorCode &status);
278 
279 #endif /* U_HIDE_DRAFT_API */
280     /**
281      * Returns unit of area: square-foot.
282      * Caller owns returned value and must free it.
283      * @param status ICU error code.
284      * @stable ICU 53
285      */
286     static MeasureUnit *createSquareFoot(UErrorCode &status);
287 
288 #ifndef U_HIDE_DRAFT_API
289     /**
290      * Returns unit of area: square-inch.
291      * Caller owns returned value and must free it.
292      * @param status ICU error code.
293      * @draft ICU 54
294      */
295     static MeasureUnit *createSquareInch(UErrorCode &status);
296 
297 #endif /* U_HIDE_DRAFT_API */
298     /**
299      * Returns unit of area: square-kilometer.
300      * Caller owns returned value and must free it.
301      * @param status ICU error code.
302      * @stable ICU 53
303      */
304     static MeasureUnit *createSquareKilometer(UErrorCode &status);
305 
306     /**
307      * Returns unit of area: square-meter.
308      * Caller owns returned value and must free it.
309      * @param status ICU error code.
310      * @stable ICU 53
311      */
312     static MeasureUnit *createSquareMeter(UErrorCode &status);
313 
314     /**
315      * Returns unit of area: square-mile.
316      * Caller owns returned value and must free it.
317      * @param status ICU error code.
318      * @stable ICU 53
319      */
320     static MeasureUnit *createSquareMile(UErrorCode &status);
321 
322 #ifndef U_HIDE_DRAFT_API
323     /**
324      * Returns unit of area: square-yard.
325      * Caller owns returned value and must free it.
326      * @param status ICU error code.
327      * @draft ICU 54
328      */
329     static MeasureUnit *createSquareYard(UErrorCode &status);
330 
331 #endif /* U_HIDE_DRAFT_API */
332 #ifndef U_HIDE_DRAFT_API
333     /**
334      * Returns unit of consumption: liter-per-kilometer.
335      * Caller owns returned value and must free it.
336      * @param status ICU error code.
337      * @draft ICU 54
338      */
339     static MeasureUnit *createLiterPerKilometer(UErrorCode &status);
340 
341 #endif /* U_HIDE_DRAFT_API */
342 #ifndef U_HIDE_DRAFT_API
343     /**
344      * Returns unit of consumption: mile-per-gallon.
345      * Caller owns returned value and must free it.
346      * @param status ICU error code.
347      * @draft ICU 54
348      */
349     static MeasureUnit *createMilePerGallon(UErrorCode &status);
350 
351 #endif /* U_HIDE_DRAFT_API */
352 #ifndef U_HIDE_DRAFT_API
353     /**
354      * Returns unit of digital: bit.
355      * Caller owns returned value and must free it.
356      * @param status ICU error code.
357      * @draft ICU 54
358      */
359     static MeasureUnit *createBit(UErrorCode &status);
360 
361 #endif /* U_HIDE_DRAFT_API */
362 #ifndef U_HIDE_DRAFT_API
363     /**
364      * Returns unit of digital: byte.
365      * Caller owns returned value and must free it.
366      * @param status ICU error code.
367      * @draft ICU 54
368      */
369     static MeasureUnit *createByte(UErrorCode &status);
370 
371 #endif /* U_HIDE_DRAFT_API */
372 #ifndef U_HIDE_DRAFT_API
373     /**
374      * Returns unit of digital: gigabit.
375      * Caller owns returned value and must free it.
376      * @param status ICU error code.
377      * @draft ICU 54
378      */
379     static MeasureUnit *createGigabit(UErrorCode &status);
380 
381 #endif /* U_HIDE_DRAFT_API */
382 #ifndef U_HIDE_DRAFT_API
383     /**
384      * Returns unit of digital: gigabyte.
385      * Caller owns returned value and must free it.
386      * @param status ICU error code.
387      * @draft ICU 54
388      */
389     static MeasureUnit *createGigabyte(UErrorCode &status);
390 
391 #endif /* U_HIDE_DRAFT_API */
392 #ifndef U_HIDE_DRAFT_API
393     /**
394      * Returns unit of digital: kilobit.
395      * Caller owns returned value and must free it.
396      * @param status ICU error code.
397      * @draft ICU 54
398      */
399     static MeasureUnit *createKilobit(UErrorCode &status);
400 
401 #endif /* U_HIDE_DRAFT_API */
402 #ifndef U_HIDE_DRAFT_API
403     /**
404      * Returns unit of digital: kilobyte.
405      * Caller owns returned value and must free it.
406      * @param status ICU error code.
407      * @draft ICU 54
408      */
409     static MeasureUnit *createKilobyte(UErrorCode &status);
410 
411 #endif /* U_HIDE_DRAFT_API */
412 #ifndef U_HIDE_DRAFT_API
413     /**
414      * Returns unit of digital: megabit.
415      * Caller owns returned value and must free it.
416      * @param status ICU error code.
417      * @draft ICU 54
418      */
419     static MeasureUnit *createMegabit(UErrorCode &status);
420 
421 #endif /* U_HIDE_DRAFT_API */
422 #ifndef U_HIDE_DRAFT_API
423     /**
424      * Returns unit of digital: megabyte.
425      * Caller owns returned value and must free it.
426      * @param status ICU error code.
427      * @draft ICU 54
428      */
429     static MeasureUnit *createMegabyte(UErrorCode &status);
430 
431 #endif /* U_HIDE_DRAFT_API */
432 #ifndef U_HIDE_DRAFT_API
433     /**
434      * Returns unit of digital: terabit.
435      * Caller owns returned value and must free it.
436      * @param status ICU error code.
437      * @draft ICU 54
438      */
439     static MeasureUnit *createTerabit(UErrorCode &status);
440 
441 #endif /* U_HIDE_DRAFT_API */
442 #ifndef U_HIDE_DRAFT_API
443     /**
444      * Returns unit of digital: terabyte.
445      * Caller owns returned value and must free it.
446      * @param status ICU error code.
447      * @draft ICU 54
448      */
449     static MeasureUnit *createTerabyte(UErrorCode &status);
450 
451 #endif /* U_HIDE_DRAFT_API */
452     /**
453      * Returns unit of duration: day.
454      * Caller owns returned value and must free it.
455      * @param status ICU error code.
456      * @stable ICU 53
457      */
458     static MeasureUnit *createDay(UErrorCode &status);
459 
460     /**
461      * Returns unit of duration: hour.
462      * Caller owns returned value and must free it.
463      * @param status ICU error code.
464      * @stable ICU 53
465      */
466     static MeasureUnit *createHour(UErrorCode &status);
467 
468 #ifndef U_HIDE_DRAFT_API
469     /**
470      * Returns unit of duration: microsecond.
471      * Caller owns returned value and must free it.
472      * @param status ICU error code.
473      * @draft ICU 54
474      */
475     static MeasureUnit *createMicrosecond(UErrorCode &status);
476 
477 #endif /* U_HIDE_DRAFT_API */
478     /**
479      * Returns unit of duration: millisecond.
480      * Caller owns returned value and must free it.
481      * @param status ICU error code.
482      * @stable ICU 53
483      */
484     static MeasureUnit *createMillisecond(UErrorCode &status);
485 
486     /**
487      * Returns unit of duration: minute.
488      * Caller owns returned value and must free it.
489      * @param status ICU error code.
490      * @stable ICU 53
491      */
492     static MeasureUnit *createMinute(UErrorCode &status);
493 
494     /**
495      * Returns unit of duration: month.
496      * Caller owns returned value and must free it.
497      * @param status ICU error code.
498      * @stable ICU 53
499      */
500     static MeasureUnit *createMonth(UErrorCode &status);
501 
502 #ifndef U_HIDE_DRAFT_API
503     /**
504      * Returns unit of duration: nanosecond.
505      * Caller owns returned value and must free it.
506      * @param status ICU error code.
507      * @draft ICU 54
508      */
509     static MeasureUnit *createNanosecond(UErrorCode &status);
510 
511 #endif /* U_HIDE_DRAFT_API */
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 #ifndef U_HIDE_DRAFT_API
537     /**
538      * Returns unit of electric: ampere.
539      * Caller owns returned value and must free it.
540      * @param status ICU error code.
541      * @draft ICU 54
542      */
543     static MeasureUnit *createAmpere(UErrorCode &status);
544 
545 #endif /* U_HIDE_DRAFT_API */
546 #ifndef U_HIDE_DRAFT_API
547     /**
548      * Returns unit of electric: milliampere.
549      * Caller owns returned value and must free it.
550      * @param status ICU error code.
551      * @draft ICU 54
552      */
553     static MeasureUnit *createMilliampere(UErrorCode &status);
554 
555 #endif /* U_HIDE_DRAFT_API */
556 #ifndef U_HIDE_DRAFT_API
557     /**
558      * Returns unit of electric: ohm.
559      * Caller owns returned value and must free it.
560      * @param status ICU error code.
561      * @draft ICU 54
562      */
563     static MeasureUnit *createOhm(UErrorCode &status);
564 
565 #endif /* U_HIDE_DRAFT_API */
566 #ifndef U_HIDE_DRAFT_API
567     /**
568      * Returns unit of electric: volt.
569      * Caller owns returned value and must free it.
570      * @param status ICU error code.
571      * @draft ICU 54
572      */
573     static MeasureUnit *createVolt(UErrorCode &status);
574 
575 #endif /* U_HIDE_DRAFT_API */
576 #ifndef U_HIDE_DRAFT_API
577     /**
578      * Returns unit of energy: calorie.
579      * Caller owns returned value and must free it.
580      * @param status ICU error code.
581      * @draft ICU 54
582      */
583     static MeasureUnit *createCalorie(UErrorCode &status);
584 
585 #endif /* U_HIDE_DRAFT_API */
586 #ifndef U_HIDE_DRAFT_API
587     /**
588      * Returns unit of energy: foodcalorie.
589      * Caller owns returned value and must free it.
590      * @param status ICU error code.
591      * @draft ICU 54
592      */
593     static MeasureUnit *createFoodcalorie(UErrorCode &status);
594 
595 #endif /* U_HIDE_DRAFT_API */
596 #ifndef U_HIDE_DRAFT_API
597     /**
598      * Returns unit of energy: joule.
599      * Caller owns returned value and must free it.
600      * @param status ICU error code.
601      * @draft ICU 54
602      */
603     static MeasureUnit *createJoule(UErrorCode &status);
604 
605 #endif /* U_HIDE_DRAFT_API */
606 #ifndef U_HIDE_DRAFT_API
607     /**
608      * Returns unit of energy: kilocalorie.
609      * Caller owns returned value and must free it.
610      * @param status ICU error code.
611      * @draft ICU 54
612      */
613     static MeasureUnit *createKilocalorie(UErrorCode &status);
614 
615 #endif /* U_HIDE_DRAFT_API */
616 #ifndef U_HIDE_DRAFT_API
617     /**
618      * Returns unit of energy: kilojoule.
619      * Caller owns returned value and must free it.
620      * @param status ICU error code.
621      * @draft ICU 54
622      */
623     static MeasureUnit *createKilojoule(UErrorCode &status);
624 
625 #endif /* U_HIDE_DRAFT_API */
626 #ifndef U_HIDE_DRAFT_API
627     /**
628      * Returns unit of energy: kilowatt-hour.
629      * Caller owns returned value and must free it.
630      * @param status ICU error code.
631      * @draft ICU 54
632      */
633     static MeasureUnit *createKilowattHour(UErrorCode &status);
634 
635 #endif /* U_HIDE_DRAFT_API */
636 #ifndef U_HIDE_DRAFT_API
637     /**
638      * Returns unit of frequency: gigahertz.
639      * Caller owns returned value and must free it.
640      * @param status ICU error code.
641      * @draft ICU 54
642      */
643     static MeasureUnit *createGigahertz(UErrorCode &status);
644 
645 #endif /* U_HIDE_DRAFT_API */
646 #ifndef U_HIDE_DRAFT_API
647     /**
648      * Returns unit of frequency: hertz.
649      * Caller owns returned value and must free it.
650      * @param status ICU error code.
651      * @draft ICU 54
652      */
653     static MeasureUnit *createHertz(UErrorCode &status);
654 
655 #endif /* U_HIDE_DRAFT_API */
656 #ifndef U_HIDE_DRAFT_API
657     /**
658      * Returns unit of frequency: kilohertz.
659      * Caller owns returned value and must free it.
660      * @param status ICU error code.
661      * @draft ICU 54
662      */
663     static MeasureUnit *createKilohertz(UErrorCode &status);
664 
665 #endif /* U_HIDE_DRAFT_API */
666 #ifndef U_HIDE_DRAFT_API
667     /**
668      * Returns unit of frequency: megahertz.
669      * Caller owns returned value and must free it.
670      * @param status ICU error code.
671      * @draft ICU 54
672      */
673     static MeasureUnit *createMegahertz(UErrorCode &status);
674 
675 #endif /* U_HIDE_DRAFT_API */
676 #ifndef U_HIDE_DRAFT_API
677     /**
678      * Returns unit of length: astronomical-unit.
679      * Caller owns returned value and must free it.
680      * @param status ICU error code.
681      * @draft ICU 54
682      */
683     static MeasureUnit *createAstronomicalUnit(UErrorCode &status);
684 
685 #endif /* U_HIDE_DRAFT_API */
686     /**
687      * Returns unit of length: centimeter.
688      * Caller owns returned value and must free it.
689      * @param status ICU error code.
690      * @stable ICU 53
691      */
692     static MeasureUnit *createCentimeter(UErrorCode &status);
693 
694 #ifndef U_HIDE_DRAFT_API
695     /**
696      * Returns unit of length: decimeter.
697      * Caller owns returned value and must free it.
698      * @param status ICU error code.
699      * @draft ICU 54
700      */
701     static MeasureUnit *createDecimeter(UErrorCode &status);
702 
703 #endif /* U_HIDE_DRAFT_API */
704 #ifndef U_HIDE_DRAFT_API
705     /**
706      * Returns unit of length: fathom.
707      * Caller owns returned value and must free it.
708      * @param status ICU error code.
709      * @draft ICU 54
710      */
711     static MeasureUnit *createFathom(UErrorCode &status);
712 
713 #endif /* U_HIDE_DRAFT_API */
714     /**
715      * Returns unit of length: foot.
716      * Caller owns returned value and must free it.
717      * @param status ICU error code.
718      * @stable ICU 53
719      */
720     static MeasureUnit *createFoot(UErrorCode &status);
721 
722 #ifndef U_HIDE_DRAFT_API
723     /**
724      * Returns unit of length: furlong.
725      * Caller owns returned value and must free it.
726      * @param status ICU error code.
727      * @draft ICU 54
728      */
729     static MeasureUnit *createFurlong(UErrorCode &status);
730 
731 #endif /* U_HIDE_DRAFT_API */
732     /**
733      * Returns unit of length: inch.
734      * Caller owns returned value and must free it.
735      * @param status ICU error code.
736      * @stable ICU 53
737      */
738     static MeasureUnit *createInch(UErrorCode &status);
739 
740     /**
741      * Returns unit of length: kilometer.
742      * Caller owns returned value and must free it.
743      * @param status ICU error code.
744      * @stable ICU 53
745      */
746     static MeasureUnit *createKilometer(UErrorCode &status);
747 
748     /**
749      * Returns unit of length: light-year.
750      * Caller owns returned value and must free it.
751      * @param status ICU error code.
752      * @stable ICU 53
753      */
754     static MeasureUnit *createLightYear(UErrorCode &status);
755 
756     /**
757      * Returns unit of length: meter.
758      * Caller owns returned value and must free it.
759      * @param status ICU error code.
760      * @stable ICU 53
761      */
762     static MeasureUnit *createMeter(UErrorCode &status);
763 
764 #ifndef U_HIDE_DRAFT_API
765     /**
766      * Returns unit of length: micrometer.
767      * Caller owns returned value and must free it.
768      * @param status ICU error code.
769      * @draft ICU 54
770      */
771     static MeasureUnit *createMicrometer(UErrorCode &status);
772 
773 #endif /* U_HIDE_DRAFT_API */
774     /**
775      * Returns unit of length: mile.
776      * Caller owns returned value and must free it.
777      * @param status ICU error code.
778      * @stable ICU 53
779      */
780     static MeasureUnit *createMile(UErrorCode &status);
781 
782     /**
783      * Returns unit of length: millimeter.
784      * Caller owns returned value and must free it.
785      * @param status ICU error code.
786      * @stable ICU 53
787      */
788     static MeasureUnit *createMillimeter(UErrorCode &status);
789 
790 #ifndef U_HIDE_DRAFT_API
791     /**
792      * Returns unit of length: nanometer.
793      * Caller owns returned value and must free it.
794      * @param status ICU error code.
795      * @draft ICU 54
796      */
797     static MeasureUnit *createNanometer(UErrorCode &status);
798 
799 #endif /* U_HIDE_DRAFT_API */
800 #ifndef U_HIDE_DRAFT_API
801     /**
802      * Returns unit of length: nautical-mile.
803      * Caller owns returned value and must free it.
804      * @param status ICU error code.
805      * @draft ICU 54
806      */
807     static MeasureUnit *createNauticalMile(UErrorCode &status);
808 
809 #endif /* U_HIDE_DRAFT_API */
810 #ifndef U_HIDE_DRAFT_API
811     /**
812      * Returns unit of length: parsec.
813      * Caller owns returned value and must free it.
814      * @param status ICU error code.
815      * @draft ICU 54
816      */
817     static MeasureUnit *createParsec(UErrorCode &status);
818 
819 #endif /* U_HIDE_DRAFT_API */
820     /**
821      * Returns unit of length: picometer.
822      * Caller owns returned value and must free it.
823      * @param status ICU error code.
824      * @stable ICU 53
825      */
826     static MeasureUnit *createPicometer(UErrorCode &status);
827 
828     /**
829      * Returns unit of length: yard.
830      * Caller owns returned value and must free it.
831      * @param status ICU error code.
832      * @stable ICU 53
833      */
834     static MeasureUnit *createYard(UErrorCode &status);
835 
836 #ifndef U_HIDE_DRAFT_API
837     /**
838      * Returns unit of light: lux.
839      * Caller owns returned value and must free it.
840      * @param status ICU error code.
841      * @draft ICU 54
842      */
843     static MeasureUnit *createLux(UErrorCode &status);
844 
845 #endif /* U_HIDE_DRAFT_API */
846 #ifndef U_HIDE_DRAFT_API
847     /**
848      * Returns unit of mass: carat.
849      * Caller owns returned value and must free it.
850      * @param status ICU error code.
851      * @draft ICU 54
852      */
853     static MeasureUnit *createCarat(UErrorCode &status);
854 
855 #endif /* U_HIDE_DRAFT_API */
856     /**
857      * Returns unit of mass: gram.
858      * Caller owns returned value and must free it.
859      * @param status ICU error code.
860      * @stable ICU 53
861      */
862     static MeasureUnit *createGram(UErrorCode &status);
863 
864     /**
865      * Returns unit of mass: kilogram.
866      * Caller owns returned value and must free it.
867      * @param status ICU error code.
868      * @stable ICU 53
869      */
870     static MeasureUnit *createKilogram(UErrorCode &status);
871 
872 #ifndef U_HIDE_DRAFT_API
873     /**
874      * Returns unit of mass: metric-ton.
875      * Caller owns returned value and must free it.
876      * @param status ICU error code.
877      * @draft ICU 54
878      */
879     static MeasureUnit *createMetricTon(UErrorCode &status);
880 
881 #endif /* U_HIDE_DRAFT_API */
882 #ifndef U_HIDE_DRAFT_API
883     /**
884      * Returns unit of mass: microgram.
885      * Caller owns returned value and must free it.
886      * @param status ICU error code.
887      * @draft ICU 54
888      */
889     static MeasureUnit *createMicrogram(UErrorCode &status);
890 
891 #endif /* U_HIDE_DRAFT_API */
892 #ifndef U_HIDE_DRAFT_API
893     /**
894      * Returns unit of mass: milligram.
895      * Caller owns returned value and must free it.
896      * @param status ICU error code.
897      * @draft ICU 54
898      */
899     static MeasureUnit *createMilligram(UErrorCode &status);
900 
901 #endif /* U_HIDE_DRAFT_API */
902     /**
903      * Returns unit of mass: ounce.
904      * Caller owns returned value and must free it.
905      * @param status ICU error code.
906      * @stable ICU 53
907      */
908     static MeasureUnit *createOunce(UErrorCode &status);
909 
910 #ifndef U_HIDE_DRAFT_API
911     /**
912      * Returns unit of mass: ounce-troy.
913      * Caller owns returned value and must free it.
914      * @param status ICU error code.
915      * @draft ICU 54
916      */
917     static MeasureUnit *createOunceTroy(UErrorCode &status);
918 
919 #endif /* U_HIDE_DRAFT_API */
920     /**
921      * Returns unit of mass: pound.
922      * Caller owns returned value and must free it.
923      * @param status ICU error code.
924      * @stable ICU 53
925      */
926     static MeasureUnit *createPound(UErrorCode &status);
927 
928 #ifndef U_HIDE_DRAFT_API
929     /**
930      * Returns unit of mass: stone.
931      * Caller owns returned value and must free it.
932      * @param status ICU error code.
933      * @draft ICU 54
934      */
935     static MeasureUnit *createStone(UErrorCode &status);
936 
937 #endif /* U_HIDE_DRAFT_API */
938 #ifndef U_HIDE_DRAFT_API
939     /**
940      * Returns unit of mass: ton.
941      * Caller owns returned value and must free it.
942      * @param status ICU error code.
943      * @draft ICU 54
944      */
945     static MeasureUnit *createTon(UErrorCode &status);
946 
947 #endif /* U_HIDE_DRAFT_API */
948 #ifndef U_HIDE_DRAFT_API
949     /**
950      * Returns unit of power: gigawatt.
951      * Caller owns returned value and must free it.
952      * @param status ICU error code.
953      * @draft ICU 54
954      */
955     static MeasureUnit *createGigawatt(UErrorCode &status);
956 
957 #endif /* U_HIDE_DRAFT_API */
958     /**
959      * Returns unit of power: horsepower.
960      * Caller owns returned value and must free it.
961      * @param status ICU error code.
962      * @stable ICU 53
963      */
964     static MeasureUnit *createHorsepower(UErrorCode &status);
965 
966     /**
967      * Returns unit of power: kilowatt.
968      * Caller owns returned value and must free it.
969      * @param status ICU error code.
970      * @stable ICU 53
971      */
972     static MeasureUnit *createKilowatt(UErrorCode &status);
973 
974 #ifndef U_HIDE_DRAFT_API
975     /**
976      * Returns unit of power: megawatt.
977      * Caller owns returned value and must free it.
978      * @param status ICU error code.
979      * @draft ICU 54
980      */
981     static MeasureUnit *createMegawatt(UErrorCode &status);
982 
983 #endif /* U_HIDE_DRAFT_API */
984 #ifndef U_HIDE_DRAFT_API
985     /**
986      * Returns unit of power: milliwatt.
987      * Caller owns returned value and must free it.
988      * @param status ICU error code.
989      * @draft ICU 54
990      */
991     static MeasureUnit *createMilliwatt(UErrorCode &status);
992 
993 #endif /* U_HIDE_DRAFT_API */
994     /**
995      * Returns unit of power: watt.
996      * Caller owns returned value and must free it.
997      * @param status ICU error code.
998      * @stable ICU 53
999      */
1000     static MeasureUnit *createWatt(UErrorCode &status);
1001 
1002     /**
1003      * Returns unit of pressure: hectopascal.
1004      * Caller owns returned value and must free it.
1005      * @param status ICU error code.
1006      * @stable ICU 53
1007      */
1008     static MeasureUnit *createHectopascal(UErrorCode &status);
1009 
1010     /**
1011      * Returns unit of pressure: inch-hg.
1012      * Caller owns returned value and must free it.
1013      * @param status ICU error code.
1014      * @stable ICU 53
1015      */
1016     static MeasureUnit *createInchHg(UErrorCode &status);
1017 
1018     /**
1019      * Returns unit of pressure: millibar.
1020      * Caller owns returned value and must free it.
1021      * @param status ICU error code.
1022      * @stable ICU 53
1023      */
1024     static MeasureUnit *createMillibar(UErrorCode &status);
1025 
1026 #ifndef U_HIDE_DRAFT_API
1027     /**
1028      * Returns unit of pressure: millimeter-of-mercury.
1029      * Caller owns returned value and must free it.
1030      * @param status ICU error code.
1031      * @draft ICU 54
1032      */
1033     static MeasureUnit *createMillimeterOfMercury(UErrorCode &status);
1034 
1035 #endif /* U_HIDE_DRAFT_API */
1036 #ifndef U_HIDE_DRAFT_API
1037     /**
1038      * Returns unit of pressure: pound-per-square-inch.
1039      * Caller owns returned value and must free it.
1040      * @param status ICU error code.
1041      * @draft ICU 54
1042      */
1043     static MeasureUnit *createPoundPerSquareInch(UErrorCode &status);
1044 
1045 #endif /* U_HIDE_DRAFT_API */
1046 #ifndef U_HIDE_DRAFT_API
1047     /**
1048      * Returns unit of proportion: karat.
1049      * Caller owns returned value and must free it.
1050      * @param status ICU error code.
1051      * @draft ICU 54
1052      */
1053     static MeasureUnit *createKarat(UErrorCode &status);
1054 
1055 #endif /* U_HIDE_DRAFT_API */
1056     /**
1057      * Returns unit of speed: kilometer-per-hour.
1058      * Caller owns returned value and must free it.
1059      * @param status ICU error code.
1060      * @stable ICU 53
1061      */
1062     static MeasureUnit *createKilometerPerHour(UErrorCode &status);
1063 
1064     /**
1065      * Returns unit of speed: meter-per-second.
1066      * Caller owns returned value and must free it.
1067      * @param status ICU error code.
1068      * @stable ICU 53
1069      */
1070     static MeasureUnit *createMeterPerSecond(UErrorCode &status);
1071 
1072     /**
1073      * Returns unit of speed: mile-per-hour.
1074      * Caller owns returned value and must free it.
1075      * @param status ICU error code.
1076      * @stable ICU 53
1077      */
1078     static MeasureUnit *createMilePerHour(UErrorCode &status);
1079 
1080     /**
1081      * Returns unit of temperature: celsius.
1082      * Caller owns returned value and must free it.
1083      * @param status ICU error code.
1084      * @stable ICU 53
1085      */
1086     static MeasureUnit *createCelsius(UErrorCode &status);
1087 
1088     /**
1089      * Returns unit of temperature: fahrenheit.
1090      * Caller owns returned value and must free it.
1091      * @param status ICU error code.
1092      * @stable ICU 53
1093      */
1094     static MeasureUnit *createFahrenheit(UErrorCode &status);
1095 
1096 #ifndef U_HIDE_DRAFT_API
1097     /**
1098      * Returns unit of temperature: kelvin.
1099      * Caller owns returned value and must free it.
1100      * @param status ICU error code.
1101      * @draft ICU 54
1102      */
1103     static MeasureUnit *createKelvin(UErrorCode &status);
1104 
1105 #endif /* U_HIDE_DRAFT_API */
1106 #ifndef U_HIDE_DRAFT_API
1107     /**
1108      * Returns unit of volume: acre-foot.
1109      * Caller owns returned value and must free it.
1110      * @param status ICU error code.
1111      * @draft ICU 54
1112      */
1113     static MeasureUnit *createAcreFoot(UErrorCode &status);
1114 
1115 #endif /* U_HIDE_DRAFT_API */
1116 #ifndef U_HIDE_DRAFT_API
1117     /**
1118      * Returns unit of volume: bushel.
1119      * Caller owns returned value and must free it.
1120      * @param status ICU error code.
1121      * @draft ICU 54
1122      */
1123     static MeasureUnit *createBushel(UErrorCode &status);
1124 
1125 #endif /* U_HIDE_DRAFT_API */
1126 #ifndef U_HIDE_DRAFT_API
1127     /**
1128      * Returns unit of volume: centiliter.
1129      * Caller owns returned value and must free it.
1130      * @param status ICU error code.
1131      * @draft ICU 54
1132      */
1133     static MeasureUnit *createCentiliter(UErrorCode &status);
1134 
1135 #endif /* U_HIDE_DRAFT_API */
1136 #ifndef U_HIDE_DRAFT_API
1137     /**
1138      * Returns unit of volume: cubic-centimeter.
1139      * Caller owns returned value and must free it.
1140      * @param status ICU error code.
1141      * @draft ICU 54
1142      */
1143     static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1144 
1145 #endif /* U_HIDE_DRAFT_API */
1146 #ifndef U_HIDE_DRAFT_API
1147     /**
1148      * Returns unit of volume: cubic-foot.
1149      * Caller owns returned value and must free it.
1150      * @param status ICU error code.
1151      * @draft ICU 54
1152      */
1153     static MeasureUnit *createCubicFoot(UErrorCode &status);
1154 
1155 #endif /* U_HIDE_DRAFT_API */
1156 #ifndef U_HIDE_DRAFT_API
1157     /**
1158      * Returns unit of volume: cubic-inch.
1159      * Caller owns returned value and must free it.
1160      * @param status ICU error code.
1161      * @draft ICU 54
1162      */
1163     static MeasureUnit *createCubicInch(UErrorCode &status);
1164 
1165 #endif /* U_HIDE_DRAFT_API */
1166     /**
1167      * Returns unit of volume: cubic-kilometer.
1168      * Caller owns returned value and must free it.
1169      * @param status ICU error code.
1170      * @stable ICU 53
1171      */
1172     static MeasureUnit *createCubicKilometer(UErrorCode &status);
1173 
1174 #ifndef U_HIDE_DRAFT_API
1175     /**
1176      * Returns unit of volume: cubic-meter.
1177      * Caller owns returned value and must free it.
1178      * @param status ICU error code.
1179      * @draft ICU 54
1180      */
1181     static MeasureUnit *createCubicMeter(UErrorCode &status);
1182 
1183 #endif /* U_HIDE_DRAFT_API */
1184     /**
1185      * Returns unit of volume: cubic-mile.
1186      * Caller owns returned value and must free it.
1187      * @param status ICU error code.
1188      * @stable ICU 53
1189      */
1190     static MeasureUnit *createCubicMile(UErrorCode &status);
1191 
1192 #ifndef U_HIDE_DRAFT_API
1193     /**
1194      * Returns unit of volume: cubic-yard.
1195      * Caller owns returned value and must free it.
1196      * @param status ICU error code.
1197      * @draft ICU 54
1198      */
1199     static MeasureUnit *createCubicYard(UErrorCode &status);
1200 
1201 #endif /* U_HIDE_DRAFT_API */
1202 #ifndef U_HIDE_DRAFT_API
1203     /**
1204      * Returns unit of volume: cup.
1205      * Caller owns returned value and must free it.
1206      * @param status ICU error code.
1207      * @draft ICU 54
1208      */
1209     static MeasureUnit *createCup(UErrorCode &status);
1210 
1211 #endif /* U_HIDE_DRAFT_API */
1212 #ifndef U_HIDE_DRAFT_API
1213     /**
1214      * Returns unit of volume: deciliter.
1215      * Caller owns returned value and must free it.
1216      * @param status ICU error code.
1217      * @draft ICU 54
1218      */
1219     static MeasureUnit *createDeciliter(UErrorCode &status);
1220 
1221 #endif /* U_HIDE_DRAFT_API */
1222 #ifndef U_HIDE_DRAFT_API
1223     /**
1224      * Returns unit of volume: fluid-ounce.
1225      * Caller owns returned value and must free it.
1226      * @param status ICU error code.
1227      * @draft ICU 54
1228      */
1229     static MeasureUnit *createFluidOunce(UErrorCode &status);
1230 
1231 #endif /* U_HIDE_DRAFT_API */
1232 #ifndef U_HIDE_DRAFT_API
1233     /**
1234      * Returns unit of volume: gallon.
1235      * Caller owns returned value and must free it.
1236      * @param status ICU error code.
1237      * @draft ICU 54
1238      */
1239     static MeasureUnit *createGallon(UErrorCode &status);
1240 
1241 #endif /* U_HIDE_DRAFT_API */
1242 #ifndef U_HIDE_DRAFT_API
1243     /**
1244      * Returns unit of volume: hectoliter.
1245      * Caller owns returned value and must free it.
1246      * @param status ICU error code.
1247      * @draft ICU 54
1248      */
1249     static MeasureUnit *createHectoliter(UErrorCode &status);
1250 
1251 #endif /* U_HIDE_DRAFT_API */
1252     /**
1253      * Returns unit of volume: liter.
1254      * Caller owns returned value and must free it.
1255      * @param status ICU error code.
1256      * @stable ICU 53
1257      */
1258     static MeasureUnit *createLiter(UErrorCode &status);
1259 
1260 #ifndef U_HIDE_DRAFT_API
1261     /**
1262      * Returns unit of volume: megaliter.
1263      * Caller owns returned value and must free it.
1264      * @param status ICU error code.
1265      * @draft ICU 54
1266      */
1267     static MeasureUnit *createMegaliter(UErrorCode &status);
1268 
1269 #endif /* U_HIDE_DRAFT_API */
1270 #ifndef U_HIDE_DRAFT_API
1271     /**
1272      * Returns unit of volume: milliliter.
1273      * Caller owns returned value and must free it.
1274      * @param status ICU error code.
1275      * @draft ICU 54
1276      */
1277     static MeasureUnit *createMilliliter(UErrorCode &status);
1278 
1279 #endif /* U_HIDE_DRAFT_API */
1280 #ifndef U_HIDE_DRAFT_API
1281     /**
1282      * Returns unit of volume: pint.
1283      * Caller owns returned value and must free it.
1284      * @param status ICU error code.
1285      * @draft ICU 54
1286      */
1287     static MeasureUnit *createPint(UErrorCode &status);
1288 
1289 #endif /* U_HIDE_DRAFT_API */
1290 #ifndef U_HIDE_DRAFT_API
1291     /**
1292      * Returns unit of volume: quart.
1293      * Caller owns returned value and must free it.
1294      * @param status ICU error code.
1295      * @draft ICU 54
1296      */
1297     static MeasureUnit *createQuart(UErrorCode &status);
1298 
1299 #endif /* U_HIDE_DRAFT_API */
1300 #ifndef U_HIDE_DRAFT_API
1301     /**
1302      * Returns unit of volume: tablespoon.
1303      * Caller owns returned value and must free it.
1304      * @param status ICU error code.
1305      * @draft ICU 54
1306      */
1307     static MeasureUnit *createTablespoon(UErrorCode &status);
1308 
1309 #endif /* U_HIDE_DRAFT_API */
1310 #ifndef U_HIDE_DRAFT_API
1311     /**
1312      * Returns unit of volume: teaspoon.
1313      * Caller owns returned value and must free it.
1314      * @param status ICU error code.
1315      * @draft ICU 54
1316      */
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     /**
1327      * For ICU use only.
1328      * @internal
1329      */
1330     void initTime(const char *timeId);
1331 
1332     /**
1333      * For ICU use only.
1334      * @internal
1335      */
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 
MeasureUnit(int32_t typeId,int32_t subTypeId)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__
1357