1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru******************************************************************************** 359d709d503bab6e2b61931737e662dd293b40578ccornelius* Copyright (C) 1997-2013, International Business Machines 4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru******************************************************************************** 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* File CHOICFMT.H 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Modification History: 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Date Name Description 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 02/19/97 aliu Converted from java. 1350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho* 03/20/97 helena Finished first cut of implementation and got rid 14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* of nextDouble/previousDouble and replaced with 15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* boolean array. 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 4/10/97 aliu Clean up. Modified to work on AIX. 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 8/6/97 nos Removed overloaded constructor, member var 'buffer'. 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 07/22/98 stephen Removed operator!= (implemented in Format) 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru******************************************************************************** 20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/ 2150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef CHOICFMT_H 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define CHOICFMT_H 2450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h" 26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 2850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * \file 29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \brief C++ API: Choice Format. 30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING 3383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#ifndef U_HIDE_DEPRECATED_API 34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/fieldpos.h" 36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/format.h" 37b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/messagepattern.h" 38b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/numfmt.h" 39b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/unistr.h" 40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_BEGIN 42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass MessageFormat; 44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 46b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * ChoiceFormat converts between ranges of numeric values and strings for those ranges. 47b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * The strings must conform to the MessageFormat pattern syntax. 48b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 49b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p><em><code>ChoiceFormat</code> is probably not what you need. 50b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Please use <code>MessageFormat</code> 51b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * with <code>plural</code> arguments for proper plural selection, 52b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and <code>select</code> arguments for simple selection among a fixed set of choices!</em></p> 53b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 54b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>A <code>ChoiceFormat</code> splits 55b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * the real number line \htmlonly<code>-∞</code> to 56b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <code>+∞</code>\endhtmlonly into two 57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or more contiguous ranges. Each range is mapped to a 58b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * string.</p> 59b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 60b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p><code>ChoiceFormat</code> was originally intended 61b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * for displaying grammatically correct 62b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * plurals such as "There is one file." vs. "There are 2 files." 63b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <em>However,</em> plural rules for many languages 64b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * are too complex for the capabilities of ChoiceFormat, 65b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and its requirement of specifying the precise rules for each message 66b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * is unmanageable for translators.</p> 6750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>There are two methods of defining a <code>ChoiceFormat</code>; both 69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are equivalent. The first is by using a string pattern. This is the 70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * preferred method in most cases. The second method is through direct 71b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * specification of the arrays that logically make up the 72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>ChoiceFormat</code>.</p> 7350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 74b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Note: Typically, choice formatting is done (if done at all) via <code>MessageFormat</code> 75b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * with a <code>choice</code> argument type, 76b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * rather than using a stand-alone <code>ChoiceFormat</code>.</p> 77b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 78b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <h5>Patterns and Their Interpretation</h5> 79b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 80b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>The pattern string defines the range boundaries and the strings for each number range. 81b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Syntax: 82b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <pre> 83b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * choiceStyle = number separator message ('|' number separator message)* 84b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * number = normal_number | ['-'] \htmlonly∞\endhtmlonly (U+221E, infinity) 85b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * normal_number = double value (unlocalized ASCII string) 86b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * separator = less_than | less_than_or_equal 87b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * less_than = '<' 88b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * less_than_or_equal = '#' | \htmlonly≤\endhtmlonly (U+2264) 89b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * message: see {@link MessageFormat} 90b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * </pre> 91b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Pattern_White_Space between syntax elements is ignored, except 92b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * around each range's sub-message.</p> 93b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 94b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Each numeric sub-range extends from the current range's number 95b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * to the next range's number. 96b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * The number itself is included in its range if a <code>less_than_or_equal</code> sign is used, 97b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and excluded from its range (and instead included in the previous range) 98b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * if a <code>less_than</code> sign is used.</p> 99b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 100b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>When a <code>ChoiceFormat</code> is constructed from 101b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * arrays of numbers, closure flags and strings, 102b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * they are interpreted just like 103b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * the sequence of <code>(number separator string)</code> in an equivalent pattern string. 104b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <code>closure[i]==TRUE</code> corresponds to a <code>less_than</code> separator sign. 105b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * The equivalent pattern string will be constructed automatically.</p> 106b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 107b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>During formatting, a number is mapped to the first range 108b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * where the number is not greater than the range's upper limit. 109b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * That range's message string is returned. A NaN maps to the very first range.</p> 110b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 111b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>During parsing, a range is selected for the longest match of 112b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * any range's message. That range's number is returned, ignoring the separator/closure. 113b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Only a simple string match is performed, without parsing of arguments that 114b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * might be specified in the message strings.</p> 115b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 116b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Note that the first range's number is ignored in formatting 117b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * but may be returned from parsing.</p> 118b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 119b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <h5>Examples</h5> 12050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>Here is an example of two arrays that map the number 122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>1..7</code> to the English day of the week abbreviations 123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>Sun..Sat</code>. No closures array is given; this is the same as 124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * specifying all closures to be <code>FALSE</code>.</p> 12550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre> {1,2,3,4,5,6,7}, 127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}</pre> 12850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1, 130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * +Inf] to three strings. That is, the number line is split into three 131b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * ranges: x < 1.0, x = 1.0, and x > 1.0. 132b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * (The round parentheses in the notation above indicate an exclusive boundary, 133b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * like the turned bracket in European notation: [-Inf, 1) == [-Inf, 1[ )</p> 13450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre> {0, 1, 1}, 136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * {FALSE, FALSE, TRUE}, 137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * {"no files", "one file", "many files"}</pre> 13850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 139b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Here is an example that shows formatting and parsing: </p> 14050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code 142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * #include <unicode/choicfmt.h> 143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * #include <unicode/unistr.h> 144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * #include <iostream.h> 14550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * int main(int argc, char *argv[]) { 147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * double limits[] = {1,2,3,4,5,6,7}; 148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString monthNames[] = { 149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * "Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; 150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ChoiceFormat fmt(limits, monthNames, 7); 151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString str; 152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * char buf[256]; 153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * for (double x = 1.0; x <= 8.0; x += 1.0) { 154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * fmt.format(x, str); 155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * str.extract(0, str.length(), buf, 256, ""); 156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * str.truncate(0); 157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * cout << x << " -> " 158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * << buf << endl; 159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * } 160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * cout << endl; 161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * return 0; 162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * } 163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode 16450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p><em>User subclasses are not supported.</em> While clients may write 166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * subclasses, such code will not necessarily work and will not be 167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * guaranteed to work stably from release to release. 16883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * 16983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass U_I18N_API ChoiceFormat: public NumberFormat { 172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic: 173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 174b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Constructs a new ChoiceFormat from the pattern string. 175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pattern Pattern used to construct object. 177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Output param to receive success code. If the 178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * pattern cannot be parsed, set to failure code. 17983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ChoiceFormat(const UnicodeString& pattern, 182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode& status); 183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 186b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Constructs a new ChoiceFormat with the given limits and message strings. 187b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * All closure flags default to <code>FALSE</code>, 188b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * equivalent to <code>less_than_or_equal</code> separators. 189b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 190b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Copies the limits and formats instead of adopting them. 191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limits Array of limit values. 193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param formats Array of formats. 194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param count Size of 'limits' and 'formats' arrays. 19583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ChoiceFormat(const double* limits, 198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString* formats, 199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t count ); 200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 202b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Constructs a new ChoiceFormat with the given limits, closure flags and message strings. 203b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 204b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Copies the limits and formats instead of adopting them. 205b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limits Array of limit values 207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param closures Array of booleans specifying whether each 208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * element of 'limits' is open or closed. If FALSE, then the 209b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * corresponding limit number is a member of its range. 210b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * If TRUE, then the limit number belongs to the previous range it. 211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param formats Array of formats 212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param count Size of 'limits', 'closures', and 'formats' arrays 21383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ChoiceFormat(const double* limits, 216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UBool* closures, 217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString* formats, 218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t count); 219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy constructor. 222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param that ChoiceFormat object to be copied from 22483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ChoiceFormat(const ChoiceFormat& that); 227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Assignment operator. 230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param that ChoiceFormat object to be copied 23283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const ChoiceFormat& operator=(const ChoiceFormat& that); 235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Destructor. 23883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual ~ChoiceFormat(); 241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 243b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Clones this Format object. The caller owns the 244b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * result and must delete it when done. 245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a copy of this object 24783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual Format* clone(void) const; 250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 252b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Returns true if the given Format objects are semantically equal. 253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Objects of different subclasses are considered unequal. 254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 25550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param other ChoiceFormat object to be compared 25650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return true if other is the same as this. 25783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UBool operator==(const Format& other) const; 260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Sets the pattern. 263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pattern The pattern to be applied. 264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Output param set to success/failure code on 265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * exit. If the pattern is invalid, this will be 266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * set to a failure result. 26783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void applyPattern(const UnicodeString& pattern, 270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode& status); 271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Sets the pattern. 274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pattern The pattern to be applied. 275b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param parseError Struct to receive information on position 276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of error if an error is encountered 277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Output param set to success/failure code on 278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * exit. If the pattern is invalid, this will be 279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * set to a failure result. 28083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void applyPattern(const UnicodeString& pattern, 283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UParseError& parseError, 284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode& status); 285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Gets the pattern. 28750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 288b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param pattern Output param which will receive the pattern 289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Previous contents are deleted. 290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to 'pattern' 29183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UnicodeString& toPattern(UnicodeString &pattern) const; 294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 296b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Sets the choices to be used in formatting. 297b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * For details see the constructor with the same parameter list. 298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limitsToCopy Contains the top value that you want 300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * parsed with that format,and should be in 301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ascending sorted order. When formatting X, 302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the choice will be the i, where limit[i] 303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <= X < limit[i+1]. 304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param formatsToCopy The format strings you want to use for each limit. 305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param count The size of the above arrays. 30683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void setChoices(const double* limitsToCopy, 309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString* formatsToCopy, 31050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho int32_t count ); 311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 313b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Sets the choices to be used in formatting. 314b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * For details see the constructor with the same parameter list. 315b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limits Array of limits 317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param closures Array of limit booleans 318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param formats Array of format string 319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param count The size of the above arrays 32083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void setChoices(const double* limits, 323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UBool* closures, 324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString* formats, 325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t count); 326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 328b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Returns NULL and 0. 329b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Before ICU 4.8, this used to return the choice limits array. 330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 331b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param count Will be set to 0. 332b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @return NULL 333b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern. 334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual const double* getLimits(int32_t& count) const; 33650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 338b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Returns NULL and 0. 339b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Before ICU 4.8, this used to return the limit booleans array. 340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 341b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param count Will be set to 0. 342b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @return NULL 343b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern. 344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual const UBool* getClosures(int32_t& count) const; 346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 348b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Returns NULL and 0. 349b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Before ICU 4.8, this used to return the array of choice strings. 350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 351b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param count Will be set to 0. 352b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @return NULL 353b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern. 354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual const UnicodeString* getFormats(int32_t& count) const; 356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 35750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 35850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho using NumberFormat::format; 35950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 361b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Formats a double number using this object's choices. 362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param number The value to be formatted. 364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param appendTo Output parameter to receive result. 365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Result is appended to existing contents. 366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pos On input: an alignment field, if desired. 367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * On output: the offsets of the alignment field. 368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Reference to 'appendTo' parameter. 36983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UnicodeString& format(double number, 372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& appendTo, 373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru FieldPosition& pos) const; 374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 375b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Formats an int32_t number using this object's choices. 376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param number The value to be formatted. 378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param appendTo Output parameter to receive result. 379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Result is appended to existing contents. 380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pos On input: an alignment field, if desired. 381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * On output: the offsets of the alignment field. 382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Reference to 'appendTo' parameter. 38383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UnicodeString& format(int32_t number, 386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& appendTo, 387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru FieldPosition& pos) const; 388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 390b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Formats an int64_t number using this object's choices. 391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param number The value to be formatted. 393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param appendTo Output parameter to receive result. 394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Result is appended to existing contents. 395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pos On input: an alignment field, if desired. 396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * On output: the offsets of the alignment field. 397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Reference to 'appendTo' parameter. 39883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UnicodeString& format(int64_t number, 401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& appendTo, 402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru FieldPosition& pos) const; 403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 405b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Formats an array of objects using this object's choices. 406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param objs The array of objects to be formatted. 408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param cnt The size of objs. 409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param appendTo Output parameter to receive result. 410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Result is appended to existing contents. 411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pos On input: an alignment field, if desired. 412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * On output: the offsets of the alignment field. 413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param success Output param set to success/failure code on 41450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * exit. 415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Reference to 'appendTo' parameter. 41683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UnicodeString& format(const Formattable* objs, 419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t cnt, 420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& appendTo, 421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru FieldPosition& pos, 422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode& success) const; 423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 42459d709d503bab6e2b61931737e662dd293b40578ccornelius using NumberFormat::parse; 425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 427b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Looks for the longest match of any message string on the input text and, 428b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * if there is a match, sets the result object to the corresponding range's number. 429b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 430b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * If no string matches, then the parsePosition is unchanged. 431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to be parsed. 433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param result Formattable to be set to the parse result. 434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If parse fails, return contents are undefined. 435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parsePosition The position to start parsing at on input. 436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * On output, moved to after the last successfully 437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * parse character. On parse failure, does not change. 43883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void parse(const UnicodeString& text, 441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru Formattable& result, 442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ParsePosition& parsePosition) const; 44350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 445b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Returns a unique class ID POLYMORPHICALLY. Part of ICU's "poor man's RTTI". 446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The class ID for this object. All objects of a 448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * given class have the same class ID. Objects of 449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * other classes have different class IDs. 45083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UClassID getDynamicClassID(void) const; 453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 455b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Returns the class ID for this class. This is useful only for 456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * comparing to a return value from getDynamicClassID(). For example: 457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre> 458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * . Base* polymorphic_pointer = createPolymorphicObject(); 459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * . if (polymorphic_pointer->getDynamicClassID() == 460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * . Derived::getStaticClassID()) ... 461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </pre> 462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The class ID for all objects of this class. 46383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru static UClassID U_EXPORT2 getStaticClassID(void); 466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprivate: 468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 469b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Converts a double value to a string. 470b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param value the double number to be converted. 471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param string the result string. 472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the converted string. 473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru static UnicodeString& dtos(double value, UnicodeString& string); 475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ChoiceFormat(); // default constructor not implemented 477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Construct a new ChoiceFormat with the limits and the corresponding formats 480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * based on the pattern. 481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param newPattern Pattern used to construct object. 483b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param parseError Struct to receive information on position 484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of error if an error is encountered. 485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Output param to receive success code. If the 486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * pattern cannot be parsed, set to failure code. 487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ChoiceFormat(const UnicodeString& newPattern, 489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UParseError& parseError, 490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode& status); 491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru friend class MessageFormat; 493b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 494b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho virtual void setChoices(const double* limits, 495b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const UBool* closures, 496b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const UnicodeString* formats, 497b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho int32_t count, 498b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UErrorCode &errorCode); 499b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 500b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho /** 501b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Finds the ChoiceFormat sub-message for the given number. 502b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param pattern A MessagePattern. 503b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param partIndex the index of the first ChoiceFormat argument style part. 504b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param number a number to be mapped to one of the ChoiceFormat argument's intervals 505b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @return the sub-message start part index. 506b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho */ 507b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number); 508b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 509b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho static double parseArgument( 510b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const MessagePattern &pattern, int32_t partIndex, 511b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const UnicodeString &source, ParsePosition &pos); 512b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 514b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Matches the pattern string from the end of the partIndex to 515b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * the beginning of the limitPartIndex, 516b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * including all syntax except SKIP_SYNTAX, 517b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * against the source string starting at sourceOffset. 518b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * If they match, returns the length of the source string match. 519b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Otherwise returns -1. 520b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho */ 521b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho static int32_t matchStringUntilLimitPart( 522b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex, 523b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const UnicodeString &source, int32_t sourceOffset); 524b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 525b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho /** 526b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Some of the ChoiceFormat constructors do not have a UErrorCode paramater. 527b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * We need _some_ way to provide one for the MessagePattern constructor. 528b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Alternatively, the MessagePattern could be a pointer field, but that is 529b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * not nice either. 530b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho */ 531b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UErrorCode constructorErrorCode; 532b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 533b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho /** 534b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * The MessagePattern which contains the parsed structure of the pattern string. 535b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 536b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Starting with ICU 4.8, the MessagePattern contains a sequence of 537b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * numeric/selector/message parts corresponding to the parsed pattern. 538b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * For details see the MessagePattern class API docs. 539b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho */ 540b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho MessagePattern msgPattern; 541b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 542b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho /** 543b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Docs & fields from before ICU 4.8, before MessagePattern was used. 544b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Commented out, and left only for explanation of semantics. 545b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * -------- 546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Each ChoiceFormat divides the range -Inf..+Inf into fCount 547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * intervals. The intervals are: 548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 0: fChoiceLimits[0]..fChoiceLimits[1] 550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1: fChoiceLimits[1]..fChoiceLimits[2] 551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ... 552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * fCount-2: fChoiceLimits[fCount-2]..fChoiceLimits[fCount-1] 553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * fCount-1: fChoiceLimits[fCount-1]..+Inf 554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Interval 0 is special; during formatting (mapping numbers to 556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * strings), it also contains all numbers less than 557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * fChoiceLimits[0], as well as NaN values. 558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Interval i maps to and from string fChoiceFormats[i]. When 560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * parsing (mapping strings to numbers), then intervals map to 561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * their lower limit, that is, interval i maps to fChoiceLimit[i]. 562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The intervals may be closed, half open, or open. This affects 564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * formatting but does not affect parsing. Interval i is affected 565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by fClosures[i] and fClosures[i+1]. If fClosures[i] 566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is FALSE, then the value fChoiceLimits[i] is in interval i. 567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * That is, intervals i and i are: 568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * i-1: ... x < fChoiceLimits[i] 570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * i: fChoiceLimits[i] <= x ... 571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If fClosures[i] is TRUE, then the value fChoiceLimits[i] is 573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in interval i-1. That is, intervals i-1 and i are: 574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * i-1: ... x <= fChoiceLimits[i] 576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * i: fChoiceLimits[i] < x ... 577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Because of the nature of interval 0, fClosures[0] has no 579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * effect. 580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 581b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho // double* fChoiceLimits; 582b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho // UBool* fClosures; 583b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho // UnicodeString* fChoiceFormats; 584b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho // int32_t fCount; 585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 58650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 58759d709d503bab6e2b61931737e662dd293b40578ccornelius 588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_END 589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 59083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#endif // U_HIDE_DEPRECATED_API 591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_FORMATTING */ 592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 59383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#endif // CHOICFMT_H 594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//eof 595