ICU-2370 fix format() docs regarding appending to result string; also misc other doc and parameter name fixes
X-SVN-Rev: 10364
This commit is contained in:
parent
97a528130e
commit
9d30c08f22
@ -570,10 +570,10 @@ ChoiceFormat::getFormats(int32_t& cnt) const
|
||||
|
||||
UnicodeString&
|
||||
ChoiceFormat::format(int32_t number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& status) const
|
||||
{
|
||||
return format((double) number, toAppendTo, status);
|
||||
return format((double) number, appendTo, status);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
@ -581,7 +581,7 @@ ChoiceFormat::format(int32_t number,
|
||||
|
||||
UnicodeString&
|
||||
ChoiceFormat::format(double number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& /*pos*/) const
|
||||
{
|
||||
// find the number
|
||||
@ -602,8 +602,8 @@ ChoiceFormat::format(double number,
|
||||
i = 0;
|
||||
}
|
||||
// return either a formatted number, or a string
|
||||
toAppendTo += fChoiceFormats[i];
|
||||
return toAppendTo;
|
||||
appendTo += fChoiceFormats[i];
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
@ -613,13 +613,13 @@ ChoiceFormat::format(double number,
|
||||
UnicodeString&
|
||||
ChoiceFormat::format(const Formattable* objs,
|
||||
int32_t cnt,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
if(cnt < 0) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return toAppendTo;
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
UnicodeString buffer;
|
||||
@ -627,10 +627,10 @@ ChoiceFormat::format(const Formattable* objs,
|
||||
double objDouble = (objs[i].getType() == Formattable::kLong) ?
|
||||
((double) objs[i].getLong()) : objs[i].getDouble();
|
||||
buffer.remove();
|
||||
toAppendTo += format(objDouble, buffer, pos);
|
||||
appendTo += format(objDouble, buffer, pos);
|
||||
}
|
||||
|
||||
return toAppendTo;
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
@ -639,11 +639,11 @@ ChoiceFormat::format(const Formattable* objs,
|
||||
|
||||
UnicodeString&
|
||||
ChoiceFormat::format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
return NumberFormat::format(obj, toAppendTo, pos, status);
|
||||
return NumberFormat::format(obj, appendTo, pos, status);
|
||||
}
|
||||
// -------------------------------------
|
||||
|
||||
|
@ -522,7 +522,7 @@ DecimalFormat::clone() const
|
||||
|
||||
UnicodeString&
|
||||
DecimalFormat::format(int32_t number,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition) const
|
||||
{
|
||||
DigitList digits;
|
||||
@ -556,14 +556,14 @@ DecimalFormat::format(int32_t number,
|
||||
getMinimumIntegerDigits() + getMaximumFractionDigits() : 0);
|
||||
}
|
||||
|
||||
return subformat(result, fieldPosition, digits, TRUE);
|
||||
return subformat(appendTo, fieldPosition, digits, TRUE);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
UnicodeString&
|
||||
DecimalFormat::format( double number,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition) const
|
||||
{
|
||||
// Clears field positions.
|
||||
@ -575,15 +575,15 @@ DecimalFormat::format( double number,
|
||||
if (uprv_isNaN(number))
|
||||
{
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
fieldPosition.setBeginIndex(result.length());
|
||||
fieldPosition.setBeginIndex(appendTo.length());
|
||||
|
||||
result += getConstSymbol(DecimalFormatSymbols::kNaNSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kNaNSymbol);
|
||||
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
fieldPosition.setEndIndex(result.length());
|
||||
fieldPosition.setEndIndex(appendTo.length());
|
||||
|
||||
addPadding(result, fieldPosition, FALSE, FALSE /*ignored*/);
|
||||
return result;
|
||||
addPadding(appendTo, fieldPosition, FALSE, FALSE /*ignored*/);
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
/* Detecting whether a double is negative is easy with the exception of
|
||||
@ -618,20 +618,20 @@ DecimalFormat::format( double number,
|
||||
// Special case for INFINITE,
|
||||
if (uprv_isInfinite(number))
|
||||
{
|
||||
result += (isNegative ? fNegativePrefix : fPositivePrefix);
|
||||
appendTo += (isNegative ? fNegativePrefix : fPositivePrefix);
|
||||
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
fieldPosition.setBeginIndex(result.length());
|
||||
fieldPosition.setBeginIndex(appendTo.length());
|
||||
|
||||
result += getConstSymbol(DecimalFormatSymbols::kInfinitySymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kInfinitySymbol);
|
||||
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
fieldPosition.setEndIndex(result.length());
|
||||
fieldPosition.setEndIndex(appendTo.length());
|
||||
|
||||
result += (isNegative ? fNegativeSuffix : fPositiveSuffix);
|
||||
appendTo += (isNegative ? fNegativeSuffix : fPositiveSuffix);
|
||||
|
||||
addPadding(result, fieldPosition, TRUE, isNegative);
|
||||
return result;
|
||||
addPadding(appendTo, fieldPosition, TRUE, isNegative);
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
DigitList digits;
|
||||
@ -642,7 +642,7 @@ DecimalFormat::format( double number,
|
||||
getMaximumFractionDigits(),
|
||||
!fUseExponentialNotation);
|
||||
|
||||
return subformat(result, fieldPosition, digits, FALSE);
|
||||
return subformat(appendTo, fieldPosition, digits, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -682,11 +682,11 @@ double DecimalFormat::round(double a, ERoundingMode mode, UBool isNegative) {
|
||||
|
||||
UnicodeString&
|
||||
DecimalFormat::format( const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
return NumberFormat::format(obj, result, fieldPosition, status);
|
||||
return NumberFormat::format(obj, appendTo, fieldPosition, status);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -718,7 +718,7 @@ UBool DecimalFormat::isGroupingPosition(int32_t pos) const {
|
||||
* be filled in with the correct digits.
|
||||
*/
|
||||
UnicodeString&
|
||||
DecimalFormat::subformat(UnicodeString& result,
|
||||
DecimalFormat::subformat(UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
DigitList& digits,
|
||||
UBool isInteger) const
|
||||
@ -748,14 +748,14 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
}
|
||||
|
||||
// Appends the prefix.
|
||||
result += (digits.fIsPositive ? fPositivePrefix : fNegativePrefix);
|
||||
appendTo += (digits.fIsPositive ? fPositivePrefix : fNegativePrefix);
|
||||
|
||||
if (fUseExponentialNotation)
|
||||
{
|
||||
// Record field information for caller.
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
{
|
||||
fieldPosition.setBeginIndex(result.length());
|
||||
fieldPosition.setBeginIndex(appendTo.length());
|
||||
fieldPosition.setEndIndex(-1);
|
||||
}
|
||||
else if (fieldPosition.getField() == NumberFormat::kFractionField)
|
||||
@ -810,39 +810,39 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
{
|
||||
// Record field information for caller.
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
fieldPosition.setEndIndex(result.length());
|
||||
fieldPosition.setEndIndex(appendTo.length());
|
||||
|
||||
result += *decimal;
|
||||
appendTo += *decimal;
|
||||
|
||||
// Record field information for caller.
|
||||
if (fieldPosition.getField() == NumberFormat::kFractionField)
|
||||
fieldPosition.setBeginIndex(result.length());
|
||||
fieldPosition.setBeginIndex(appendTo.length());
|
||||
}
|
||||
// Restores the digit character or pads the buffer with zeros.
|
||||
UChar32 c = (UChar32)((i < digits.fCount) ?
|
||||
(digits.fDigits[i] + zeroDelta) :
|
||||
zero);
|
||||
result += c;
|
||||
appendTo += c;
|
||||
}
|
||||
|
||||
// Record field information
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
{
|
||||
if (fieldPosition.getEndIndex() < 0)
|
||||
fieldPosition.setEndIndex(result.length());
|
||||
fieldPosition.setEndIndex(appendTo.length());
|
||||
}
|
||||
else if (fieldPosition.getField() == NumberFormat::kFractionField)
|
||||
{
|
||||
if (fieldPosition.getBeginIndex() < 0)
|
||||
fieldPosition.setBeginIndex(result.length());
|
||||
fieldPosition.setEndIndex(result.length());
|
||||
fieldPosition.setBeginIndex(appendTo.length());
|
||||
fieldPosition.setEndIndex(appendTo.length());
|
||||
}
|
||||
|
||||
// The exponent is output using the pattern-specified minimum
|
||||
// exponent digits. There is no maximum limit to the exponent
|
||||
// digits, since truncating the exponent would result in an
|
||||
// digits, since truncating the exponent would appendTo in an
|
||||
// unacceptable inaccuracy.
|
||||
result += getConstSymbol(DecimalFormatSymbols::kExponentialSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kExponentialSymbol);
|
||||
|
||||
// For zero values, we force the exponent to zero. We
|
||||
// must do this here, and not earlier, because the value
|
||||
@ -851,27 +851,27 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
exponent = 0;
|
||||
|
||||
if (exponent < 0) {
|
||||
result += getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol);
|
||||
} else if (fExponentSignAlwaysShown) {
|
||||
result += getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol);
|
||||
}
|
||||
|
||||
DigitList expDigits;
|
||||
expDigits.set(exponent);
|
||||
for (i=expDigits.fDecimalAt; i<fMinExponentDigits; ++i)
|
||||
result += (zero);
|
||||
appendTo += (zero);
|
||||
for (i=0; i<expDigits.fDecimalAt; ++i)
|
||||
{
|
||||
UChar32 c = (UChar32)((i < expDigits.fCount) ?
|
||||
(expDigits.fDigits[i] + zeroDelta) : zero);
|
||||
result += c;
|
||||
appendTo += c;
|
||||
}
|
||||
}
|
||||
else // Not using exponential notation
|
||||
{
|
||||
// Record field information for caller.
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
fieldPosition.setBeginIndex(result.length());
|
||||
fieldPosition.setBeginIndex(appendTo.length());
|
||||
|
||||
// Output the integer portion. Here 'count' is the total
|
||||
// number of integer digits we will display, including both
|
||||
@ -893,7 +893,7 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
digitIndex = digits.fDecimalAt - count;
|
||||
}
|
||||
|
||||
int32_t sizeBeforeIntegerPart = result.length();
|
||||
int32_t sizeBeforeIntegerPart = appendTo.length();
|
||||
|
||||
int32_t i;
|
||||
for (i=count-1; i>=0; --i)
|
||||
@ -901,23 +901,23 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
if (i < digits.fDecimalAt && digitIndex < digits.fCount)
|
||||
{
|
||||
// Output a real digit
|
||||
result += ((UChar32)(digits.fDigits[digitIndex++] + zeroDelta));
|
||||
appendTo += ((UChar32)(digits.fDigits[digitIndex++] + zeroDelta));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output a leading zero
|
||||
result += (zero);
|
||||
appendTo += (zero);
|
||||
}
|
||||
|
||||
// Output grouping separator if necessary.
|
||||
if (isGroupingPosition(i)) {
|
||||
result.append(*grouping);
|
||||
appendTo.append(*grouping);
|
||||
}
|
||||
}
|
||||
|
||||
// Record field information for caller.
|
||||
if (fieldPosition.getField() == NumberFormat::kIntegerField)
|
||||
fieldPosition.setEndIndex(result.length());
|
||||
fieldPosition.setEndIndex(appendTo.length());
|
||||
|
||||
// Determine whether or not there are any printable fractional
|
||||
// digits. If we've used up the digits we know there aren't.
|
||||
@ -927,16 +927,16 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
// If there is no fraction present, and we haven't printed any
|
||||
// integer digits, then print a zero. Otherwise we won't print
|
||||
// _any_ digits, and we won't be able to parse this string.
|
||||
if (!fractionPresent && result.length() == sizeBeforeIntegerPart)
|
||||
result += (zero);
|
||||
if (!fractionPresent && appendTo.length() == sizeBeforeIntegerPart)
|
||||
appendTo += (zero);
|
||||
|
||||
// Output the decimal separator if we always do so.
|
||||
if (fDecimalSeparatorAlwaysShown || fractionPresent)
|
||||
result += *decimal;
|
||||
appendTo += *decimal;
|
||||
|
||||
// Record field information for caller.
|
||||
if (fieldPosition.getField() == NumberFormat::kFractionField)
|
||||
fieldPosition.setBeginIndex(result.length());
|
||||
fieldPosition.setBeginIndex(appendTo.length());
|
||||
|
||||
int32_t maxFracDigits = getMaximumFractionDigits();
|
||||
int32_t negDecimalAt = -digits.fDecimalAt;
|
||||
@ -947,14 +947,14 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
if (i >= negDecimalAt)
|
||||
{
|
||||
// Output a digit
|
||||
result += ((UChar32)(digits.fDigits[digitIndex++] + zeroDelta));
|
||||
appendTo += ((UChar32)(digits.fDigits[digitIndex++] + zeroDelta));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output leading fractional zeros. These are zeros that come after
|
||||
// the decimal but before any significant digits. These are only
|
||||
// output if abs(number being formatted) < 1.0.
|
||||
result += zero;
|
||||
appendTo += zero;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -968,19 +968,19 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
break;
|
||||
|
||||
// No precision is left.
|
||||
result += zero;
|
||||
appendTo += zero;
|
||||
}
|
||||
}
|
||||
|
||||
// Record field information for caller.
|
||||
if (fieldPosition.getField() == NumberFormat::kFractionField)
|
||||
fieldPosition.setEndIndex(result.length());
|
||||
fieldPosition.setEndIndex(appendTo.length());
|
||||
}
|
||||
|
||||
result += (digits.fIsPositive ? fPositiveSuffix : fNegativeSuffix);
|
||||
appendTo += (digits.fIsPositive ? fPositiveSuffix : fNegativeSuffix);
|
||||
|
||||
addPadding(result, fieldPosition, TRUE, !digits.fIsPositive);
|
||||
return result;
|
||||
addPadding(appendTo, fieldPosition, TRUE, !digits.fIsPositive);
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -993,13 +993,13 @@ DecimalFormat::subformat(UnicodeString& result,
|
||||
* @param isNegative must be true if result contains a formatted negative
|
||||
* number, and false otherwise. Ignored if hasAffixes is false.
|
||||
*/
|
||||
void DecimalFormat::addPadding(UnicodeString& result,
|
||||
void DecimalFormat::addPadding(UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UBool hasAffixes,
|
||||
UBool isNegative) const
|
||||
{
|
||||
if (fFormatWidth > 0) {
|
||||
int32_t len = fFormatWidth - result.length();
|
||||
int32_t len = fFormatWidth - appendTo.length();
|
||||
if (len > 0) {
|
||||
UnicodeString padding;
|
||||
for (int32_t i=0; i<len; ++i) {
|
||||
@ -1008,24 +1008,24 @@ void DecimalFormat::addPadding(UnicodeString& result,
|
||||
switch (fPadPosition) {
|
||||
case kPadAfterPrefix:
|
||||
if (hasAffixes) {
|
||||
result.insert(isNegative ? fNegativePrefix.length()
|
||||
appendTo.insert(isNegative ? fNegativePrefix.length()
|
||||
: fPositivePrefix.length(),
|
||||
padding);
|
||||
break;
|
||||
} // else fall through to next case
|
||||
case kPadBeforePrefix:
|
||||
result.insert(0, padding);
|
||||
appendTo.insert(0, padding);
|
||||
break;
|
||||
case kPadBeforeSuffix:
|
||||
if (hasAffixes) {
|
||||
result.insert(result.length() -
|
||||
appendTo.insert(appendTo.length() -
|
||||
(isNegative ? fNegativeSuffix.length()
|
||||
: fPositiveSuffix.length()),
|
||||
padding);
|
||||
break;
|
||||
} // else fall through to next case
|
||||
case kPadAfterSuffix:
|
||||
result += padding;
|
||||
appendTo += padding;
|
||||
break;
|
||||
}
|
||||
fieldPosition.setBeginIndex(len + fieldPosition.getBeginIndex());
|
||||
@ -1949,7 +1949,8 @@ void DecimalFormat::expandAffixes(void) {
|
||||
* itself at the end of the pattern.
|
||||
*
|
||||
* @param pattern the non-null, fPossibly empty pattern
|
||||
* @param affix string to receive the expanded equivalent of pattern
|
||||
* @param affix string to receive the expanded equivalent of pattern.
|
||||
* Previous contents are deleted.
|
||||
*/
|
||||
void DecimalFormat::expandAffix(const UnicodeString& pattern,
|
||||
UnicodeString& affix) const {
|
||||
@ -2017,7 +2018,7 @@ void DecimalFormat::expandAffix(const UnicodeString& pattern,
|
||||
* appended string will generate the same affix pattern (or literal affix)
|
||||
* when passed to toPattern().
|
||||
*
|
||||
* @param buffer the affix string is appended to this
|
||||
* @param appendTo the affix string is appended to this
|
||||
* @param affixPattern a pattern such as fPosPrefixPattern; may be null
|
||||
* @param expAffix a corresponding expanded affix, such as fPositivePrefix.
|
||||
* Ignored unless affixPattern is null. If affixPattern is null, then
|
||||
@ -2025,12 +2026,12 @@ void DecimalFormat::expandAffix(const UnicodeString& pattern,
|
||||
* @param localized true if the appended pattern should contain localized
|
||||
* pattern characters; otherwise, non-localized pattern chars are appended
|
||||
*/
|
||||
void DecimalFormat::appendAffix(UnicodeString& buffer,
|
||||
void DecimalFormat::appendAffix(UnicodeString& appendTo,
|
||||
const UnicodeString* affixPattern,
|
||||
const UnicodeString& expAffix,
|
||||
UBool localized) const {
|
||||
if (affixPattern == 0) {
|
||||
appendAffix(buffer, expAffix, localized);
|
||||
appendAffix(appendTo, expAffix, localized);
|
||||
} else {
|
||||
int i;
|
||||
for (int pos=0; pos<affixPattern->length(); pos=i) {
|
||||
@ -2038,43 +2039,43 @@ void DecimalFormat::appendAffix(UnicodeString& buffer,
|
||||
if (i < 0) {
|
||||
UnicodeString s;
|
||||
affixPattern->extractBetween(pos, affixPattern->length(), s);
|
||||
appendAffix(buffer, s, localized);
|
||||
appendAffix(appendTo, s, localized);
|
||||
break;
|
||||
}
|
||||
if (i > pos) {
|
||||
UnicodeString s;
|
||||
affixPattern->extractBetween(pos, i, s);
|
||||
appendAffix(buffer, s, localized);
|
||||
appendAffix(appendTo, s, localized);
|
||||
}
|
||||
UChar32 c = affixPattern->char32At(++i);
|
||||
++i;
|
||||
if (c == kQuote) {
|
||||
buffer.append(c).append(c);
|
||||
appendTo.append(c).append(c);
|
||||
// Fall through and append another kQuote below
|
||||
} else if (c == kCurrencySign &&
|
||||
i<affixPattern->length() &&
|
||||
affixPattern->char32At(i) == kCurrencySign) {
|
||||
++i;
|
||||
buffer.append(c).append(c);
|
||||
appendTo.append(c).append(c);
|
||||
} else if (localized) {
|
||||
switch (c) {
|
||||
case kPatternPercent:
|
||||
buffer += getConstSymbol(DecimalFormatSymbols::kPercentSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kPercentSymbol);
|
||||
break;
|
||||
case kPatternPerMill:
|
||||
buffer += getConstSymbol(DecimalFormatSymbols::kPerMillSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kPerMillSymbol);
|
||||
break;
|
||||
case kPatternPlus:
|
||||
buffer += getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol);
|
||||
break;
|
||||
case kPatternMinus:
|
||||
buffer += getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol);
|
||||
appendTo += getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol);
|
||||
break;
|
||||
default:
|
||||
buffer.append(c);
|
||||
appendTo.append(c);
|
||||
}
|
||||
} else {
|
||||
buffer.append(c);
|
||||
appendTo.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2086,7 +2087,7 @@ void DecimalFormat::appendAffix(UnicodeString& buffer,
|
||||
* escaped in either case.
|
||||
*/
|
||||
void
|
||||
DecimalFormat::appendAffix( UnicodeString& buffer,
|
||||
DecimalFormat::appendAffix( UnicodeString& appendTo,
|
||||
const UnicodeString& affix,
|
||||
UBool localized) const {
|
||||
UBool needQuote;
|
||||
@ -2116,20 +2117,20 @@ DecimalFormat::appendAffix( UnicodeString& buffer,
|
||||
|| affix.indexOf(kCurrencySign) >= 0;
|
||||
}
|
||||
if (needQuote)
|
||||
buffer += (UChar)0x0027 /*'\''*/;
|
||||
appendTo += (UChar)0x0027 /*'\''*/;
|
||||
if (affix.indexOf((UChar)0x0027 /*'\''*/) < 0)
|
||||
buffer += affix;
|
||||
appendTo += affix;
|
||||
else {
|
||||
for (int32_t j = 0; j < affix.length(); ++j) {
|
||||
UChar32 c = affix.char32At(j);
|
||||
buffer += c;
|
||||
appendTo += c;
|
||||
if (c == 0x0027 /*'\''*/)
|
||||
buffer += c;
|
||||
appendTo += c;
|
||||
j = j + UTF_NEED_MULTIPLE_UCHAR(c);
|
||||
}
|
||||
}
|
||||
if (needQuote)
|
||||
buffer += (UChar)0x0027 /*'\''*/;
|
||||
appendTo += (UChar)0x0027 /*'\''*/;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -519,18 +519,17 @@ MessageFormat::applyPattern(const UnicodeString& newPattern,
|
||||
// -------------------------------------
|
||||
// Converts this MessageFormat instance to a pattern.
|
||||
UnicodeString&
|
||||
MessageFormat::toPattern(UnicodeString& result) const
|
||||
MessageFormat::toPattern(UnicodeString& appendTo) const
|
||||
{
|
||||
// later, make this more extensible
|
||||
int32_t lastOffset = 0;
|
||||
for (int i = 0; i <= fMaxOffset; ++i) {
|
||||
copyAndFixQuotes(fPattern, lastOffset, fOffsets[i], result);
|
||||
copyAndFixQuotes(fPattern, lastOffset, fOffsets[i], appendTo);
|
||||
lastOffset = fOffsets[i];
|
||||
result += LEFT_CURLY_BRACE;
|
||||
appendTo += LEFT_CURLY_BRACE;
|
||||
// {sfb} check this later
|
||||
//result += (UChar) (fArgumentNumbers[i] + '0');
|
||||
UnicodeString temp;
|
||||
result += itos(fArgumentNumbers[i], temp);
|
||||
//appendTo += (UChar) (fArgumentNumbers[i] + '0');
|
||||
itos(fArgumentNumbers[i], appendTo);
|
||||
if (fFormats[i] == NULL) {
|
||||
// do nothing, string format
|
||||
}
|
||||
@ -543,22 +542,22 @@ MessageFormat::toPattern(UnicodeString& result) const
|
||||
NumberFormat *percentTemplate = NumberFormat::createPercentInstance(fLocale, status);
|
||||
NumberFormat *integerTemplate = createIntegerFormat(fLocale, status);
|
||||
|
||||
result += COMMA;
|
||||
result += g_umsg_number;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_number;
|
||||
if (formatAlias != *numberTemplate) {
|
||||
result += COMMA;
|
||||
appendTo += COMMA;
|
||||
if (formatAlias == *currencyTemplate) {
|
||||
result += g_umsg_currency;
|
||||
appendTo += g_umsg_currency;
|
||||
}
|
||||
else if (formatAlias == *percentTemplate) {
|
||||
result += g_umsg_percent;
|
||||
appendTo += g_umsg_percent;
|
||||
}
|
||||
else if (formatAlias == *integerTemplate) {
|
||||
result += g_umsg_integer;
|
||||
appendTo += g_umsg_integer;
|
||||
}
|
||||
else {
|
||||
UnicodeString buffer;
|
||||
result += ((DecimalFormat*)fFormats[i])->toPattern(buffer);
|
||||
appendTo += ((DecimalFormat*)fFormats[i])->toPattern(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,58 +578,58 @@ MessageFormat::toPattern(UnicodeString& result) const
|
||||
DateFormat *fullTimeTemplate = DateFormat::createTimeInstance(DateFormat::kFull, fLocale);
|
||||
|
||||
|
||||
result += COMMA;
|
||||
appendTo += COMMA;
|
||||
if (formatAlias == *defaultDateTemplate) {
|
||||
result += g_umsg_date;
|
||||
appendTo += g_umsg_date;
|
||||
}
|
||||
else if (formatAlias == *shortDateTemplate) {
|
||||
result += g_umsg_date;
|
||||
result += COMMA;
|
||||
result += g_umsg_short;
|
||||
appendTo += g_umsg_date;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_short;
|
||||
}
|
||||
else if (formatAlias == *defaultDateTemplate) {
|
||||
result += g_umsg_date;
|
||||
result += COMMA;
|
||||
result += g_umsg_medium;
|
||||
appendTo += g_umsg_date;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_medium;
|
||||
}
|
||||
else if (formatAlias == *longDateTemplate) {
|
||||
result += g_umsg_date;
|
||||
result += COMMA;
|
||||
result += g_umsg_long;
|
||||
appendTo += g_umsg_date;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_long;
|
||||
}
|
||||
else if (formatAlias == *fullDateTemplate) {
|
||||
result += g_umsg_date;
|
||||
result += COMMA;
|
||||
result += g_umsg_full;
|
||||
appendTo += g_umsg_date;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_full;
|
||||
}
|
||||
else if (formatAlias == *defaultTimeTemplate) {
|
||||
result += g_umsg_time;
|
||||
appendTo += g_umsg_time;
|
||||
}
|
||||
else if (formatAlias == *shortTimeTemplate) {
|
||||
result += g_umsg_time;
|
||||
result += COMMA;
|
||||
result += g_umsg_short;
|
||||
appendTo += g_umsg_time;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_short;
|
||||
}
|
||||
else if (formatAlias == *defaultTimeTemplate) {
|
||||
result += g_umsg_time;
|
||||
result += COMMA;
|
||||
result += g_umsg_medium;
|
||||
appendTo += g_umsg_time;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_medium;
|
||||
}
|
||||
else if (formatAlias == *longTimeTemplate) {
|
||||
result += g_umsg_time;
|
||||
result += COMMA;
|
||||
result += g_umsg_long;
|
||||
appendTo += g_umsg_time;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_long;
|
||||
}
|
||||
else if (formatAlias == *fullTimeTemplate) {
|
||||
result += g_umsg_time;
|
||||
result += COMMA;
|
||||
result += g_umsg_full;
|
||||
appendTo += g_umsg_time;
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_full;
|
||||
}
|
||||
else {
|
||||
UnicodeString buffer;
|
||||
result += g_umsg_date;
|
||||
result += COMMA;
|
||||
result += ((SimpleDateFormat*)fFormats[i])->toPattern(buffer);
|
||||
appendTo += g_umsg_date;
|
||||
appendTo += COMMA;
|
||||
appendTo += ((SimpleDateFormat*)fFormats[i])->toPattern(buffer);
|
||||
}
|
||||
|
||||
delete defaultDateTemplate;
|
||||
@ -645,18 +644,18 @@ MessageFormat::toPattern(UnicodeString& result) const
|
||||
}
|
||||
else if (fFormats[i]->getDynamicClassID() == ChoiceFormat::getStaticClassID()) {
|
||||
UnicodeString buffer;
|
||||
result += COMMA;
|
||||
result += g_umsg_choice;
|
||||
result += COMMA;
|
||||
result += ((ChoiceFormat*)fFormats[i])->toPattern(buffer);
|
||||
appendTo += COMMA;
|
||||
appendTo += g_umsg_choice;
|
||||
appendTo += COMMA;
|
||||
appendTo += ((ChoiceFormat*)fFormats[i])->toPattern(buffer);
|
||||
}
|
||||
else {
|
||||
//result += ", unknown";
|
||||
//appendTo += ", unknown";
|
||||
}
|
||||
result += RIGHT_CURLY_BRACE;
|
||||
appendTo += RIGHT_CURLY_BRACE;
|
||||
}
|
||||
copyAndFixQuotes(fPattern, lastOffset, fPattern.length(), result);
|
||||
return result;
|
||||
copyAndFixQuotes(fPattern, lastOffset, fPattern.length(), appendTo);
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
@ -761,26 +760,26 @@ MessageFormat::getFormats(int32_t& cnt) const
|
||||
UnicodeString&
|
||||
MessageFormat::format(const Formattable* source,
|
||||
int32_t cnt,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& ignore,
|
||||
UErrorCode& success) const
|
||||
{
|
||||
if (U_FAILURE(success))
|
||||
return result;
|
||||
return appendTo;
|
||||
|
||||
return format(source, cnt, result, ignore, 0, success);
|
||||
return format(source, cnt, appendTo, ignore, 0, success);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Internally creates a MessageFormat instance based on the
|
||||
// pattern and formats the arguments Formattable array and
|
||||
// copy into the result buffer.
|
||||
// copy into the appendTo buffer.
|
||||
|
||||
UnicodeString&
|
||||
MessageFormat::format( const UnicodeString& pattern,
|
||||
const Formattable* arguments,
|
||||
int32_t cnt,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& success)
|
||||
{
|
||||
// {sfb} why does this use a local when so many other places use a static?
|
||||
@ -788,71 +787,70 @@ MessageFormat::format( const UnicodeString& pattern,
|
||||
/* test for NULL */
|
||||
if (temp == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
if (U_FAILURE(success))
|
||||
return result;
|
||||
return appendTo;
|
||||
FieldPosition ignore(0);
|
||||
temp->format(arguments, cnt, result, ignore, success);
|
||||
temp->format(arguments, cnt, appendTo, ignore, success);
|
||||
delete temp;
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Formats the source Formattable object and copy into the
|
||||
// result buffer. The Formattable object must be an array
|
||||
// appendTo buffer. The Formattable object must be an array
|
||||
// of Formattable instances, returns error otherwise.
|
||||
|
||||
UnicodeString&
|
||||
MessageFormat::format(const Formattable& source,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& ignore,
|
||||
UErrorCode& success) const
|
||||
{
|
||||
int32_t cnt;
|
||||
|
||||
if (U_FAILURE(success))
|
||||
return result;
|
||||
return appendTo;
|
||||
if (source.getType() != Formattable::kArray) {
|
||||
success = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
const Formattable* tmpPtr = source.getArray(cnt);
|
||||
|
||||
return format(tmpPtr, cnt, result, ignore, 0, success);
|
||||
return format(tmpPtr, cnt, appendTo, ignore, 0, success);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Formats the arguments Formattable array and copy into the result buffer.
|
||||
// Formats the arguments Formattable array and copy into the appendTo buffer.
|
||||
// Ignore the FieldPosition result for error checking.
|
||||
|
||||
UnicodeString&
|
||||
MessageFormat::format(const Formattable* arguments,
|
||||
int32_t cnt,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& status,
|
||||
int32_t recursionProtection,
|
||||
UErrorCode& success) const
|
||||
{
|
||||
if(/*arguments == NULL ||*/ cnt < 0) {
|
||||
success = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
int32_t lastOffset = 0;
|
||||
for (int32_t i = 0; i <= fMaxOffset;++i) {
|
||||
// Append the prefix of current format element.
|
||||
result.append(fPattern, lastOffset, fOffsets[i] - lastOffset);
|
||||
appendTo.append(fPattern, lastOffset, fOffsets[i] - lastOffset);
|
||||
lastOffset = fOffsets[i];
|
||||
int32_t argumentNumber = fArgumentNumbers[i];
|
||||
// Checks the scope of the argument number.
|
||||
if (argumentNumber >= cnt) {
|
||||
/*success = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return result;*/
|
||||
result += LEFT_CURLY_BRACE;
|
||||
UnicodeString temp;
|
||||
result += itos(argumentNumber, temp);
|
||||
result += RIGHT_CURLY_BRACE;
|
||||
return appendTo;*/
|
||||
appendTo += LEFT_CURLY_BRACE;
|
||||
itos(argumentNumber, appendTo);
|
||||
appendTo += RIGHT_CURLY_BRACE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -871,13 +869,13 @@ MessageFormat::format(const Formattable* arguments,
|
||||
arg.indexOf(LEFT_CURLY_BRACE) >= 0
|
||||
) {
|
||||
MessageFormat temp(arg, fLocale, success);
|
||||
temp.format(arguments, cnt, result, status, recursionProtection, success);
|
||||
temp.format(arguments, cnt, appendTo, status, recursionProtection, success);
|
||||
if (U_FAILURE(success)) {
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result += arg;
|
||||
appendTo += arg;
|
||||
}
|
||||
}
|
||||
// If the obj data type is a number, use a NumberFormat instance.
|
||||
@ -886,41 +884,41 @@ MessageFormat::format(const Formattable* arguments,
|
||||
numTemplate = NumberFormat::createInstance(fLocale, success);
|
||||
if (numTemplate == NULL || U_FAILURE(success)) {
|
||||
delete numTemplate;
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
if (type == Formattable::kDouble) {
|
||||
numTemplate->format(obj->getDouble(), result);
|
||||
numTemplate->format(obj->getDouble(), appendTo);
|
||||
} else {
|
||||
numTemplate->format(obj->getLong(), result);
|
||||
numTemplate->format(obj->getLong(), appendTo);
|
||||
}
|
||||
delete numTemplate;
|
||||
if (U_FAILURE(success))
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
// If the obj data type is a Date instance, use a DateFormat instance.
|
||||
else if (type == Formattable::kDate) {
|
||||
DateFormat *dateTemplate = NULL;
|
||||
dateTemplate = DateFormat::createDateTimeInstance(DateFormat::kShort, DateFormat::kShort, fLocale);
|
||||
if (dateTemplate == NULL) {
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
dateTemplate->format(obj->getDate(), result);
|
||||
dateTemplate->format(obj->getDate(), appendTo);
|
||||
delete dateTemplate;
|
||||
}
|
||||
else if (type == Formattable::kString) {
|
||||
result += obj->getString();
|
||||
appendTo += obj->getString();
|
||||
}
|
||||
else {
|
||||
#ifdef LIUDEBUG
|
||||
cerr << "Unknown object of type:" << type << endl;
|
||||
#endif
|
||||
success = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return result;
|
||||
return appendTo;
|
||||
}
|
||||
}
|
||||
// Appends the rest of the pattern characters after the real last offset.
|
||||
result.append(fPattern, lastOffset, 0x7fffffff);
|
||||
return result;
|
||||
appendTo.append(fPattern, lastOffset, 0x7fffffff);
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
|
||||
@ -983,8 +981,7 @@ MessageFormat::parse(const UnicodeString& source,
|
||||
UnicodeString strValue = buffer;
|
||||
UnicodeString temp(LEFT_CURLY_BRACE);
|
||||
// {sfb} check this later
|
||||
UnicodeString temp1;
|
||||
temp += itos(fArgumentNumbers[i], temp1);
|
||||
itos(fArgumentNumbers[i], temp);
|
||||
temp += RIGHT_CURLY_BRACE;
|
||||
if (strValue != temp) {
|
||||
source.extract(sourceOffset,next - sourceOffset, buffer);
|
||||
@ -1164,7 +1161,7 @@ MessageFormat::stoi(const UnicodeString& string)
|
||||
*/
|
||||
UnicodeString&
|
||||
MessageFormat::itos(int32_t i,
|
||||
UnicodeString& string)
|
||||
UnicodeString& appendTo)
|
||||
{
|
||||
/*
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
@ -1184,8 +1181,8 @@ MessageFormat::itos(int32_t i,
|
||||
*/
|
||||
UChar temp[10] = { '\0' };
|
||||
uprv_itou(temp,i,16,0);
|
||||
string.append(temp);
|
||||
return string;
|
||||
appendTo.append(temp);
|
||||
return appendTo;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
@ -1375,36 +1372,36 @@ void
|
||||
MessageFormat::copyAndFixQuotes(const UnicodeString& source,
|
||||
int32_t start,
|
||||
int32_t end,
|
||||
UnicodeString& target)
|
||||
UnicodeString& appendTo)
|
||||
{
|
||||
UBool gotLB = FALSE;
|
||||
|
||||
for (int32_t i = start; i < end; ++i) {
|
||||
UChar ch = source[i];
|
||||
if (ch == LEFT_CURLY_BRACE) {
|
||||
target += SINGLE_QUOTE;
|
||||
target += LEFT_CURLY_BRACE;
|
||||
target += SINGLE_QUOTE;
|
||||
appendTo += SINGLE_QUOTE;
|
||||
appendTo += LEFT_CURLY_BRACE;
|
||||
appendTo += SINGLE_QUOTE;
|
||||
gotLB = TRUE;
|
||||
}
|
||||
else if (ch == RIGHT_CURLY_BRACE) {
|
||||
if(gotLB) {
|
||||
target += RIGHT_CURLY_BRACE;
|
||||
appendTo += RIGHT_CURLY_BRACE;
|
||||
gotLB = FALSE;
|
||||
}
|
||||
else {
|
||||
// orig code.
|
||||
target += SINGLE_QUOTE;
|
||||
target += RIGHT_CURLY_BRACE;
|
||||
target += SINGLE_QUOTE;
|
||||
appendTo += SINGLE_QUOTE;
|
||||
appendTo += RIGHT_CURLY_BRACE;
|
||||
appendTo += SINGLE_QUOTE;
|
||||
}
|
||||
}
|
||||
else if (ch == SINGLE_QUOTE) {
|
||||
target += SINGLE_QUOTE;
|
||||
target += SINGLE_QUOTE;
|
||||
appendTo += SINGLE_QUOTE;
|
||||
appendTo += SINGLE_QUOTE;
|
||||
}
|
||||
else {
|
||||
target += ch;
|
||||
appendTo += ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,22 +140,22 @@ NumberFormat::operator==(const Format& that) const
|
||||
|
||||
UnicodeString&
|
||||
NumberFormat::format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
if (U_FAILURE(status)) return toAppendTo;
|
||||
if (U_FAILURE(status)) return appendTo;
|
||||
|
||||
if (obj.getType() == Formattable::kDouble) {
|
||||
return format(obj.getDouble(), toAppendTo, pos);
|
||||
return format(obj.getDouble(), appendTo, pos);
|
||||
}
|
||||
else if (obj.getType() == Formattable::kLong) {
|
||||
return format(obj.getLong(), toAppendTo, pos);
|
||||
return format(obj.getLong(), appendTo, pos);
|
||||
}
|
||||
// can't try to format a non-numeric object
|
||||
else {
|
||||
status = U_INVALID_FORMAT_ERROR;
|
||||
return toAppendTo;
|
||||
return appendTo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,20 +175,20 @@ NumberFormat::parseObject(const UnicodeString& source,
|
||||
// Formats a double number and save the result in a string.
|
||||
|
||||
UnicodeString&
|
||||
NumberFormat::format(double number, UnicodeString& toAppendTo) const
|
||||
NumberFormat::format(double number, UnicodeString& appendTo) const
|
||||
{
|
||||
FieldPosition pos(0);
|
||||
return format(number, toAppendTo, pos);
|
||||
return format(number, appendTo, pos);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Formats a long number and save the result in a string.
|
||||
|
||||
UnicodeString&
|
||||
NumberFormat::format(int32_t number, UnicodeString& toAppendTo) const
|
||||
NumberFormat::format(int32_t number, UnicodeString& appendTo) const
|
||||
{
|
||||
FieldPosition pos(0);
|
||||
return format(number, toAppendTo, pos);
|
||||
return format(number, appendTo, pos);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
@ -361,6 +361,7 @@ public:
|
||||
* Gets the pattern.
|
||||
*
|
||||
* @param pattern Output param which will recieve the pattern
|
||||
* Previous contents are deleted.
|
||||
* @return A reference to 'pattern'
|
||||
* @stable
|
||||
*/
|
||||
@ -454,84 +455,85 @@ public:
|
||||
*/
|
||||
virtual const UnicodeString* getFormats(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Format a double or long number using this object's choices.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
*/
|
||||
/**
|
||||
* Format a double or long number using this object's choices.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(double number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
/**
|
||||
* Format a int_32t number using this object's choices.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
*/
|
||||
/**
|
||||
* Format a int_32t number using this object's choices.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(int32_t number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
/**
|
||||
* Format an array of objects using this object's choices.
|
||||
*
|
||||
* @param objs The array of objects to be formatted.
|
||||
* @param cnt The size of objs.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param success Output param set to success/failure code on
|
||||
* exit.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
*/
|
||||
/**
|
||||
* Format an array of objects using this object's choices.
|
||||
*
|
||||
* @param objs The array of objects to be formatted.
|
||||
* @param cnt The size of objs.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param success Output param set to success/failure code on
|
||||
* exit.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable* objs,
|
||||
int32_t cnt,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& success) const;
|
||||
/**
|
||||
* Format an object using this object's choices.
|
||||
*
|
||||
*
|
||||
* @param obj The object to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
*/
|
||||
/**
|
||||
* Format an object using this object's choices.
|
||||
*
|
||||
*
|
||||
* @param obj The object to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Redeclared NumberFormat method.
|
||||
*
|
||||
* @param obj The object to be formatted.
|
||||
* @param result Output param which will receive the formatted object.
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit.
|
||||
* @return A reference to 'result'.
|
||||
* @param obj The object to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
@ -540,12 +542,13 @@ public:
|
||||
* pure virtual format() methods with the default FieldPosition.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param output Output param with the formatted string.
|
||||
* @return A reference to 'output' param.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format( double number,
|
||||
UnicodeString& output) const;
|
||||
UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Redeclared NumberFormat method.
|
||||
@ -553,12 +556,13 @@ public:
|
||||
* pure virtual format() methods with the default FieldPosition.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param output Output param with the formatted string.
|
||||
* @return A reference to 'output' param.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format( int32_t number,
|
||||
UnicodeString& output) const;
|
||||
UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Return a long if possible (e.g. within range LONG_MAX,
|
||||
@ -766,23 +770,23 @@ inline double ChoiceFormat::previousDouble( double d )
|
||||
|
||||
inline UnicodeString&
|
||||
ChoiceFormat::format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const {
|
||||
// Don't use Format:: - use immediate base class only,
|
||||
// in case immediate base modifies behavior later.
|
||||
return NumberFormat::format(obj, result, status);
|
||||
return NumberFormat::format(obj, appendTo, status);
|
||||
}
|
||||
|
||||
inline UnicodeString&
|
||||
ChoiceFormat::format(double number,
|
||||
UnicodeString& output) const {
|
||||
return NumberFormat::format(number, output);
|
||||
UnicodeString& appendTo) const {
|
||||
return NumberFormat::format(number, appendTo);
|
||||
}
|
||||
|
||||
inline UnicodeString&
|
||||
ChoiceFormat::format(int32_t number,
|
||||
UnicodeString& output) const {
|
||||
return NumberFormat::format(number, output);
|
||||
UnicodeString& appendTo) const {
|
||||
return NumberFormat::format(number, appendTo);
|
||||
}
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
@ -339,48 +339,48 @@ public:
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
/**
|
||||
* Format a double or long number using base-10 representation.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
/**
|
||||
* Format a double or long number using base-10 representation.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(double number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
/**
|
||||
* Format a long number using base-10 representation.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
*/
|
||||
/**
|
||||
* Format a long number using base-10 representation.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(int32_t number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
/**
|
||||
* Format a Formattable using base-10 representation.
|
||||
*
|
||||
* @param obj The value to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Error code indicating success or failure.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
*/
|
||||
/**
|
||||
* Format a Formattable using base-10 representation.
|
||||
*
|
||||
* @param obj The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Error code indicating success or failure.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
@ -389,14 +389,14 @@ public:
|
||||
* Formats an object to produce a string.
|
||||
*
|
||||
* @param obj The object to format.
|
||||
* @param result Output parameter which will be filled in with the
|
||||
* formatted string.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param status Output parameter filled in with success or failure status.
|
||||
* @return Reference to 'result' parameter.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
@ -404,12 +404,13 @@ public:
|
||||
* Format a double number.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param output Output param with the formatted string.
|
||||
* @return A reference to 'output' param.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format(double number,
|
||||
UnicodeString& output) const;
|
||||
UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Redeclared NumberFormat method.
|
||||
@ -417,12 +418,13 @@ public:
|
||||
* pure virtual format() methods with the default FieldPosition.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param output Output param with the formatted string.
|
||||
* @return A reference to 'output' param.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format(int32_t number,
|
||||
UnicodeString& output) const;
|
||||
UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Parse the given string using this object's choices. The method
|
||||
@ -892,6 +894,7 @@ public:
|
||||
* of this Format object.
|
||||
*
|
||||
* @param result Output param which will receive the pattern.
|
||||
* Previous contents are deleted.
|
||||
* @return A reference to 'result'.
|
||||
* @see applyPattern
|
||||
* @stable
|
||||
@ -903,6 +906,7 @@ public:
|
||||
* state of this Format object.
|
||||
*
|
||||
* @param result Output param which will receive the localized pattern.
|
||||
* Previous contents are deleted.
|
||||
* @return A reference to 'result'.
|
||||
* @see applyPattern
|
||||
* @stable
|
||||
@ -1119,6 +1123,7 @@ private:
|
||||
* Does the real work of generating a pattern.
|
||||
*
|
||||
* @param result Output param which will receive the pattern.
|
||||
* Previous contents are deleted.
|
||||
* @param localized TRUE return localized pattern.
|
||||
* @return A reference to 'result'.
|
||||
*/
|
||||
@ -1141,14 +1146,15 @@ private:
|
||||
/**
|
||||
* Do the work of formatting a number, either a double or a long.
|
||||
*
|
||||
* @param result Output param which will receive the formatted string.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param fieldPosition On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param digits the digits to be formatted.
|
||||
* @param isInteger if TRUE format the digits as Integer.
|
||||
* @return A reference to 'result'.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
*/
|
||||
UnicodeString& subformat(UnicodeString& result,
|
||||
UnicodeString& subformat(UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
DigitList& digits,
|
||||
UBool isInteger) const;
|
||||
@ -1181,14 +1187,14 @@ private:
|
||||
inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
|
||||
|
||||
/**
|
||||
* Append an affix to the given StringBuffer, using quotes if
|
||||
* Append an affix to the given UnicodeString, using quotes if
|
||||
* there are special characters. Single quotes themselves must be
|
||||
* escaped in either case.
|
||||
*/
|
||||
void appendAffix(UnicodeString& buffer, const UnicodeString& affix,
|
||||
void appendAffix(UnicodeString& appendTo, const UnicodeString& affix,
|
||||
UBool localized) const;
|
||||
|
||||
void appendAffix(UnicodeString& buffer,
|
||||
void appendAffix(UnicodeString& appendTo,
|
||||
const UnicodeString* affixPattern,
|
||||
const UnicodeString& expAffix, UBool localized) const;
|
||||
|
||||
@ -1199,7 +1205,7 @@ private:
|
||||
|
||||
static double round(double a, ERoundingMode mode, UBool isNegative);
|
||||
|
||||
void addPadding(UnicodeString& result,
|
||||
void addPadding(UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UBool hasAffixes,
|
||||
UBool isNegative) const;
|
||||
@ -1281,25 +1287,25 @@ protected:
|
||||
|
||||
inline UnicodeString&
|
||||
DecimalFormat::format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const {
|
||||
// Don't use Format:: - use immediate base class only,
|
||||
// in case immediate base modifies behavior later.
|
||||
return NumberFormat::format(obj, result, status);
|
||||
return NumberFormat::format(obj, appendTo, status);
|
||||
}
|
||||
|
||||
inline UnicodeString&
|
||||
DecimalFormat::format(double number,
|
||||
UnicodeString& output) const {
|
||||
UnicodeString& appendTo) const {
|
||||
FieldPosition pos(0);
|
||||
return format(number, output, pos);
|
||||
return format(number, appendTo, pos);
|
||||
}
|
||||
|
||||
inline UnicodeString&
|
||||
DecimalFormat::format(int32_t number,
|
||||
UnicodeString& output) const {
|
||||
UnicodeString& appendTo) const {
|
||||
FieldPosition pos(0);
|
||||
return format(number, output, pos);
|
||||
return format(number, appendTo, pos);
|
||||
}
|
||||
|
||||
inline const UnicodeString &
|
||||
|
@ -123,14 +123,14 @@ public:
|
||||
* Formats an object to produce a string.
|
||||
*
|
||||
* @param obj The object to format.
|
||||
* @param result Output parameter which will be filled in with the
|
||||
* formatted string.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param status Output parameter filled in with success or failure status.
|
||||
* @return Reference to 'result' parameter.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
@ -140,17 +140,17 @@ public:
|
||||
* object type it doesn't handle (e.g., if a numeric Formattable is passed
|
||||
* to a DateFormat object) then it returns a failing UErrorCode.
|
||||
*
|
||||
* @param obj The object to format.
|
||||
* @param toAppendTo Where the text is to be appended.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return The value passed in as toAppendTo (this allows chaining,
|
||||
* as with UnicodeString::append())
|
||||
* @param obj The object to format.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const = 0;
|
||||
|
||||
|
@ -311,11 +311,12 @@ public:
|
||||
|
||||
/**
|
||||
* Gets the pattern. See the class description.
|
||||
* @param result Output param which will receive the pattern.
|
||||
* @return A reference to 'result'.
|
||||
* @param appendTo Output parameter to receive the pattern.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& toPattern(UnicodeString& result) const;
|
||||
virtual UnicodeString& toPattern(UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Sets formats to use on parameters.
|
||||
@ -383,14 +384,16 @@ public:
|
||||
*
|
||||
* @param source An array of objects to be formatted & substituted.
|
||||
* @param count the size of the array.
|
||||
* @param result Where text is appended.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param ignore No useful status is returned.
|
||||
* @param success Output param set to success/failure code
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format( const Formattable* source,
|
||||
int32_t count,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& ignore,
|
||||
UErrorCode& success) const;
|
||||
|
||||
@ -400,14 +403,16 @@ public:
|
||||
* @param pattern the pattern.
|
||||
* @param source An array of objects to be formatted & substituted.
|
||||
* @param count the size of the array.
|
||||
* @param result Where text is appended.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param success Output param set to success/failure code
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
static UnicodeString& format( const UnicodeString& pattern,
|
||||
const Formattable* arguments,
|
||||
int32_t count,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& success);
|
||||
|
||||
/**
|
||||
@ -416,30 +421,31 @@ public:
|
||||
* object type is not of type kArray, then it returns a failing
|
||||
* UErrorCode.
|
||||
*
|
||||
* @param obj The object to format
|
||||
* @param toAppendTo Where the text is to be appended
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return The value passed in as toAppendTo (this allows chaining,
|
||||
* as with UnicodeString::append())
|
||||
* @param obj The object to format
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Redeclared Format method.
|
||||
* @param obj The object to format
|
||||
* @param result Output param which will receive the formatted string
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return A reference to 'result'.
|
||||
* @param obj The object to format
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
@ -596,19 +602,24 @@ private:
|
||||
const UChar * const *list);
|
||||
|
||||
/**
|
||||
* Formats the array of arguments and copies the result into the result buffer,
|
||||
* updates the field position.
|
||||
* @param arguments the formattable objects array.
|
||||
* @param cnt the array count.
|
||||
* @param status field position status.
|
||||
* @param recursionProtection Initially zero. Bits 0..9 are used to indicate
|
||||
* that a parameter has already been seen, to avoid recursion. Currently
|
||||
* unused.
|
||||
* @param success the error code status.
|
||||
* Formats the array of arguments and copies the result into the
|
||||
* result buffer, updates the field position.
|
||||
*
|
||||
* @param arguments The formattable objects array.
|
||||
* @param cnt The array count.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param status Field position status.
|
||||
* @param recursionProtection
|
||||
* Initially zero. Bits 0..9 are used to indicate
|
||||
* that a parameter has already been seen, to
|
||||
* avoid recursion. Currently unused.
|
||||
* @param success The error code status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
*/
|
||||
UnicodeString& format( const Formattable* arguments,
|
||||
int32_t cnt,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& status,
|
||||
int32_t recursionProtection,
|
||||
UErrorCode& success) const;
|
||||
@ -638,9 +649,10 @@ private:
|
||||
* @param source
|
||||
* @param start the text offset to start the process of in the source string
|
||||
* @param end the text offset to end the process of in the source string
|
||||
* @param target the result buffer
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
*/
|
||||
static void copyAndFixQuotes(const UnicodeString& source, int32_t start, int32_t end, UnicodeString& target);
|
||||
static void copyAndFixQuotes(const UnicodeString& appendTo, int32_t start, int32_t end, UnicodeString& target);
|
||||
|
||||
/**
|
||||
* Converts a string to an integer value using a default NumberFormat object
|
||||
@ -655,11 +667,12 @@ private:
|
||||
* Converts an integer value to a string using a default NumberFormat object
|
||||
* which is static (shared by all MessageFormat instances). This replaces
|
||||
* a call to wtoi().
|
||||
* @param i the integer to format
|
||||
* @param string the destination string
|
||||
* @return a reference to string.
|
||||
* @param i The integer to format
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
*/
|
||||
static UnicodeString& itos(int32_t i, UnicodeString& string);
|
||||
static UnicodeString& itos(int32_t i, UnicodeString& appendTo);
|
||||
};
|
||||
|
||||
inline UClassID
|
||||
@ -670,9 +683,9 @@ MessageFormat::getDynamicClassID() const
|
||||
|
||||
inline UnicodeString&
|
||||
MessageFormat::format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const {
|
||||
return Format::format(obj, result, status);
|
||||
return Format::format(obj, appendTo, status);
|
||||
}
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
@ -170,17 +170,17 @@ public:
|
||||
* object type is not a numeric type, then it returns a failing
|
||||
* UErrorCode.
|
||||
*
|
||||
* @param obj The object to format.
|
||||
* @param toAppendTo Where the text is to be appended.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return The value passed in as toAppendTo (this allows chaining,
|
||||
* as with UnicodeString::append())
|
||||
* @param obj The object to format.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
@ -221,65 +221,68 @@ public:
|
||||
* pure virtual format() methods with the default FieldPosition.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param output Output param with the formatted string.
|
||||
* @return A reference to 'output' param.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format( double number,
|
||||
UnicodeString& output) const;
|
||||
UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Format a long number. These methods call the NumberFormat
|
||||
* pure virtual format() methods with the default FieldPosition.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param output Output param with the formatted string.
|
||||
* @return A reference to 'output' param.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format( int32_t number,
|
||||
UnicodeString& output) const;
|
||||
UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Format a double number. Concrete subclasses must implement
|
||||
* these pure virtual methods.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
*/
|
||||
/**
|
||||
* Format a double number. Concrete subclasses must implement
|
||||
* these pure virtual methods.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(double number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const = 0;
|
||||
/**
|
||||
* Format a long number. Concrete subclasses must implement
|
||||
* these pure virtual methods.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param toAppendTo The string to append the formatted string to.
|
||||
* This is an output parameter.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return A reference to 'toAppendTo'.
|
||||
* @stable
|
||||
/**
|
||||
* Format a long number. Concrete subclasses must implement
|
||||
* these pure virtual methods.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
virtual UnicodeString& format(int32_t number,
|
||||
UnicodeString& toAppendTo,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const = 0;
|
||||
|
||||
/**
|
||||
* Redeclared Format method.
|
||||
* @param obj the object to be formatted.
|
||||
* @param result Output param with the formatted string.
|
||||
* @return A reference to 'result'.
|
||||
* @param obj The object to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable
|
||||
*/
|
||||
UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
@ -620,9 +623,9 @@ NumberFormat::isParseIntegerOnly() const
|
||||
|
||||
inline UnicodeString&
|
||||
NumberFormat::format(const Formattable& obj,
|
||||
UnicodeString& result,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const {
|
||||
return Format::format(obj, result, status);
|
||||
return Format::format(obj, appendTo, status);
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
Loading…
Reference in New Issue
Block a user