Logo Search packages:      
Sourcecode: icu version File versions

U_STABLE int32_t U_EXPORT2 unum_getAttribute ( const UNumberFormat fmt,
UNumberFormatAttribute  attr 
)

Get a numeric attribute associated with a UNumberFormat. An example of a numeric attribute is the number of integer digits a formatter will produce.

Parameters:
fmtThe formatter to query.
attrThe attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED, UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS, UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER, UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE.
Returns:
The value of attr.
See also:
unum_setAttribute
unum_getDoubleAttribute
unum_setDoubleAttribute
unum_getTextAttribute
unum_setTextAttribute ICU 2.0

Definition at line 449 of file unum.cpp.

References DecimalFormat::areSignificantDigitsUsed(), DecimalFormat::getFormatWidth(), DecimalFormat::getGroupingSize(), NumberFormat::getMaximumFractionDigits(), NumberFormat::getMaximumIntegerDigits(), DecimalFormat::getMaximumSignificantDigits(), NumberFormat::getMinimumFractionDigits(), NumberFormat::getMinimumIntegerDigits(), DecimalFormat::getMinimumSignificantDigits(), DecimalFormat::getMultiplier(), DecimalFormat::getPadPosition(), DecimalFormat::getRoundingMode(), DecimalFormat::getSecondaryGroupingSize(), DecimalFormat::isDecimalSeparatorAlwaysShown(), NumberFormat::isGroupingUsed(), NumberFormat::isLenient(), NumberFormat::isParseIntegerOnly(), NULL, UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_FORMAT_WIDTH, UNUM_FRACTION_DIGITS, UNUM_GROUPING_SIZE, UNUM_GROUPING_USED, UNUM_INTEGER_DIGITS, UNUM_LENIENT_PARSE, UNUM_MAX_FRACTION_DIGITS, UNUM_MAX_INTEGER_DIGITS, UNUM_MAX_SIGNIFICANT_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_MIN_SIGNIFICANT_DIGITS, UNUM_MULTIPLIER, UNUM_PADDING_POSITION, UNUM_PARSE_INT_ONLY, UNUM_ROUNDING_MODE, UNUM_SECONDARY_GROUPING_SIZE, and UNUM_SIGNIFICANT_DIGITS_USED.

{
  const NumberFormat* nf = reinterpret_cast<const NumberFormat*>(fmt);
  if ( attr == UNUM_LENIENT_PARSE ) {
    // Supported for all subclasses
    return nf->isLenient();
  }
  // The remaining attributea are only supported for DecimalFormat
  const DecimalFormat* df = dynamic_cast<const DecimalFormat*>(nf);
  if (df != NULL) {
    switch(attr) {
    case UNUM_PARSE_INT_ONLY:
        return df->isParseIntegerOnly();
        
    case UNUM_GROUPING_USED:
        return df->isGroupingUsed();
        
    case UNUM_DECIMAL_ALWAYS_SHOWN:
        return df->isDecimalSeparatorAlwaysShown();    
        
    case UNUM_MAX_INTEGER_DIGITS:
        return df->getMaximumIntegerDigits();
        
    case UNUM_MIN_INTEGER_DIGITS:
        return df->getMinimumIntegerDigits();
        
    case UNUM_INTEGER_DIGITS:
        // TBD: what should this return?
        return df->getMinimumIntegerDigits();
        
    case UNUM_MAX_FRACTION_DIGITS:
        return df->getMaximumFractionDigits();
        
    case UNUM_MIN_FRACTION_DIGITS:
        return df->getMinimumFractionDigits();
        
    case UNUM_FRACTION_DIGITS:
        // TBD: what should this return?
        return df->getMinimumFractionDigits();
        
    case UNUM_SIGNIFICANT_DIGITS_USED:
        return df->areSignificantDigitsUsed();
        
    case UNUM_MAX_SIGNIFICANT_DIGITS:
        return df->getMaximumSignificantDigits();
        
    case UNUM_MIN_SIGNIFICANT_DIGITS:
        return df->getMinimumSignificantDigits();
        
    case UNUM_MULTIPLIER:
        return df->getMultiplier();    
        
    case UNUM_GROUPING_SIZE:
        return df->getGroupingSize();    
        
    case UNUM_ROUNDING_MODE:
        return df->getRoundingMode();
        
    case UNUM_FORMAT_WIDTH:
        return df->getFormatWidth();
        
    case UNUM_PADDING_POSITION:
        return df->getPadPosition();
        
    case UNUM_SECONDARY_GROUPING_SIZE:
        return df->getSecondaryGroupingSize();

    default:
        /* enums out of sync? unsupported enum? */
        break;
    }
  }

  return -1;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index