jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ******************************************************************************** jpayne@69: * Copyright (C) 1997-2013, International Business Machines jpayne@69: * Corporation and others. All Rights Reserved. jpayne@69: ******************************************************************************** jpayne@69: * jpayne@69: * File CHOICFMT.H jpayne@69: * jpayne@69: * Modification History: jpayne@69: * jpayne@69: * Date Name Description jpayne@69: * 02/19/97 aliu Converted from java. jpayne@69: * 03/20/97 helena Finished first cut of implementation and got rid jpayne@69: * of nextDouble/previousDouble and replaced with jpayne@69: * boolean array. jpayne@69: * 4/10/97 aliu Clean up. Modified to work on AIX. jpayne@69: * 8/6/97 nos Removed overloaded constructor, member var 'buffer'. jpayne@69: * 07/22/98 stephen Removed operator!= (implemented in Format) jpayne@69: ******************************************************************************** jpayne@69: */ jpayne@69: jpayne@69: #ifndef CHOICFMT_H jpayne@69: #define CHOICFMT_H jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if U_SHOW_CPLUSPLUS_API jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C++ API: Choice Format. jpayne@69: */ jpayne@69: jpayne@69: #if !UCONFIG_NO_FORMATTING jpayne@69: jpayne@69: #include "unicode/fieldpos.h" jpayne@69: #include "unicode/format.h" jpayne@69: #include "unicode/messagepattern.h" jpayne@69: #include "unicode/numfmt.h" jpayne@69: #include "unicode/unistr.h" jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: jpayne@69: U_NAMESPACE_BEGIN jpayne@69: jpayne@69: class MessageFormat; jpayne@69: jpayne@69: /** jpayne@69: * ChoiceFormat converts between ranges of numeric values and strings for those ranges. jpayne@69: * The strings must conform to the MessageFormat pattern syntax. jpayne@69: * jpayne@69: *
ChoiceFormat
is probably not what you need.
jpayne@69: * Please use MessageFormat
jpayne@69: * with plural
arguments for proper plural selection,
jpayne@69: * and select
arguments for simple selection among a fixed set of choices!
A ChoiceFormat
splits
jpayne@69: * the real number line \htmlonly-∞
to
jpayne@69: * +∞
\endhtmlonly into two
jpayne@69: * or more contiguous ranges. Each range is mapped to a
jpayne@69: * string.
ChoiceFormat
was originally intended
jpayne@69: * for displaying grammatically correct
jpayne@69: * plurals such as "There is one file." vs. "There are 2 files."
jpayne@69: * However, plural rules for many languages
jpayne@69: * are too complex for the capabilities of ChoiceFormat,
jpayne@69: * and its requirement of specifying the precise rules for each message
jpayne@69: * is unmanageable for translators.
There are two methods of defining a ChoiceFormat
; both
jpayne@69: * are equivalent. The first is by using a string pattern. This is the
jpayne@69: * preferred method in most cases. The second method is through direct
jpayne@69: * specification of the arrays that logically make up the
jpayne@69: * ChoiceFormat
.
Note: Typically, choice formatting is done (if done at all) via MessageFormat
jpayne@69: * with a choice
argument type,
jpayne@69: * rather than using a stand-alone ChoiceFormat
.
The pattern string defines the range boundaries and the strings for each number range. jpayne@69: * Syntax: jpayne@69: *
jpayne@69: * choiceStyle = number separator message ('|' number separator message)* jpayne@69: * number = normal_number | ['-'] \htmlonly∞\endhtmlonly (U+221E, infinity) jpayne@69: * normal_number = double value (unlocalized ASCII string) jpayne@69: * separator = less_than | less_than_or_equal jpayne@69: * less_than = '<' jpayne@69: * less_than_or_equal = '#' | \htmlonly≤\endhtmlonly (U+2264) jpayne@69: * message: see {@link MessageFormat} jpayne@69: *jpayne@69: * Pattern_White_Space between syntax elements is ignored, except jpayne@69: * around each range's sub-message. jpayne@69: * jpayne@69: *
Each numeric sub-range extends from the current range's number
jpayne@69: * to the next range's number.
jpayne@69: * The number itself is included in its range if a less_than_or_equal
sign is used,
jpayne@69: * and excluded from its range (and instead included in the previous range)
jpayne@69: * if a less_than
sign is used.
When a ChoiceFormat
is constructed from
jpayne@69: * arrays of numbers, closure flags and strings,
jpayne@69: * they are interpreted just like
jpayne@69: * the sequence of (number separator string)
in an equivalent pattern string.
jpayne@69: * closure[i]==TRUE
corresponds to a less_than
separator sign.
jpayne@69: * The equivalent pattern string will be constructed automatically.
During formatting, a number is mapped to the first range jpayne@69: * where the number is not greater than the range's upper limit. jpayne@69: * That range's message string is returned. A NaN maps to the very first range.
jpayne@69: * jpayne@69: *During parsing, a range is selected for the longest match of jpayne@69: * any range's message. That range's number is returned, ignoring the separator/closure. jpayne@69: * Only a simple string match is performed, without parsing of arguments that jpayne@69: * might be specified in the message strings.
jpayne@69: * jpayne@69: *Note that the first range's number is ignored in formatting jpayne@69: * but may be returned from parsing.
jpayne@69: * jpayne@69: *Here is an example of two arrays that map the number
jpayne@69: * 1..7
to the English day of the week abbreviations
jpayne@69: * Sun..Sat
. No closures array is given; this is the same as
jpayne@69: * specifying all closures to be FALSE
.
{1,2,3,4,5,6,7}, jpayne@69: * {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}jpayne@69: * jpayne@69: *
Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1, jpayne@69: * +Inf] to three strings. That is, the number line is split into three jpayne@69: * ranges: x < 1.0, x = 1.0, and x > 1.0. jpayne@69: * (The round parentheses in the notation above indicate an exclusive boundary, jpayne@69: * like the turned bracket in European notation: [-Inf, 1) == [-Inf, 1[ )
jpayne@69: * jpayne@69: *{0, 1, 1}, jpayne@69: * {FALSE, FALSE, TRUE}, jpayne@69: * {"no files", "one file", "many files"}jpayne@69: * jpayne@69: *
Here is an example that shows formatting and parsing:
jpayne@69: * jpayne@69: * \code jpayne@69: * #includeUser subclasses are not supported. While clients may write
jpayne@69: * subclasses, such code will not necessarily work and will not be
jpayne@69: * guaranteed to work stably from release to release.
jpayne@69: *
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: class U_I18N_API ChoiceFormat: public NumberFormat {
jpayne@69: public:
jpayne@69: /**
jpayne@69: * Constructs a new ChoiceFormat from the pattern string.
jpayne@69: *
jpayne@69: * @param pattern Pattern used to construct object.
jpayne@69: * @param status Output param to receive success code. If the
jpayne@69: * pattern cannot be parsed, set to failure code.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: ChoiceFormat(const UnicodeString& pattern,
jpayne@69: UErrorCode& status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Constructs a new ChoiceFormat with the given limits and message strings.
jpayne@69: * All closure flags default to FALSE
,
jpayne@69: * equivalent to less_than_or_equal
separators.
jpayne@69: *
jpayne@69: * Copies the limits and formats instead of adopting them.
jpayne@69: *
jpayne@69: * @param limits Array of limit values.
jpayne@69: * @param formats Array of formats.
jpayne@69: * @param count Size of 'limits' and 'formats' arrays.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: ChoiceFormat(const double* limits,
jpayne@69: const UnicodeString* formats,
jpayne@69: int32_t count );
jpayne@69:
jpayne@69: /**
jpayne@69: * Constructs a new ChoiceFormat with the given limits, closure flags and message strings.
jpayne@69: *
jpayne@69: * Copies the limits and formats instead of adopting them.
jpayne@69: *
jpayne@69: * @param limits Array of limit values
jpayne@69: * @param closures Array of booleans specifying whether each
jpayne@69: * element of 'limits' is open or closed. If FALSE, then the
jpayne@69: * corresponding limit number is a member of its range.
jpayne@69: * If TRUE, then the limit number belongs to the previous range it.
jpayne@69: * @param formats Array of formats
jpayne@69: * @param count Size of 'limits', 'closures', and 'formats' arrays
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: ChoiceFormat(const double* limits,
jpayne@69: const UBool* closures,
jpayne@69: const UnicodeString* formats,
jpayne@69: int32_t count);
jpayne@69:
jpayne@69: /**
jpayne@69: * Copy constructor.
jpayne@69: *
jpayne@69: * @param that ChoiceFormat object to be copied from
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: ChoiceFormat(const ChoiceFormat& that);
jpayne@69:
jpayne@69: /**
jpayne@69: * Assignment operator.
jpayne@69: *
jpayne@69: * @param that ChoiceFormat object to be copied
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: const ChoiceFormat& operator=(const ChoiceFormat& that);
jpayne@69:
jpayne@69: /**
jpayne@69: * Destructor.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual ~ChoiceFormat();
jpayne@69:
jpayne@69: /**
jpayne@69: * Clones this Format object. The caller owns the
jpayne@69: * result and must delete it when done.
jpayne@69: *
jpayne@69: * @return a copy of this object
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual ChoiceFormat* clone() const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns true if the given Format objects are semantically equal.
jpayne@69: * Objects of different subclasses are considered unequal.
jpayne@69: *
jpayne@69: * @param other ChoiceFormat object to be compared
jpayne@69: * @return true if other is the same as this.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual UBool operator==(const Format& other) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets the pattern.
jpayne@69: * @param pattern The pattern to be applied.
jpayne@69: * @param status Output param set to success/failure code on
jpayne@69: * exit. If the pattern is invalid, this will be
jpayne@69: * set to a failure result.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual void applyPattern(const UnicodeString& pattern,
jpayne@69: UErrorCode& status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets the pattern.
jpayne@69: * @param pattern The pattern to be applied.
jpayne@69: * @param parseError Struct to receive information on position
jpayne@69: * of error if an error is encountered
jpayne@69: * @param status Output param set to success/failure code on
jpayne@69: * exit. If the pattern is invalid, this will be
jpayne@69: * set to a failure result.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual void applyPattern(const UnicodeString& pattern,
jpayne@69: UParseError& parseError,
jpayne@69: UErrorCode& status);
jpayne@69: /**
jpayne@69: * Gets the pattern.
jpayne@69: *
jpayne@69: * @param pattern Output param which will receive the pattern
jpayne@69: * Previous contents are deleted.
jpayne@69: * @return A reference to 'pattern'
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual UnicodeString& toPattern(UnicodeString &pattern) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets the choices to be used in formatting.
jpayne@69: * For details see the constructor with the same parameter list.
jpayne@69: *
jpayne@69: * @param limitsToCopy Contains the top value that you want
jpayne@69: * parsed with that format,and should be in
jpayne@69: * ascending sorted order. When formatting X,
jpayne@69: * the choice will be the i, where limit[i]
jpayne@69: * <= X < limit[i+1].
jpayne@69: * @param formatsToCopy The format strings you want to use for each limit.
jpayne@69: * @param count The size of the above arrays.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual void setChoices(const double* limitsToCopy,
jpayne@69: const UnicodeString* formatsToCopy,
jpayne@69: int32_t count );
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets the choices to be used in formatting.
jpayne@69: * For details see the constructor with the same parameter list.
jpayne@69: *
jpayne@69: * @param limits Array of limits
jpayne@69: * @param closures Array of limit booleans
jpayne@69: * @param formats Array of format string
jpayne@69: * @param count The size of the above arrays
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual void setChoices(const double* limits,
jpayne@69: const UBool* closures,
jpayne@69: const UnicodeString* formats,
jpayne@69: int32_t count);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns NULL and 0.
jpayne@69: * Before ICU 4.8, this used to return the choice limits array.
jpayne@69: *
jpayne@69: * @param count Will be set to 0.
jpayne@69: * @return NULL
jpayne@69: * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
jpayne@69: */
jpayne@69: virtual const double* getLimits(int32_t& count) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns NULL and 0.
jpayne@69: * Before ICU 4.8, this used to return the limit booleans array.
jpayne@69: *
jpayne@69: * @param count Will be set to 0.
jpayne@69: * @return NULL
jpayne@69: * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
jpayne@69: */
jpayne@69: virtual const UBool* getClosures(int32_t& count) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns NULL and 0.
jpayne@69: * Before ICU 4.8, this used to return the array of choice strings.
jpayne@69: *
jpayne@69: * @param count Will be set to 0.
jpayne@69: * @return NULL
jpayne@69: * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
jpayne@69: */
jpayne@69: virtual const UnicodeString* getFormats(int32_t& count) const;
jpayne@69:
jpayne@69:
jpayne@69: using NumberFormat::format;
jpayne@69:
jpayne@69: /**
jpayne@69: * Formats a double number using this object's choices.
jpayne@69: *
jpayne@69: * @param number The value to be formatted.
jpayne@69: * @param appendTo Output parameter to receive result.
jpayne@69: * Result is appended to existing contents.
jpayne@69: * @param pos On input: an alignment field, if desired.
jpayne@69: * On output: the offsets of the alignment field.
jpayne@69: * @return Reference to 'appendTo' parameter.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual UnicodeString& format(double number,
jpayne@69: UnicodeString& appendTo,
jpayne@69: FieldPosition& pos) const;
jpayne@69: /**
jpayne@69: * Formats an int32_t number using this object's choices.
jpayne@69: *
jpayne@69: * @param number The value to be formatted.
jpayne@69: * @param appendTo Output parameter to receive result.
jpayne@69: * Result is appended to existing contents.
jpayne@69: * @param pos On input: an alignment field, if desired.
jpayne@69: * On output: the offsets of the alignment field.
jpayne@69: * @return Reference to 'appendTo' parameter.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual UnicodeString& format(int32_t number,
jpayne@69: UnicodeString& appendTo,
jpayne@69: FieldPosition& pos) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Formats an int64_t number using this object's choices.
jpayne@69: *
jpayne@69: * @param number The value to be formatted.
jpayne@69: * @param appendTo Output parameter to receive result.
jpayne@69: * Result is appended to existing contents.
jpayne@69: * @param pos On input: an alignment field, if desired.
jpayne@69: * On output: the offsets of the alignment field.
jpayne@69: * @return Reference to 'appendTo' parameter.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual UnicodeString& format(int64_t number,
jpayne@69: UnicodeString& appendTo,
jpayne@69: FieldPosition& pos) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Formats an array of objects using this object's choices.
jpayne@69: *
jpayne@69: * @param objs The array of objects to be formatted.
jpayne@69: * @param cnt The size of objs.
jpayne@69: * @param appendTo Output parameter to receive result.
jpayne@69: * Result is appended to existing contents.
jpayne@69: * @param pos On input: an alignment field, if desired.
jpayne@69: * On output: the offsets of the alignment field.
jpayne@69: * @param success Output param set to success/failure code on
jpayne@69: * exit.
jpayne@69: * @return Reference to 'appendTo' parameter.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual UnicodeString& format(const Formattable* objs,
jpayne@69: int32_t cnt,
jpayne@69: UnicodeString& appendTo,
jpayne@69: FieldPosition& pos,
jpayne@69: UErrorCode& success) const;
jpayne@69:
jpayne@69: using NumberFormat::parse;
jpayne@69:
jpayne@69: /**
jpayne@69: * Looks for the longest match of any message string on the input text and,
jpayne@69: * if there is a match, sets the result object to the corresponding range's number.
jpayne@69: *
jpayne@69: * If no string matches, then the parsePosition is unchanged.
jpayne@69: *
jpayne@69: * @param text The text to be parsed.
jpayne@69: * @param result Formattable to be set to the parse result.
jpayne@69: * If parse fails, return contents are undefined.
jpayne@69: * @param parsePosition The position to start parsing at on input.
jpayne@69: * On output, moved to after the last successfully
jpayne@69: * parse character. On parse failure, does not change.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual void parse(const UnicodeString& text,
jpayne@69: Formattable& result,
jpayne@69: ParsePosition& parsePosition) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns a unique class ID POLYMORPHICALLY. Part of ICU's "poor man's RTTI".
jpayne@69: *
jpayne@69: * @return The class ID for this object. All objects of a
jpayne@69: * given class have the same class ID. Objects of
jpayne@69: * other classes have different class IDs.
jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
jpayne@69: */
jpayne@69: virtual UClassID getDynamicClassID(void) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the class ID for this class. This is useful only for
jpayne@69: * comparing to a return value from getDynamicClassID(). For example:
jpayne@69: *
jpayne@69: * . Base* polymorphic_pointer = createPolymorphicObject(); jpayne@69: * . if (polymorphic_pointer->getDynamicClassID() == jpayne@69: * . Derived::getStaticClassID()) ... jpayne@69: *jpayne@69: * @return The class ID for all objects of this class. jpayne@69: * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. jpayne@69: */ jpayne@69: static UClassID U_EXPORT2 getStaticClassID(void); jpayne@69: jpayne@69: private: jpayne@69: /** jpayne@69: * Converts a double value to a string. jpayne@69: * @param value the double number to be converted. jpayne@69: * @param string the result string. jpayne@69: * @return the converted string. jpayne@69: */ jpayne@69: static UnicodeString& dtos(double value, UnicodeString& string); jpayne@69: jpayne@69: ChoiceFormat(); // default constructor not implemented jpayne@69: jpayne@69: /** jpayne@69: * Construct a new ChoiceFormat with the limits and the corresponding formats jpayne@69: * based on the pattern. jpayne@69: * jpayne@69: * @param newPattern Pattern used to construct object. jpayne@69: * @param parseError Struct to receive information on position jpayne@69: * of error if an error is encountered. jpayne@69: * @param status Output param to receive success code. If the jpayne@69: * pattern cannot be parsed, set to failure code. jpayne@69: */ jpayne@69: ChoiceFormat(const UnicodeString& newPattern, jpayne@69: UParseError& parseError, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: friend class MessageFormat; jpayne@69: jpayne@69: virtual void setChoices(const double* limits, jpayne@69: const UBool* closures, jpayne@69: const UnicodeString* formats, jpayne@69: int32_t count, jpayne@69: UErrorCode &errorCode); jpayne@69: jpayne@69: /** jpayne@69: * Finds the ChoiceFormat sub-message for the given number. jpayne@69: * @param pattern A MessagePattern. jpayne@69: * @param partIndex the index of the first ChoiceFormat argument style part. jpayne@69: * @param number a number to be mapped to one of the ChoiceFormat argument's intervals jpayne@69: * @return the sub-message start part index. jpayne@69: */ jpayne@69: static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number); jpayne@69: jpayne@69: static double parseArgument( jpayne@69: const MessagePattern &pattern, int32_t partIndex, jpayne@69: const UnicodeString &source, ParsePosition &pos); jpayne@69: jpayne@69: /** jpayne@69: * Matches the pattern string from the end of the partIndex to jpayne@69: * the beginning of the limitPartIndex, jpayne@69: * including all syntax except SKIP_SYNTAX, jpayne@69: * against the source string starting at sourceOffset. jpayne@69: * If they match, returns the length of the source string match. jpayne@69: * Otherwise returns -1. jpayne@69: */ jpayne@69: static int32_t matchStringUntilLimitPart( jpayne@69: const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex, jpayne@69: const UnicodeString &source, int32_t sourceOffset); jpayne@69: jpayne@69: /** jpayne@69: * Some of the ChoiceFormat constructors do not have a UErrorCode paramater. jpayne@69: * We need _some_ way to provide one for the MessagePattern constructor. jpayne@69: * Alternatively, the MessagePattern could be a pointer field, but that is jpayne@69: * not nice either. jpayne@69: */ jpayne@69: UErrorCode constructorErrorCode; jpayne@69: jpayne@69: /** jpayne@69: * The MessagePattern which contains the parsed structure of the pattern string. jpayne@69: * jpayne@69: * Starting with ICU 4.8, the MessagePattern contains a sequence of jpayne@69: * numeric/selector/message parts corresponding to the parsed pattern. jpayne@69: * For details see the MessagePattern class API docs. jpayne@69: */ jpayne@69: MessagePattern msgPattern; jpayne@69: jpayne@69: /** jpayne@69: * Docs & fields from before ICU 4.8, before MessagePattern was used. jpayne@69: * Commented out, and left only for explanation of semantics. jpayne@69: * -------- jpayne@69: * Each ChoiceFormat divides the range -Inf..+Inf into fCount jpayne@69: * intervals. The intervals are: jpayne@69: * jpayne@69: * 0: fChoiceLimits[0]..fChoiceLimits[1] jpayne@69: * 1: fChoiceLimits[1]..fChoiceLimits[2] jpayne@69: * ... jpayne@69: * fCount-2: fChoiceLimits[fCount-2]..fChoiceLimits[fCount-1] jpayne@69: * fCount-1: fChoiceLimits[fCount-1]..+Inf jpayne@69: * jpayne@69: * Interval 0 is special; during formatting (mapping numbers to jpayne@69: * strings), it also contains all numbers less than jpayne@69: * fChoiceLimits[0], as well as NaN values. jpayne@69: * jpayne@69: * Interval i maps to and from string fChoiceFormats[i]. When jpayne@69: * parsing (mapping strings to numbers), then intervals map to jpayne@69: * their lower limit, that is, interval i maps to fChoiceLimit[i]. jpayne@69: * jpayne@69: * The intervals may be closed, half open, or open. This affects jpayne@69: * formatting but does not affect parsing. Interval i is affected jpayne@69: * by fClosures[i] and fClosures[i+1]. If fClosures[i] jpayne@69: * is FALSE, then the value fChoiceLimits[i] is in interval i. jpayne@69: * That is, intervals i and i are: jpayne@69: * jpayne@69: * i-1: ... x < fChoiceLimits[i] jpayne@69: * i: fChoiceLimits[i] <= x ... jpayne@69: * jpayne@69: * If fClosures[i] is TRUE, then the value fChoiceLimits[i] is jpayne@69: * in interval i-1. That is, intervals i-1 and i are: jpayne@69: * jpayne@69: * i-1: ... x <= fChoiceLimits[i] jpayne@69: * i: fChoiceLimits[i] < x ... jpayne@69: * jpayne@69: * Because of the nature of interval 0, fClosures[0] has no jpayne@69: * effect. jpayne@69: */ jpayne@69: // double* fChoiceLimits; jpayne@69: // UBool* fClosures; jpayne@69: // UnicodeString* fChoiceFormats; jpayne@69: // int32_t fCount; jpayne@69: }; jpayne@69: jpayne@69: jpayne@69: U_NAMESPACE_END jpayne@69: jpayne@69: #endif // U_HIDE_DEPRECATED_API jpayne@69: #endif /* #if !UCONFIG_NO_FORMATTING */ jpayne@69: jpayne@69: #endif /* U_SHOW_CPLUSPLUS_API */ jpayne@69: jpayne@69: #endif // CHOICFMT_H jpayne@69: //eof