measunit.h 38 KB

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