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