measunit.h 38 KB

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