ICU-551.51.4.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / measunit.h
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 */
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 * Apple-specific for now
1109 * Returns unit of temperature: generic temperature.
1110 * Caller owns returned value and must free it.
1111 * @param status ICU error code.
1112 * @internal
1113 */
1114 static MeasureUnit *createGenericTemperature(UErrorCode &status);
1115
1116 #endif /* U_HIDE_DRAFT_API */
1117 #ifndef U_HIDE_DRAFT_API
1118 /**
1119 * Returns unit of volume: acre-foot.
1120 * Caller owns returned value and must free it.
1121 * @param status ICU error code.
1122 * @draft ICU 54
1123 */
1124 static MeasureUnit *createAcreFoot(UErrorCode &status);
1125
1126 #endif /* U_HIDE_DRAFT_API */
1127 #ifndef U_HIDE_DRAFT_API
1128 /**
1129 * Returns unit of volume: bushel.
1130 * Caller owns returned value and must free it.
1131 * @param status ICU error code.
1132 * @draft ICU 54
1133 */
1134 static MeasureUnit *createBushel(UErrorCode &status);
1135
1136 #endif /* U_HIDE_DRAFT_API */
1137 #ifndef U_HIDE_DRAFT_API
1138 /**
1139 * Returns unit of volume: centiliter.
1140 * Caller owns returned value and must free it.
1141 * @param status ICU error code.
1142 * @draft ICU 54
1143 */
1144 static MeasureUnit *createCentiliter(UErrorCode &status);
1145
1146 #endif /* U_HIDE_DRAFT_API */
1147 #ifndef U_HIDE_DRAFT_API
1148 /**
1149 * Returns unit of volume: cubic-centimeter.
1150 * Caller owns returned value and must free it.
1151 * @param status ICU error code.
1152 * @draft ICU 54
1153 */
1154 static MeasureUnit *createCubicCentimeter(UErrorCode &status);
1155
1156 #endif /* U_HIDE_DRAFT_API */
1157 #ifndef U_HIDE_DRAFT_API
1158 /**
1159 * Returns unit of volume: cubic-foot.
1160 * Caller owns returned value and must free it.
1161 * @param status ICU error code.
1162 * @draft ICU 54
1163 */
1164 static MeasureUnit *createCubicFoot(UErrorCode &status);
1165
1166 #endif /* U_HIDE_DRAFT_API */
1167 #ifndef U_HIDE_DRAFT_API
1168 /**
1169 * Returns unit of volume: cubic-inch.
1170 * Caller owns returned value and must free it.
1171 * @param status ICU error code.
1172 * @draft ICU 54
1173 */
1174 static MeasureUnit *createCubicInch(UErrorCode &status);
1175
1176 #endif /* U_HIDE_DRAFT_API */
1177 /**
1178 * Returns unit of volume: cubic-kilometer.
1179 * Caller owns returned value and must free it.
1180 * @param status ICU error code.
1181 * @stable ICU 53
1182 */
1183 static MeasureUnit *createCubicKilometer(UErrorCode &status);
1184
1185 #ifndef U_HIDE_DRAFT_API
1186 /**
1187 * Returns unit of volume: cubic-meter.
1188 * Caller owns returned value and must free it.
1189 * @param status ICU error code.
1190 * @draft ICU 54
1191 */
1192 static MeasureUnit *createCubicMeter(UErrorCode &status);
1193
1194 #endif /* U_HIDE_DRAFT_API */
1195 /**
1196 * Returns unit of volume: cubic-mile.
1197 * Caller owns returned value and must free it.
1198 * @param status ICU error code.
1199 * @stable ICU 53
1200 */
1201 static MeasureUnit *createCubicMile(UErrorCode &status);
1202
1203 #ifndef U_HIDE_DRAFT_API
1204 /**
1205 * Returns unit of volume: cubic-yard.
1206 * Caller owns returned value and must free it.
1207 * @param status ICU error code.
1208 * @draft ICU 54
1209 */
1210 static MeasureUnit *createCubicYard(UErrorCode &status);
1211
1212 #endif /* U_HIDE_DRAFT_API */
1213 #ifndef U_HIDE_DRAFT_API
1214 /**
1215 * Returns unit of volume: cup.
1216 * Caller owns returned value and must free it.
1217 * @param status ICU error code.
1218 * @draft ICU 54
1219 */
1220 static MeasureUnit *createCup(UErrorCode &status);
1221
1222 #endif /* U_HIDE_DRAFT_API */
1223 #ifndef U_HIDE_DRAFT_API
1224 /**
1225 * Returns unit of volume: deciliter.
1226 * Caller owns returned value and must free it.
1227 * @param status ICU error code.
1228 * @draft ICU 54
1229 */
1230 static MeasureUnit *createDeciliter(UErrorCode &status);
1231
1232 #endif /* U_HIDE_DRAFT_API */
1233 #ifndef U_HIDE_DRAFT_API
1234 /**
1235 * Returns unit of volume: fluid-ounce.
1236 * Caller owns returned value and must free it.
1237 * @param status ICU error code.
1238 * @draft ICU 54
1239 */
1240 static MeasureUnit *createFluidOunce(UErrorCode &status);
1241
1242 #endif /* U_HIDE_DRAFT_API */
1243 #ifndef U_HIDE_DRAFT_API
1244 /**
1245 * Returns unit of volume: gallon.
1246 * Caller owns returned value and must free it.
1247 * @param status ICU error code.
1248 * @draft ICU 54
1249 */
1250 static MeasureUnit *createGallon(UErrorCode &status);
1251
1252 #endif /* U_HIDE_DRAFT_API */
1253 #ifndef U_HIDE_DRAFT_API
1254 /**
1255 * Returns unit of volume: hectoliter.
1256 * Caller owns returned value and must free it.
1257 * @param status ICU error code.
1258 * @draft ICU 54
1259 */
1260 static MeasureUnit *createHectoliter(UErrorCode &status);
1261
1262 #endif /* U_HIDE_DRAFT_API */
1263 /**
1264 * Returns unit of volume: liter.
1265 * Caller owns returned value and must free it.
1266 * @param status ICU error code.
1267 * @stable ICU 53
1268 */
1269 static MeasureUnit *createLiter(UErrorCode &status);
1270
1271 #ifndef U_HIDE_DRAFT_API
1272 /**
1273 * Returns unit of volume: megaliter.
1274 * Caller owns returned value and must free it.
1275 * @param status ICU error code.
1276 * @draft ICU 54
1277 */
1278 static MeasureUnit *createMegaliter(UErrorCode &status);
1279
1280 #endif /* U_HIDE_DRAFT_API */
1281 #ifndef U_HIDE_DRAFT_API
1282 /**
1283 * Returns unit of volume: milliliter.
1284 * Caller owns returned value and must free it.
1285 * @param status ICU error code.
1286 * @draft ICU 54
1287 */
1288 static MeasureUnit *createMilliliter(UErrorCode &status);
1289
1290 #endif /* U_HIDE_DRAFT_API */
1291 #ifndef U_HIDE_DRAFT_API
1292 /**
1293 * Returns unit of volume: pint.
1294 * Caller owns returned value and must free it.
1295 * @param status ICU error code.
1296 * @draft ICU 54
1297 */
1298 static MeasureUnit *createPint(UErrorCode &status);
1299
1300 #endif /* U_HIDE_DRAFT_API */
1301 #ifndef U_HIDE_DRAFT_API
1302 /**
1303 * Returns unit of volume: quart.
1304 * Caller owns returned value and must free it.
1305 * @param status ICU error code.
1306 * @draft ICU 54
1307 */
1308 static MeasureUnit *createQuart(UErrorCode &status);
1309
1310 #endif /* U_HIDE_DRAFT_API */
1311 #ifndef U_HIDE_DRAFT_API
1312 /**
1313 * Returns unit of volume: tablespoon.
1314 * Caller owns returned value and must free it.
1315 * @param status ICU error code.
1316 * @draft ICU 54
1317 */
1318 static MeasureUnit *createTablespoon(UErrorCode &status);
1319
1320 #endif /* U_HIDE_DRAFT_API */
1321 #ifndef U_HIDE_DRAFT_API
1322 /**
1323 * Returns unit of volume: teaspoon.
1324 * Caller owns returned value and must free it.
1325 * @param status ICU error code.
1326 * @draft ICU 54
1327 */
1328 static MeasureUnit *createTeaspoon(UErrorCode &status);
1329
1330 #endif /* U_HIDE_DRAFT_API */
1331
1332 // End generated createXXX methods
1333
1334 protected:
1335
1336 #ifndef U_HIDE_INTERNAL_API
1337 /**
1338 * For ICU use only.
1339 * @internal
1340 */
1341 void initTime(const char *timeId);
1342
1343 /**
1344 * For ICU use only.
1345 * @internal
1346 */
1347 void initCurrency(const char *isoCurrency);
1348
1349 #endif /* U_HIDE_INTERNAL_API */
1350
1351 private:
1352 int32_t fTypeId;
1353 int32_t fSubTypeId;
1354 char fCurrency[4];
1355
1356 MeasureUnit(int32_t typeId, int32_t subTypeId) : fTypeId(typeId), fSubTypeId(subTypeId) {
1357 fCurrency[0] = 0;
1358 }
1359 void setTo(int32_t typeId, int32_t subTypeId);
1360 int32_t getOffset() const;
1361 static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
1362 };
1363
1364 U_NAMESPACE_END
1365
1366 #endif // !UNCONFIG_NO_FORMATTING
1367 #endif // __MEASUREUNIT_H__