]> granicus.if.org Git - icu/commitdiff
Improve documentation comments.
authorHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Tue, 14 Apr 2020 18:59:41 +0000 (20:59 +0200)
committerHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Tue, 14 Apr 2020 18:59:41 +0000 (20:59 +0200)
icu4c/source/i18n/unitsdata.cpp
icu4c/source/i18n/unitsdata.h

index 3e285b65bd6ee2ea11c053e9c891b1a1d63756ba..27990386e7d06673eea19d50ee6bcbf957ceff06 100644 (file)
@@ -20,15 +20,7 @@ namespace {
 /**
  * A ResourceSink that collects conversion rate information.
  *
- * This class is for use by ures_getAllItemsWithFallback. Example code for
- * collecting conversion info for "mile" and "foot" into conversionInfoOutput:
- *
- *     UErrorCode status = U_ZERO_ERROR;
- *     ures_getByKey(unitsBundle, "convertUnits", &fillIn, &status);
- *     MaybeStackVector<ConversionRateInfo> conversionInfoOutput;
- *     ConversionRateDataSink convertSink(conversionInfoOutput);
- *     ures_getAllItemsWithFallback(fillIn, "mile", convertSink, status);
- *     ures_getAllItemsWithFallback(fillIn, "foot", convertSink, status);
+ * This class is for use by ures_getAllItemsWithFallback.
  */
 class ConversionRateDataSink : public ResourceSink {
   public:
@@ -55,6 +47,8 @@ class ConversionRateDataSink : public ResourceSink {
     void put(const char *source, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) {
         if (U_FAILURE(status)) return;
         if (uprv_strcmp(source, "convertUnits") != 0) {
+            // This is very strict, however it is the cheapest way to be sure
+            // that with `value`, we're looking at the convertUnits table.
             status = U_ILLEGAL_ARGUMENT_ERROR;
             return;
         }
index 87e49a8ec6f24cceb552c05e5b22851dfb33f9b2..5bba426862dc4c37c7173839bfb21a9183998e8e 100644 (file)
 
 U_NAMESPACE_BEGIN
 
-// Encapsulates "convertUnits" information from units resources, specifying how
-// to convert from one unit to another.
-//
-// Information in this class is still in the form of strings: symbolic constants
-// need to be interpreted.
+/**
+ * Encapsulates "convertUnits" information from units resources, specifying how
+ * to convert from one unit to another.
+ *
+ * Information in this class is still in the form of strings: symbolic constants
+ * need to be interpreted. Rationale: symbols can cancel out for higher
+ * precision conversion - going from feet to inches should cancel out the
+ * `ft_to_m` constant.
+ */
 class U_I18N_API ConversionRateInfo {
   public:
     ConversionRateInfo(){};
@@ -45,11 +49,13 @@ class U_I18N_API ConversionRateInfo {
 MaybeStackVector<ConversionRateInfo> U_I18N_API getAllConversionRates(UErrorCode &status);
 
 /**
- * Collects and returns ConversionRateInfo needed for conversions for a set of
- * units.
+ * Temporary backward-compatibility function.
  *
- * @param units The units for which to load conversion data.
- * @param status Receives status.
+ * TODO(hugovdm): ensure this gets removed. Currently
+ * https://github.com/sffc/icu/pull/32 is making use of it.
+ *
+ * @param units Ignored.
+ * @return the result of getAllConversionRates.
  */
 MaybeStackVector<ConversionRateInfo>
     U_I18N_API getConversionRatesInfo(const MaybeStackVector<MeasureUnit> &units, UErrorCode &status);