/*
********************************************************************************
-* Copyright (C) 1997-2011, International Business Machines Corporation and others.
+* Copyright (C) 1997-2012, International Business Machines Corporation and others.
* All Rights Reserved.
********************************************************************************
*
* support identification of all number format fields, not just those
* pertaining to alignment.
*
+ * These constants are provided for backwards compatibility only.
+ * Please use the C style constants defined in the header file unum.h.
+ *
* @see FieldPosition
* @stable ICU 2.0
*/
enum EAlignmentFields {
- kIntegerField,
- kFractionField,
- kDecimalSeparatorField,
- kExponentSymbolField,
- kExponentSignField,
- kExponentField,
- kGroupingSeparatorField,
- kCurrencyField,
- kPercentField,
- kPermillField,
- kSignField,
+ /** @stable ICU 2.0 */
+ kIntegerField = UNUM_INTEGER_FIELD,
+ /** @stable ICU 2.0 */
+ kFractionField = UNUM_FRACTION_FIELD,
+ /** @stable ICU 2.0 */
+ kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD,
+ /** @stable ICU 2.0 */
+ kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD,
+ /** @stable ICU 2.0 */
+ kExponentSignField = UNUM_EXPONENT_SIGN_FIELD,
+ /** @stable ICU 2.0 */
+ kExponentField = UNUM_EXPONENT_FIELD,
+ /** @stable ICU 2.0 */
+ kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD,
+ /** @stable ICU 2.0 */
+ kCurrencyField = UNUM_CURRENCY_FIELD,
+ /** @stable ICU 2.0 */
+ kPercentField = UNUM_PERCENT_FIELD,
+ /** @stable ICU 2.0 */
+ kPermillField = UNUM_PERMILL_FIELD,
+ /** @stable ICU 2.0 */
+ kSignField = UNUM_SIGN_FIELD,
/**
* These constants are provided for backwards compatibility only.
- * Please use the C++ style constants defined above.
- * @stable ICU 2.0
+ * Please use the constants defined in the header file unum.h.
*/
- INTEGER_FIELD = kIntegerField,
- FRACTION_FIELD = kFractionField
+ /** @stable ICU 2.0 */
+ INTEGER_FIELD = UNUM_INTEGER_FIELD,
+ /** @stable ICU 2.0 */
+ FRACTION_FIELD = UNUM_FRACTION_FIELD
};
/**
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2011, International Business Machines Corporation and
+ * Copyright (c) 1997-2012, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
log_verbose("\nTesting unum_format() \n");
resultlength=0;
- pos1.field = 0; /* Integer Section */
+ pos1.field = UNUM_INTEGER_FIELD;
resultlengthneeded=unum_format(cur_def, l, NULL, resultlength, &pos1, &status);
if(status==U_BUFFER_OVERFLOW_ERROR)
{
log_verbose("\nTesting unum_formatDouble()\n");
u_uastrcpy(temp1, "($10,456.37)");
resultlength=0;
- pos2.field = 1; /* Fractional Section */
+ pos2.field = UNUM_FRACTION_FIELD;
resultlengthneeded=unum_formatDouble(cur_def, d, NULL, resultlength, &pos2, &status);
if(status==U_BUFFER_OVERFLOW_ERROR)
{
temp1[0] = 0xA5; /* Yen sign */
u_uastrcpy(temp, "JPY");
resultlength=0;
- pos2.field = 0; /* integer part */
+ pos2.field = UNUM_INTEGER_FIELD;
resultlengthneeded=unum_formatDoubleCurrency(cur_def, a, temp, NULL, resultlength, &pos2, &status);
if (status==U_BUFFER_OVERFLOW_ERROR) {
status=U_ZERO_ERROR;
/* Format with a FieldPosition parameter */
- fieldPos.field = 2; /* Ticket 8034 - need enum constants for the field values. */
- /* 2 = kDecimalSeparatorField */
+ fieldPos.field = UNUM_DECIMAL_SEPARATOR_FIELD;
resultSize = unum_formatDecimal(fmt, numInitial, -1, dest, DESTCAPACITY, &fieldPos, &status);
if (U_FAILURE(status)) {
log_err("File %s, Line %d, status = %s\n", __FILE__, __LINE__, u_errorName(status));
/* u_uastrcpy(temp1, "(xxxxxxx10,456.37)"); */
u_uastrcpy(temp1, "xxxxx(10,456.37)");
resultlength=0;
- pos1.field = 1; /* Fraction field */
+ pos1.field = UNUM_FRACTION_FIELD;
resultlengthneeded=unum_formatDouble(pattern, d, NULL, resultlength, &pos1, &status);
if(status==U_BUFFER_OVERFLOW_ERROR)
{
{
int32_t expected[] = {
- NumberFormat::kCurrencyField, 0, 1,
- NumberFormat::kGroupingSeparatorField, 3, 4,
- NumberFormat::kIntegerField, 1, 7,
- NumberFormat::kDecimalSeparatorField, 7, 8,
- NumberFormat::kFractionField, 8, 10,
+ UNUM_CURRENCY_FIELD, 0, 1,
+ UNUM_GROUPING_SEPARATOR_FIELD, 3, 4,
+ UNUM_INTEGER_FIELD, 1, 7,
+ UNUM_DECIMAL_SEPARATOR_FIELD, 7, 8,
+ UNUM_FRACTION_FIELD, 8, 10,
};
int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected));
expectPositions(posIter, expected, tupleCount, result);
}
{
- FieldPosition fp(NumberFormat::kIntegerField);
+ FieldPosition fp(UNUM_INTEGER_FIELD);
UnicodeString result;
decFmt->format(val, result, fp);
- expectPosition(fp, NumberFormat::kIntegerField, 1, 7, result);
+ expectPosition(fp, UNUM_INTEGER_FIELD, 1, 7, result);
}
{
- FieldPosition fp(NumberFormat::kFractionField);
+ FieldPosition fp(UNUM_FRACTION_FIELD);
UnicodeString result;
decFmt->format(val, result, fp);
- expectPosition(fp, NumberFormat::kFractionField, 8, 10, result);
+ expectPosition(fp, UNUM_FRACTION_FIELD, 8, 10, result);
}
delete decFmt;
val = -0.0000123;
{
int32_t expected[] = {
- NumberFormat::kSignField, 0, 1,
- NumberFormat::kIntegerField, 1, 2,
- NumberFormat::kDecimalSeparatorField, 2, 3,
- NumberFormat::kFractionField, 3, 5,
- NumberFormat::kExponentSymbolField, 5, 6,
- NumberFormat::kExponentSignField, 6, 7,
- NumberFormat::kExponentField, 7, 8
+ UNUM_SIGN_FIELD, 0, 1,
+ UNUM_INTEGER_FIELD, 1, 2,
+ UNUM_DECIMAL_SEPARATOR_FIELD, 2, 3,
+ UNUM_FRACTION_FIELD, 3, 5,
+ UNUM_EXPONENT_SYMBOL_FIELD, 5, 6,
+ UNUM_EXPONENT_SIGN_FIELD, 6, 7,
+ UNUM_EXPONENT_FIELD, 7, 8
};
int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected));
expectPositions(posIter, expected, tupleCount, result);
}
{
- FieldPosition fp(NumberFormat::kIntegerField);
+ FieldPosition fp(UNUM_INTEGER_FIELD);
UnicodeString result;
decFmt->format(val, result, fp);
- expectPosition(fp, NumberFormat::kIntegerField, 1, 2, result);
+ expectPosition(fp, UNUM_INTEGER_FIELD, 1, 2, result);
}
{
- FieldPosition fp(NumberFormat::kFractionField);
+ FieldPosition fp(UNUM_FRACTION_FIELD);
UnicodeString result;
decFmt->format(val, result, fp);
- expectPosition(fp, NumberFormat::kFractionField, 3, 5, result);
+ expectPosition(fp, UNUM_FRACTION_FIELD, 3, 5, result);
}
delete decFmt;
const char* attrString(int32_t attrId) {
switch (attrId) {
- case NumberFormat::kIntegerField: return "integer";
- case NumberFormat::kFractionField: return "fraction";
- case NumberFormat::kDecimalSeparatorField: return "decimal separator";
- case NumberFormat::kExponentSymbolField: return "exponent symbol";
- case NumberFormat::kExponentSignField: return "exponent sign";
- case NumberFormat::kExponentField: return "exponent";
- case NumberFormat::kGroupingSeparatorField: return "grouping separator";
- case NumberFormat::kCurrencyField: return "currency";
- case NumberFormat::kPercentField: return "percent";
- case NumberFormat::kPermillField: return "permille";
- case NumberFormat::kSignField: return "sign";
+ case UNUM_INTEGER_FIELD: return "integer";
+ case UNUM_FRACTION_FIELD: return "fraction";
+ case UNUM_DECIMAL_SEPARATOR_FIELD: return "decimal separator";
+ case UNUM_EXPONENT_SYMBOL_FIELD: return "exponent symbol";
+ case UNUM_EXPONENT_SIGN_FIELD: return "exponent sign";
+ case UNUM_EXPONENT_FIELD: return "exponent";
+ case UNUM_GROUPING_SEPARATOR_FIELD: return "grouping separator";
+ case UNUM_CURRENCY_FIELD: return "currency";
+ case UNUM_PERCENT_FIELD: return "percent";
+ case UNUM_PERMILL_FIELD: return "permille";
+ case UNUM_SIGN_FIELD: return "sign";
default: return "";
}
}