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