/** * A FixedDecimal version of UPLRULES_NO_UNIQUE_VALUE used in PluralRulesTest * for parsing of samples.
*/ #define UPLRULES_NO_UNIQUE_VALUE_DECIMAL(ERROR_CODE) (DecimalQuantity::fromExponentString(u"-0.00123456777", ERROR_CODE))
class PluralRulesTest;
U_NAMESPACE_BEGIN
class AndConstraint; class RuleChain; class DigitInterval; class PluralRules; class VisibleDigits;
namespace pluralimpl {
// TODO: Remove this and replace with u"" literals. Was for EBCDIC compatibility.
const UnicodeString *ruleSrc; // The rules string.
int32_t ruleIndex; // String index in the input rules, the current parse position.
UnicodeString token; // Token most recently scanned.
tokenType type;
tokenType prevType;
// The items currently being parsed & built. // Note: currentChain may not be the last RuleChain in the // list because the "other" chain is forced to the end.
AndConstraint *curAndConstraint;
RuleChain *currentChain;
int32_t rangeLowIdx; // Indices in the UVector of ranges of the
int32_t rangeHiIdx; // low and hi values currently being parsed.
enum PluralOperand { /** * The double value of the entire number.
*/
PLURAL_OPERAND_N,
/** * The integer value, with the fraction digits truncated off.
*/
PLURAL_OPERAND_I,
/** * All visible fraction digits as an integer, including trailing zeros.
*/
PLURAL_OPERAND_F,
/** * Visible fraction digits as an integer, not including trailing zeros.
*/
PLURAL_OPERAND_T,
/** * Number of visible fraction digits.
*/
PLURAL_OPERAND_V,
/** * Number of visible fraction digits, not including trailing zeros.
*/
PLURAL_OPERAND_W,
/** * Suppressed exponent for scientific notation (exponent needed in * scientific notation to approximate i).
*/
PLURAL_OPERAND_E,
/** * This operand is currently treated as an alias for `PLURAL_OPERAND_E`. * In the future, it will represent: * * Suppressed exponent for compact notation (exponent needed in * compact notation to approximate i).
*/
PLURAL_OPERAND_C,
/** * THIS OPERAND IS DEPRECATED AND HAS BEEN REMOVED FROM THE SPEC. * * <p>Returns the integer value, but will fail if the number has fraction digits. * That is, using "j" instead of "i" is like implicitly adding "v is 0". * * <p>For example, "j is 3" is equivalent to "i is 3 and v is 0": it matches * "3" but not "3.1" or "3.0".
*/
PLURAL_OPERAND_J
};
/** * Converts from the tokenType enum to PluralOperand. Asserts that the given * tokenType can be mapped to a PluralOperand.
*/
PluralOperand tokenTypeToPluralOperand(tokenType tt);
/** * An interface to FixedDecimal, allowing for other implementations. * @internal
*/ class U_I18N_API IFixedDecimal { public: virtual ~IFixedDecimal();
/** * Returns the value corresponding to the specified operand (n, i, f, t, v, or w). * If the operand is 'n', returns a double; otherwise, returns an integer.
*/ virtualdouble getPluralOperand(PluralOperand operand) const = 0;
virtualbool isNaN() const = 0;
virtualbool isInfinite() const = 0;
/** Whether the number has no nonzero fraction digits. */ virtualbool hasIntegerValue() const = 0;
};
/** * class FixedDecimal serves to communicate the properties * of a formatted number from a decimal formatter to PluralRules::select() * * see DecimalFormat::getFixedDecimal() * @internal
*/ class U_I18N_API FixedDecimal: public IFixedDecimal, public UObject { public: /** * @param n the number, e.g. 12.345 * @param v The number of visible fraction digits, e.g. 3 * @param f The fraction digits, e.g. 345 * @param e The exponent, e.g. 7 in 1.2e7, for scientific notation * @param c Currently: an alias for param `e`.
*/
FixedDecimal(double n, int32_t v, int64_t f, int32_t e, int32_t c);
FixedDecimal(double n, int32_t v, int64_t f, int32_t e);
FixedDecimal(double n, int32_t v, int64_t f);
FixedDecimal(double n, int32_t); explicit FixedDecimal(double n);
FixedDecimal();
~FixedDecimal() override;
FixedDecimal(const UnicodeString &s, UErrorCode &ec);
FixedDecimal(const FixedDecimal &other);
static FixedDecimal createWithExponent(double n, int32_t v, int32_t e);
class AndConstraint : public UMemory { public: typedefenum RuleOp {
NONE,
MOD
} RuleOp;
RuleOp op = AndConstraint::NONE;
int32_t opNum = -1; // for mod expressions, the right operand of the mod.
int32_t value = -1; // valid for 'is' rules only.
UVector32 *rangeList = nullptr; // for 'in', 'within' rules. Null otherwise.
UBool negated = false; // true for negated rules.
UBool integerOnly = false; // true for 'within' rules.
tokenType digitsType = none; // n | i | v | f constraint.
AndConstraint *next = nullptr; // Internal error status, used for errors that occur during the copy constructor.
UErrorCode fInternalStatus = U_ZERO_ERROR;
class OrConstraint : public UMemory { public:
AndConstraint *childNode = nullptr;
OrConstraint *next = nullptr; // Internal error status, used for errors that occur during the copy constructor.
UErrorCode fInternalStatus = U_ZERO_ERROR;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.