+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
-* Copyright (c) 2004-2015, International Business Machines
+* Copyright (c) 2004-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
#include "unicode/format.h"
#include "unicode/udat.h"
+// Apple specific:
+#include "unicode/uameasureformat.h"
/**
* \file
*/
UMEASFMT_WIDTH_NUMERIC,
+#ifndef U_HIDE_DEPRECATED_API
/**
- * Count of values in this enum.
- * @stable ICU 53
+ * One more than the highest normal UMeasureFormatWidth value.
+ * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UMEASFMT_WIDTH_COUNT = 4
+#endif // U_HIDE_DEPRECATED_API
+#ifndef U_HIDE_INTERNAL_API
+ ,
+ /**
+ * Apple-specific
+ * Shorter, between SHORT and NARROW (SHORT without space in unit pattern)
+ * @draft ICU 57
+ */
+ UMEASFMT_WIDTH_SHORTER = 8
+#endif /* U_HIDE_INTERNAL_API */
};
/** @stable ICU 53 */
typedef enum UMeasureFormatWidth UMeasureFormatWidth;
+#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
class Measure;
class SharedNumberFormat;
class SharedPluralRules;
class QuantityFormatter;
-class SimplePatternFormatter;
+class SimpleFormatter;
class ListFormatter;
class DateFormat;
+class FieldPositionHandler;
/**
*
UErrorCode &status) const;
#ifndef U_HIDE_INTERNAL_API
+ /**
+ * Apple-specific for now.
+ * Like formatMeasures above, but with a
+ * FieldPositionIterator* instead of a FieldPosition&
+ *
+ * @param measures Array of measure objects.
+ * @param measureCount the number of measure objects.
+ * @param appendTo Formatted string appended here.
+ * @param posIter On return, can be used to iterate over positions
+ * of fields generated by this format call. Field
+ * values are defined in UAMeasureUnit.
+ * @param status The error.
+ * @return appendTo reference
+ *
+ * @internal.
+ */
+ UnicodeString &formatMeasures(
+ const Measure *measures,
+ int32_t measureCount,
+ UnicodeString &appendTo,
+ FieldPositionIterator* posIter,
+ UErrorCode &status) const;
+
/**
* Apple-specific for now
* @internal.
*/
UMeasureFormatWidth getWidth(void) const;
+
#endif /* U_HIDE_INTERNAL_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Formats a single measure per unit. An example of such a
* formatted string is 3.5 meters per second.
* @param status the error.
* @return appendTo reference
*
- * @draft ICU 55
+ * @stable ICU 55
*/
UnicodeString &formatMeasurePerUnit(
const Measure &measure,
FieldPosition &pos,
UErrorCode &status) const;
-#endif /* U_HIDE_DRAFT_API */
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Gets the display name of the specified {@link MeasureUnit} corresponding to the current
+ * locale and format width.
+ * @param unit The unit for which to get a display name.
+ * @param status the error.
+ * @return The display name in the locale and width specified in
+ * {@link MeasureFormat#getInstance}, or null if there is no display name available
+ * for the specified unit.
+ *
+ * @draft ICU 58
+ */
+ UnicodeString getUnitDisplayName(const MeasureUnit& unit, UErrorCode &status) const;
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Return a formatter for CurrencyAmount objects in the given
/**
* ICU use only.
* Let subclass change NumberFormat.
- * @internal.
+ * @internal Apple
*/
void adoptNumberFormat(NumberFormat *nfToAdopt, UErrorCode &status);
+ /**
+ * Gets the display name for a unit.
+ * @param unit The unit whose display name to get.
+ * @param result Receives the name result, if any (if none,
+ * length will be 0)
+ * @return Reference to result
+ *
+ * @internal Apple
+ */
+ UnicodeString &getUnitName(
+ const MeasureUnit* unit,
+ UnicodeString &result ) const;
+
+ /**
+ * Gets the display name for a set of units.
+ * @param units Array of units whose display name to get.
+ * @param unitCount The count of units
+ * @param listStyle The list style used for combining the unit names.
+ * @param result Receives the name result, if any (if none,
+ * length will be 0)
+ * @return Reference to result
+ *
+ * @internal Apple
+ */
+ UnicodeString &getMultipleUnitNames(
+ const MeasureUnit** units,
+ int32_t unitCount,
+ UAMeasureNameListStyle listStyle,
+ UnicodeString &result ) const;
+
protected:
/**
* ICU use only.
const SharedNumberFormat *numberFormat;
const SharedPluralRules *pluralRules;
UMeasureFormatWidth width;
+ UBool stripPatternSpaces;
// Declared outside of MeasureFormatSharedData because ListFormatter
// objects are relatively cheap to copy; therefore, they don't need to be
// shared across instances.
ListFormatter *listFormatter;
+ ListFormatter *listFormatterStd; // standard list style, option for display names; Apple specific
- const QuantityFormatter *getQuantityFormatter(
- int32_t index,
- int32_t widthIndex,
- UErrorCode &status) const;
+ const SimpleFormatter *getFormatterOrNull(
+ const MeasureUnit &unit, UMeasureFormatWidth width, int32_t index) const;
- const SimplePatternFormatter *getPerUnitFormatter(
- int32_t index,
- int32_t widthIndex) const;
+ const SimpleFormatter *getFormatter(
+ const MeasureUnit &unit, UMeasureFormatWidth width, int32_t index,
+ UErrorCode &errorCode) const;
- const SimplePatternFormatter *getPerFormatter(
- int32_t widthIndex,
+ const SimpleFormatter *getPluralFormatter(
+ const MeasureUnit &unit, UMeasureFormatWidth width, int32_t index,
+ UErrorCode &errorCode) const;
+
+ const SimpleFormatter *getPerFormatter(
+ UMeasureFormatWidth width,
UErrorCode &status) const;
int32_t withPerUnitAndAppend(
// minute; [2] is second.
int32_t bitMap, // 1=hour set, 2=minute set, 4=second set
UnicodeString &appendTo,
+ FieldPositionHandler& handler,
UErrorCode &status) const;
UnicodeString &formatNumeric(
UDateFormatField smallestField,
const Formattable &smallestAmount,
UnicodeString &appendTo,
+ FieldPositionHandler& handler,
UErrorCode &status) const;
};
U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
#endif // #if !UCONFIG_NO_FORMATTING
#endif // #ifndef MEASUREFORMAT_H