diff options
author | Steven R. Loomis <srloomis@us.ibm.com> | 2016-04-08 19:03:16 -0700 |
---|---|---|
committer | Steven R. Loomis <srloomis@us.ibm.com> | 2016-05-04 16:02:45 -0700 |
commit | 2bbd1cd6004b3e1467e30d860385a85dad01fe24 (patch) | |
tree | b812046e89e46e0de09bc858e0b128787cbc0632 /deps/icu-small/source/i18n/digitaffixesandpadding.h | |
parent | cd752e8463fad7c4805951d9ba47cd2f39691f2d (diff) | |
download | android-node-v8-2bbd1cd6004b3e1467e30d860385a85dad01fe24.tar.gz android-node-v8-2bbd1cd6004b3e1467e30d860385a85dad01fe24.tar.bz2 android-node-v8-2bbd1cd6004b3e1467e30d860385a85dad01fe24.zip |
deps: Intl: Check in "small-icu" 57.1
* this commit has "small" ICU 57.1.
See other related commit for tools to generate this commit.
Fixes: https://github.com/nodejs/node/issues/3476
PR-URL: https://github.com/nodejs/node/pull/6088
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/icu-small/source/i18n/digitaffixesandpadding.h')
-rw-r--r-- | deps/icu-small/source/i18n/digitaffixesandpadding.h | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/deps/icu-small/source/i18n/digitaffixesandpadding.h b/deps/icu-small/source/i18n/digitaffixesandpadding.h new file mode 100644 index 0000000000..3586371094 --- /dev/null +++ b/deps/icu-small/source/i18n/digitaffixesandpadding.h @@ -0,0 +1,177 @@ +/* +******************************************************************************* +* Copyright (C) 2015, International Business Machines +* Corporation and others. All Rights Reserved. +******************************************************************************* +* digitaffixesandpadding.h +* +* created on: 2015jan06 +* created by: Travis Keep +*/ + +#ifndef __DIGITAFFIXESANDPADDING_H__ +#define __DIGITAFFIXESANDPADDING_H__ + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING + +#include "unicode/uobject.h" +#include "pluralaffix.h" + +U_NAMESPACE_BEGIN + +class DigitList; +class ValueFormatter; +class UnicodeString; +class FieldPositionHandler; +class PluralRules; +class VisibleDigitsWithExponent; + +/** + * A formatter of numbers. This class can format any numerical value + * except for not a number (NaN), positive infinity, and negative infinity. + * This class manages prefixes, suffixes, and padding but delegates the + * formatting of actual positive values to a ValueFormatter. + */ +class U_I18N_API DigitAffixesAndPadding : public UMemory { +public: + +/** + * Equivalent to DecimalFormat EPadPosition, but redeclared here to prevent + * depending on DecimalFormat which would cause a circular dependency. + */ +enum EPadPosition { + kPadBeforePrefix, + kPadAfterPrefix, + kPadBeforeSuffix, + kPadAfterSuffix +}; + +/** + * The positive prefix + */ +PluralAffix fPositivePrefix; + +/** + * The positive suffix + */ +PluralAffix fPositiveSuffix; + +/** + * The negative suffix + */ +PluralAffix fNegativePrefix; + +/** + * The negative suffix + */ +PluralAffix fNegativeSuffix; + +/** + * The padding position + */ +EPadPosition fPadPosition; + +/** + * The padding character. + */ +UChar32 fPadChar; + +/** + * The field width in code points. The format method inserts instances of + * the padding character as needed in the desired padding position so that + * the entire formatted string contains this many code points. If the + * formatted string already exceeds this many code points, the format method + * inserts no padding. + */ +int32_t fWidth; + +/** + * Pad position is before prefix; padding character is '*' field width is 0. + * The affixes are all the empty string with no annotated fields with just + * the 'other' plural variation. + */ +DigitAffixesAndPadding() + : fPadPosition(kPadBeforePrefix), fPadChar(0x2a), fWidth(0) { } + +/** + * Returns TRUE if this object is equal to rhs. + */ +UBool equals(const DigitAffixesAndPadding &rhs) const { + return (fPositivePrefix.equals(rhs.fPositivePrefix) && + fPositiveSuffix.equals(rhs.fPositiveSuffix) && + fNegativePrefix.equals(rhs.fNegativePrefix) && + fNegativeSuffix.equals(rhs.fNegativeSuffix) && + fPadPosition == rhs.fPadPosition && + fWidth == rhs.fWidth && + fPadChar == rhs.fPadChar); +} + +/** + * Returns TRUE if a plural rules instance is needed to complete the + * formatting by detecting if any of the affixes have multiple plural + * variations. + */ +UBool needsPluralRules() const; + +/** + * Formats value and appends to appendTo. + * + * @param value the value to format. May be NaN or ininite. + * @param formatter handles the details of formatting the actual value. + * @param handler records field positions + * @param optPluralRules the plural rules, but may be NULL if + * needsPluralRules returns FALSE. + * @appendTo formatted string appended here. + * @status any error returned here. + */ +UnicodeString &format( + const VisibleDigitsWithExponent &value, + const ValueFormatter &formatter, + FieldPositionHandler &handler, + const PluralRules *optPluralRules, + UnicodeString &appendTo, + UErrorCode &status) const; + +/** + * For testing only. + */ +UnicodeString &format( + DigitList &value, + const ValueFormatter &formatter, + FieldPositionHandler &handler, + const PluralRules *optPluralRules, + UnicodeString &appendTo, + UErrorCode &status) const; + +/** + * Formats a 32-bit integer and appends to appendTo. When formatting an + * integer, this method is preferred to plain format as it can run + * several times faster under certain conditions. + * + * @param value the value to format. + * @param formatter handles the details of formatting the actual value. + * @param handler records field positions + * @param optPluralRules the plural rules, but may be NULL if + * needsPluralRules returns FALSE. + * @appendTo formatted string appended here. + * @status any error returned here. + */ +UnicodeString &formatInt32( + int32_t value, + const ValueFormatter &formatter, + FieldPositionHandler &handler, + const PluralRules *optPluralRules, + UnicodeString &appendTo, + UErrorCode &status) const; + +private: +UnicodeString &appendPadding(int32_t paddingCount, UnicodeString &appendTo) const; + +}; + + +U_NAMESPACE_END +#endif /* #if !UCONFIG_NO_FORMATTING */ +#endif // __DIGITAFFIXANDPADDING_H__ |