1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
2103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius* Copyright (C) 2007-2012, International Business Machines Corporation and
350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho* others. All Rights Reserved.
4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************************
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* File MSGFMT.H
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Modification History:
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Date        Name        Description
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   02/19/97    aliu        Converted from java.
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   03/20/97    helena      Finished first cut of implementation.
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   07/22/98    stephen     Removed operator!= (defined in Format)
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   08/19/2002  srl         Removing Javaisms
1550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho*******************************************************************************/
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef MSGFMT_H
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define MSGFMT_H
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
2350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * \file
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \brief C++ API: Formats messages in a language-neutral way.
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
2650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/format.h"
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/locid.h"
31b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/messagepattern.h"
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/parseerr.h"
33b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/plurfmt.h"
34b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/plurrule.h"
35b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
36b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoU_CDECL_BEGIN
37b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho// Forward declaration.
38b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehostruct UHashtable;
39b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehotypedef struct UHashtable UHashtable;
40b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoU_CDECL_END
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_BEGIN
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
44b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoclass AppendableWrapper;
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass DateFormat;
46b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoclass NumberFormat;
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
49b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>MessageFormat prepares strings for display to users,
50b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * with optional arguments (variables/placeholders).
51b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * The arguments can occur in any order, which is necessary for translation
52b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * into languages with different grammars.
53b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
54b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>A MessageFormat is constructed from a <em>pattern</em> string
55b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * with arguments in {curly braces} which will be replaced by formatted values.
56b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
57b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p><code>MessageFormat</code> differs from the other <code>Format</code>
58b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * classes in that you create a <code>MessageFormat</code> object with one
59b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * of its constructors (not with a <code>createInstance</code> style factory
60b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * method). Factory methods aren't necessary because <code>MessageFormat</code>
61b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * itself doesn't implement locale-specific behavior. Any locale-specific
62b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * behavior is defined by the pattern that you provide and the
63b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * subformats used for inserted arguments.
64b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
65b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Arguments can be named (using identifiers) or numbered (using small ASCII-digit integers).
66b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Some of the API methods work only with argument numbers and throw an exception
67b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * if the pattern has named arguments (see {@link #usesNamedArguments()}).
68b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
69b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>An argument might not specify any format type. In this case,
70b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * a Number value is formatted with a default (for the locale) NumberFormat,
71b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * a Date value is formatted with a default (for the locale) DateFormat,
72b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and for any other value its toString() value is used.
73b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
74b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>An argument might specify a "simple" type for which the specified
75b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Format object is created, cached and used.
76b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
77b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>An argument might have a "complex" type with nested MessageFormat sub-patterns.
78b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * During formatting, one of these sub-messages is selected according to the argument value
79b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and recursively formatted.
80b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
81b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>After construction, a custom Format object can be set for
82b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * a top-level argument, overriding the default formatting and parsing behavior
83b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * for that argument.
84b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * However, custom formatting can be achieved more simply by writing
85b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * a typeless argument in the pattern string
86b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and supplying it with a preformatted string value.
87b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
88b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>When formatting, MessageFormat takes a collection of argument values
89b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and writes an output string.
90b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * The argument values may be passed as an array
91b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * (when the pattern contains only numbered arguments)
92b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * or as an array of names and and an array of arguments (which works for both named
93b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and numbered arguments).
94b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
95b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Each argument is matched with one of the input values by array index or argument name
96b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * and formatted according to its pattern specification
97b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * (or using a custom Format object if one was set).
98b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * A numbered pattern argument is matched with an argument name that contains that number
99b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * as an ASCII-decimal-digit string (without leading zero).
100b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
101b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <h4><a name="patterns">Patterns and Their Interpretation</a></h4>
102b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
103b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <code>MessageFormat</code> uses patterns of the following form:
104b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <pre>
105b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * message = messageText (argument messageText)*
106b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * argument = noneArg | simpleArg | complexArg
10754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * complexArg = choiceArg | pluralArg | selectArg | selectordinalArg
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
109b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * noneArg = '{' argNameOrNumber '}'
110b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * simpleArg = '{' argNameOrNumber ',' argType [',' argStyle] '}'
111b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * choiceArg = '{' argNameOrNumber ',' "choice" ',' choiceStyle '}'
112b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * pluralArg = '{' argNameOrNumber ',' "plural" ',' pluralStyle '}'
113b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * selectArg = '{' argNameOrNumber ',' "select" ',' selectStyle '}'
11454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * selectordinalArg = '{' argNameOrNumber ',' "selectordinal" ',' pluralStyle '}'
115b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
116b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * choiceStyle: see {@link ChoiceFormat}
117b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * pluralStyle: see {@link PluralFormat}
118b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * selectStyle: see {@link SelectFormat}
119b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
120b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * argNameOrNumber = argName | argNumber
121b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * argName = [^[[:Pattern_Syntax:][:Pattern_White_Space:]]]+
122b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * argNumber = '0' | ('1'..'9' ('0'..'9')*)
123b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
124b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * argType = "number" | "date" | "time" | "spellout" | "ordinal" | "duration"
125b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * argStyle = "short" | "medium" | "long" | "full" | "integer" | "currency" | "percent" | argStyleText
126b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * </pre>
127b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
128b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <ul>
129b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *   <li>messageText can contain quoted literal strings including syntax characters.
130b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       A quoted literal string begins with an ASCII apostrophe and a syntax character
131b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       (usually a {curly brace}) and continues until the next single apostrophe.
132b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       A double ASCII apostrohpe inside or outside of a quoted string represents
133b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       one literal apostrophe.
134b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *   <li>Quotable syntax characters are the {curly braces} in all messageText parts,
135b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       plus the '#' sign in a messageText immediately inside a pluralStyle,
136b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       and the '|' symbol in a messageText immediately inside a choiceStyle.
137b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *   <li>See also {@link #UMessagePatternApostropheMode}
138b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *   <li>In argStyleText, every single ASCII apostrophe begins and ends quoted literal text,
139b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       and unquoted {curly braces} must occur in matched pairs.
140b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * </ul>
141b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
142b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Recommendation: Use the real apostrophe (single quote) character
143b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * \htmlonly&#x2019;\endhtmlonly (U+2019) for
144b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * human-readable text, and use the ASCII apostrophe ' (U+0027)
145b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * only in program syntax, like quoting in MessageFormat.
146b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * See the annotations for U+0027 Apostrophe in The Unicode Standard.
147b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
148103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>The <code>choice</code> argument type is deprecated.
149103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Use <code>plural</code> arguments for proper plural selection,
150103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * and <code>select</code> arguments for simple selection among a fixed set of choices.
151103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius *
152b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>The <code>argType</code> and <code>argStyle</code> values are used to create
153b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * a <code>Format</code> instance for the format element. The following
154b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * table shows how the values map to Format instances. Combinations not
155b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * shown in the table are illegal. Any <code>argStyleText</code> must
156b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * be a valid pattern string for the Format subclass used.
157b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
158b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p><table border=1>
159b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
160b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <th>argType
161b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <th>argStyle
162b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <th>resulting Format object
163b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
164b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td colspan=2><i>(none)</i>
165b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>null</code>
166b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
167b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td rowspan=5><code>number</code>
168b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>(none)</i>
169b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>NumberFormat.createInstance(getLocale(), status)</code>
170b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
171b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>integer</code>
172b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>NumberFormat.createInstance(getLocale(), kNumberStyle, status)</code>
173b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
174b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>currency</code>
175b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>NumberFormat.createCurrencyInstance(getLocale(), status)</code>
176b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
177b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>percent</code>
178b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>NumberFormat.createPercentInstance(getLocale(), status)</code>
179b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
180b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>argStyleText</i>
181b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>new DecimalFormat(argStyleText, new DecimalFormatSymbols(getLocale(), status), status)</code>
182b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
183b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td rowspan=6><code>date</code>
184b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>(none)</i>
185b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createDateInstance(kDefault, getLocale(), status)</code>
186b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
187b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>short</code>
188b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createDateInstance(kShort, getLocale(), status)</code>
189b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
190b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>medium</code>
191b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createDateInstance(kDefault, getLocale(), status)</code>
192b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
193b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>long</code>
194b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createDateInstance(kLong, getLocale(), status)</code>
195b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
196b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>full</code>
197b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createDateInstance(kFull, getLocale(), status)</code>
198b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
199b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>argStyleText</i>
200b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)
201b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
202b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td rowspan=6><code>time</code>
203b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>(none)</i>
204b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createTimeInstance(kDefault, getLocale(), status)</code>
205b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
206b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>short</code>
207b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createTimeInstance(kShort, getLocale(), status)</code>
208b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
209b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>medium</code>
210b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createTimeInstance(kDefault, getLocale(), status)</code>
211b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
212b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>long</code>
213b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createTimeInstance(kLong, getLocale(), status)</code>
214b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
215b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>full</code>
216b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>DateFormat.createTimeInstance(kFull, getLocale(), status)</code>
217b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
218b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>argStyleText</i>
219b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)
220b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
221b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>spellout</code>
222b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>argStyleText (optional)</i>
223b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>new RuleBasedNumberFormat(URBNF_SPELLOUT, getLocale(), status)
224b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *           <br/>&nbsp;&nbsp;&nbsp;&nbsp;.setDefaultRuleset(argStyleText, status);</code>
225b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
226b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>ordinal</code>
227b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>argStyleText (optional)</i>
228b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>new RuleBasedNumberFormat(URBNF_ORDINAL, getLocale(), status)
229b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *           <br/>&nbsp;&nbsp;&nbsp;&nbsp;.setDefaultRuleset(argStyleText, status);</code>
230b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *    <tr>
231b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>duration</code>
232b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><i>argStyleText (optional)</i>
233b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       <td><code>new RuleBasedNumberFormat(URBNF_DURATION, getLocale(), status)
234b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *           <br/>&nbsp;&nbsp;&nbsp;&nbsp;.setDefaultRuleset(argStyleText, status);</code>
235b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * </table>
236b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>
237b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
238b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <h4>Usage Information</h4>
239b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
240b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Here are some examples of usage:
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Example 1:
242b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre>
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     UErrorCode success = U_ZERO_ERROR;
246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     GregorianCalendar cal(success);
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     Formattable arguments[] = {
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         7L,
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         Formattable( (Date) cal.getTime(success), Formattable::kIsDate),
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         "a disturbance in the Force"
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     };
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     UnicodeString result;
254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     MessageFormat::format(
255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          "At {1,time} on {1,date}, there was {2} on planet {0,number}.",
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          arguments, 3, result, success );
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     cout << "result: " << result << endl;
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     //<output>: At 4:34:20 PM on 23-Mar-98, there was a disturbance
260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     //             in the Force on planet 7.
261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode
262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </pre>
263b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Typically, the message format will come from resources, and the
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * arguments will be dynamically set at runtime.
266b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
267b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>Example 2:
268b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre>
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  \code
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     success = U_ZERO_ERROR;
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     Formattable testArgs[] = {3L, "MyDisk"};
273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     MessageFormat form(
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         "The disk \"{1}\" contains {0} file(s).", success );
276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     UnicodeString string;
278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     FieldPosition fpos = 0;
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     cout << "format: " << form.format(testArgs, 2, string, fpos, success ) << endl;
280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     // output, with different testArgs:
282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     // output: The disk "MyDisk" contains 0 file(s).
283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     // output: The disk "MyDisk" contains 1 file(s).
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     // output: The disk "MyDisk" contains 1,273 file(s).
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  \endcode
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  </pre>
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
289b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>For messages that include plural forms, you can use a plural argument:
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre>
291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code
292b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  success = U_ZERO_ERROR;
293b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  MessageFormat msgFmt(
294b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       "{num_files, plural, "
295b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       "=0{There are no files on disk \"{disk_name}\".}"
296b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       "=1{There is one file on disk \"{disk_name}\".}"
297b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *       "other{There are # files on disk \"{disk_name}\".}}",
298b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *      Locale("en"),
299b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *      success);
300b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  FieldPosition fpos = 0;
301b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  Formattable testArgs[] = {0L, "MyDisk"};
302b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  UnicodeString testArgsNames[] = {"num_files", "disk_name"};
30327f654740f2a26ad62a5c155af9199af9e69b889claireho *  UnicodeString result;
304b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  cout << msgFmt.format(testArgs, testArgsNames, 2, result, fpos, 0, success);
305b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  testArgs[0] = 3L;
306b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *  cout << msgFmt.format(testArgs, testArgsNames, 2, result, fpos, 0, success);
307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode
308b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <em>output</em>:
309b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * There are no files on disk "MyDisk".
310b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * There are 3 files on "MyDisk".
311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </pre>
312b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * See {@link PluralFormat} and {@link PluralRules} for details.
313b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
314b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <h4><a name="synchronization">Synchronization</a></h4>
315b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
316b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>MessageFormats are not synchronized.
317b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * It is recommended to create separate format instances for each thread.
318b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * If multiple threads access a format concurrently, it must be synchronized
319b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * externally.
320b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *
321b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @stable ICU 2.0
322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass U_I18N_API MessageFormat : public Format {
324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic:
325103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_OBSOLETE_API
326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Enum type for kMaxFormat.
328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @obsolete ICU 3.0.  The 10-argument limit was removed as of ICU 2.6,
329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * rendering this enum type obsolete.
330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum EFormatNumber {
332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * The maximum number of arguments.
334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @obsolete ICU 3.0.  The 10-argument limit was removed as of ICU 2.6,
335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * rendering this constant obsolete.
336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kMaxFormat = 10
338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
339103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_OBSOLETE_API */
340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Constructs a new MessageFormat using the given pattern and the
343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * default locale.
344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pattern   Pattern used to construct object.
346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MessageFormat(const UnicodeString& pattern,
351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  UErrorCode &status);
352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Constructs a new MessageFormat using the given pattern and locale.
355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pattern   Pattern used to construct object.
356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param newLocale The locale to use for formatting dates and numbers.
357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MessageFormat(const UnicodeString& pattern,
362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  const Locale& newLocale,
363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        UErrorCode& status);
364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Constructs a new MessageFormat using the given pattern and locale.
366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pattern   Pattern used to construct object.
367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param newLocale The locale to use for formatting dates and numbers.
368b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param parseError Struct to receive information on the position
369b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                   of an error within the pattern.
370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MessageFormat(const UnicodeString& pattern,
375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  const Locale& newLocale,
376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  UParseError& parseError,
377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  UErrorCode& status);
378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Constructs a new MessageFormat from an existing one.
380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MessageFormat(const MessageFormat&);
383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Assignment operator.
386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const MessageFormat& operator=(const MessageFormat&);
389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Destructor.
392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual ~MessageFormat();
395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Clones this Format object polymorphically.  The caller owns the
398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * result and should delete it when done.
399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual Format* clone(void) const;
402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns true if the given Format objects are semantically equal.
405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Objects of different subclasses are considered unequal.
406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param other  the object to be compared with.
407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       true if the given Format objects are semantically equal.
408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UBool operator==(const Format& other) const;
411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
413b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Sets the locale to be used for creating argument Format objects.
414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param theLocale    the new locale value to be set.
415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void setLocale(const Locale& theLocale);
418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
420b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Gets the locale used for creating argument Format objects.
421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * format information.
422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the locale of the object.
423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual const Locale& getLocale(void) const;
426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Applies the given pattern string to this message format.
429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pattern   The pattern to be applied.
431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void applyPattern(const UnicodeString& pattern,
436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                              UErrorCode& status);
437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Applies the given pattern string to this message format.
439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pattern    The pattern to be applied.
441b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param parseError Struct to receive information on the position
442b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                   of an error within the pattern.
443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void applyPattern(const UnicodeString& pattern,
448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             UParseError& parseError,
449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             UErrorCode& status);
450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
452b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Sets the UMessagePatternApostropheMode and the pattern used by this message format.
453b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Parses the pattern and caches Format objects for simple argument types.
454b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Patterns and their interpretation are specified in the
455b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * <a href="#patterns">class description</a>.
456b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * <p>
457b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * This method is best used only once on a given object to avoid confusion about the mode,
458b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * and after constructing the object with an empty pattern string to minimize overhead.
459b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *
460b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param pattern    The pattern to be applied.
461b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param aposMode   The new apostrophe mode.
462b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param parseError Struct to receive information on the position
463b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                   of an error within the pattern.
464b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                   Can be NULL.
465b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param status    Input/output error code.  If the
466b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                  pattern cannot be parsed, set to failure code.
467103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.8
468b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
469b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    virtual void applyPattern(const UnicodeString& pattern,
470b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                              UMessagePatternApostropheMode aposMode,
471b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                              UParseError* parseError,
472b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                              UErrorCode& status);
473b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
474b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    /**
475b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @return this instance's UMessagePatternApostropheMode.
476103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.8
477b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
478b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UMessagePatternApostropheMode getApostropheMode() const {
479b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        return msgPattern.getApostropheMode();
480b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    }
481b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
482b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    /**
483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns a pattern that can be used to recreate this object.
484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param appendTo  Output parameter to receive the pattern.
486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  Result is appended to existing contents.
487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          Reference to 'appendTo' parameter.
488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UnicodeString& toPattern(UnicodeString& appendTo) const;
491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets subformats.
494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * See the class description about format numbering.
495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The caller should not delete the Format objects after this call.
496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <EM>The array formatsToAdopt is not itself adopted.</EM> Its
497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * ownership is retained by the caller. If the call fails because
498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * memory cannot be allocated, then the formats will be deleted
499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * by this method, and this object will remain unchanged.
50050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
50150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * <p>If this format uses named arguments, the new formats are discarded
50250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * and this format remains unchanged.
50350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param formatsToAdopt    the format to be adopted.
506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count             the size of the array.
507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void adoptFormats(Format** formatsToAdopt, int32_t count);
509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets subformats.
512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * See the class description about format numbering.
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Each item in the array is cloned into the internal array.
514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * If the call fails because memory cannot be allocated, then this
515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * object will remain unchanged.
51650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
51750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * <p>If this format uses named arguments, the new formats are discarded
51850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * and this format remains unchanged.
51950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param newFormats the new format to be set.
522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param cnt        the size of the array.
523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
524c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    virtual void setFormats(const Format** newFormats, int32_t cnt);
525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets one subformat.
529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * See the class description about format numbering.
530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The caller should not delete the Format object after this call.
531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * If the number is over the number of formats already set,
532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the item will be deleted and ignored.
53350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
53450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * <p>If this format uses named arguments, the new format is discarded
53550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * and this format remains unchanged.
53650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param formatNumber     index of the subformat.
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param formatToAdopt    the format to be adopted.
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt);
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets one subformat.
545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * See the class description about format numbering.
546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * If the number is over the number of formats already set,
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the item will be ignored.
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param formatNumber     index of the subformat.
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param format    the format to be set.
550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void setFormat(int32_t formatNumber, const Format& format);
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
555c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * Gets format names. This function returns formatNames in StringEnumerations
55650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * which can be used with getFormat() and setFormat() to export formattable
557b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * array from current MessageFormat to another.  It is the caller's responsibility
558c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * to delete the returned formatNames.
559c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param status  output param set to success/failure code.
560b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @stable ICU 4.0
561c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     */
562c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    virtual StringEnumeration* getFormatNames(UErrorCode& status);
56350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
564c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
56550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Gets subformat pointer for given format name.
566c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * This function supports both named and numbered
567b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * arguments. If numbered, the formatName is the
568c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
569c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * The returned Format object should not be deleted by the caller,
57050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * nor should the ponter of other object .  The pointer and its
571c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * contents remain valid only until the next call to any method
57250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * of this class is made with this object.
573c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param formatName the name or number specifying a format
574c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param status  output param set to success/failure code.
575b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @stable ICU 4.0
576c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     */
577c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    virtual Format* getFormat(const UnicodeString& formatName, UErrorCode& status);
57850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
579c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
580c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * Sets one subformat for given format name.
58150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * See the class description about format name.
582c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * This function supports both named and numbered
583c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * arguments-- if numbered, the formatName is the
584c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
585c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * If there is no matched formatName or wrong type,
586c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * the item will be ignored.
587c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param formatName  Name of the subformat.
588c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param format      the format to be set.
589c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param status  output param set to success/failure code.
590b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @stable ICU 4.0
591c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     */
592c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    virtual void setFormat(const UnicodeString& formatName, const Format& format, UErrorCode& status);
59350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
594c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
595c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * Sets one subformat for given format name.
59650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * See the class description about format name.
597c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * This function supports both named and numbered
598c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * arguments-- if numbered, the formatName is the
599c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
600c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * If there is no matched formatName or wrong type,
601c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * the item will be ignored.
602c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * The caller should not delete the Format object after this call.
603c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param formatName  Name of the subformat.
604c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param formatToAdopt  Format to be adopted.
605c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param status      output param set to success/failure code.
606b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @stable ICU 4.0
607c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     */
608c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    virtual void adoptFormat(const UnicodeString& formatName, Format* formatToAdopt, UErrorCode& status);
609c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
610c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets an array of subformats of this object.  The returned array
612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * should not be deleted by the caller, nor should the pointers
613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * within the array.  The array and its contents remain valid only
61450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * until the next call to this format. See the class description
61550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * about format numbering.
61650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count output parameter to receive the size of the array
618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return an array of count Format* objects, or NULL if out of
619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * memory.  Any or all of the array elements may be NULL.
620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual const Format** getFormats(int32_t& count) const;
623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
62450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
62550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    using Format::format;
62650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Formats the given array of arguments into a user-readable string.
629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Does not take ownership of the Formattable* array or its contents.
630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
63150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * <p>If this format uses named arguments, appendTo is unchanged and
63250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * status is set to U_ILLEGAL_ARGUMENT_ERROR.
63350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param source    An array of objects to be formatted.
635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count     The number of elements of 'source'.
636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param appendTo  Output parameter to receive result.
637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  Result is appended to existing contents.
638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param ignore    Not used; inherited from base class API.
639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          Reference to 'appendTo' parameter.
642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
64450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    UnicodeString& format(const Formattable* source,
64550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                          int32_t count,
64650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                          UnicodeString& appendTo,
64750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                          FieldPosition& ignore,
64850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                          UErrorCode& status) const;
649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Formats the given array of arguments into a user-readable string
652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * using the given pattern.
653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
65450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * <p>If this format uses named arguments, appendTo is unchanged and
65550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * status is set to U_ILLEGAL_ARGUMENT_ERROR.
65650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pattern   The pattern.
658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param arguments An array of objects to be formatted.
659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count     The number of elements of 'source'.
660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param appendTo  Output parameter to receive result.
661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  Result is appended to existing contents.
662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          Reference to 'appendTo' parameter.
665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
667c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    static UnicodeString& format(const UnicodeString& pattern,
668c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                 const Formattable* arguments,
669c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                 int32_t count,
670c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                 UnicodeString& appendTo,
671c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                 UErrorCode& status);
672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Formats the given array of arguments into a user-readable
675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * string.  The array must be stored within a single Formattable
676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * object of type kArray. If the Formattable object type is not of
677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * type kArray, then returns a failing UErrorCode.
678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
67950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * <p>If this format uses named arguments, appendTo is unchanged and
68050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * status is set to U_ILLEGAL_ARGUMENT_ERROR.
68150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param obj       A Formattable of type kArray containing
683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  arguments to be formatted.
684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param appendTo  Output parameter to receive result.
685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  Result is appended to existing contents.
686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pos       On input: an alignment field, if desired.
687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  On output: the offsets of the alignment field.
688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          Reference to 'appendTo' parameter.
691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UnicodeString& format(const Formattable& obj,
694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                  UnicodeString& appendTo,
695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                  FieldPosition& pos,
696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                  UErrorCode& status) const;
697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Formats the given array of arguments into a user-readable
700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * string.  The array must be stored within a single Formattable
701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * object of type kArray. If the Formattable object type is not of
702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * type kArray, then returns a failing UErrorCode.
703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param obj       The object to format
705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param appendTo  Output parameter to receive result.
706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  Result is appended to existing contents.
707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          Reference to 'appendTo' parameter.
710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString& format(const Formattable& obj,
713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                          UnicodeString& appendTo,
714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                          UErrorCode& status) const;
71550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
718c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * Formats the given array of arguments into a user-defined argument name
719c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * array. This function supports both named and numbered
720c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * arguments-- if numbered, the formatName is the
721c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
722c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     *
723c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param argumentNames argument name array
724c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param arguments An array of objects to be formatted.
72550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param count     The number of elements of 'argumentNames' and
726c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     *                  arguments.  The number of argumentNames and arguments
727c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     *                  must be the same.
728c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param appendTo  Output parameter to receive result.
729c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     *                  Result is appended to existing contents.
730c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @param status    Input/output error code.  If the
731c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     *                  pattern cannot be parsed, set to failure code.
732c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @return          Reference to 'appendTo' parameter.
733c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @stable ICU 4.0
734c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     */
735c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UnicodeString& format(const UnicodeString* argumentNames,
736c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                          const Formattable* arguments,
737c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                          int32_t count,
738c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                          UnicodeString& appendTo,
739c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                          UErrorCode& status) const;
740c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Parses the given string into an array of output arguments.
742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param source    String to be parsed.
744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pos       On input, starting position for parse. On output,
745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  final position after parse.  Unchanged if parse
746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  fails.
747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count     Output parameter to receive the number of arguments
748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  parsed.
749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return an array of parsed arguments.  The caller owns both
750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the array and its contents.
751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
75350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    virtual Formattable* parse(const UnicodeString& source,
75450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                               ParsePosition& pos,
75550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                               int32_t& count) const;
756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Parses the given string into an array of output arguments.
759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
76050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * <p>If this format uses named arguments, status is set to
76150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * U_ARGUMENT_TYPE_MISMATCH.
76250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param source    String to be parsed.
764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count     Output param to receive size of returned array.
765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the
76650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *                  pattern cannot be parsed, set to failure code.
767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return an array of parsed arguments.  The caller owns both
76850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * the array and its contents. Returns NULL if status is not U_ZERO_ERROR.
76950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
77250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    virtual Formattable* parse(const UnicodeString& source,
77350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                               int32_t& count,
77450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                               UErrorCode& status) const;
775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Parses the given string into an array of output arguments
778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * stored within a single Formattable of type kArray.
779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param source    The string to be parsed into an object.
781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param result    Formattable to be set to the parse result.
782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  If parse fails, return contents are undefined.
783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pos       On input, starting position for parse. On output,
784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  final position after parse.  Unchanged if parse
785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  fails.
786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void parseObject(const UnicodeString& source,
789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             Formattable& result,
790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             ParsePosition& pos) const;
791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Convert an 'apostrophe-friendly' pattern into a standard
794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * pattern.  Standard patterns treat all apostrophes as
79550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * quotes, which is problematic in some languages, e.g.
796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * French, where apostrophe is commonly used.  This utility
797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * assumes that only an unpaired apostrophe immediately before
798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * a brace is a true quote.  Other unpaired apostrophes are paired,
799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * and the resulting standard pattern string is returned.
800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p><b>Note</b> it is not guaranteed that the returned pattern
802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * is indeed a valid pattern.  The only effect is to convert
803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * between patterns having different quoting semantics.
804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param pattern the 'apostrophe-friendly' patttern to convert
806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    Input/output error code.  If the pattern
807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  cannot be parsed, the failure code is set.
808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the standard equivalent of the original pattern
809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
81150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    static UnicodeString autoQuoteApostrophe(const UnicodeString& pattern,
812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UErrorCode& status);
81350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
814b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
815c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
816c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * Returns true if this MessageFormat uses named arguments,
817c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * and false otherwise.  See class description.
818c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     *
819c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     * @return true if named arguments are used.
820b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @stable ICU 4.0
821c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     */
822c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UBool usesNamedArguments() const;
82350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
824b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru
825103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
826b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    /**
827b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * This API is for ICU internal use only.
828b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * Please do not use it.
829b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     *
830b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * Returns argument types count in the parsed pattern.
831b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * Used to distinguish pattern "{0} d" and "d".
832b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     *
833b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @return           The number of formattable types in the pattern
834b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @internal
835b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     */
836b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    int32_t getArgTypeCount() const;
837103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
838b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru
839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This method is to implement a simple version of RTTI, since not all
842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * clone() methods call this method.
844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          The class ID for this object. All objects of a
846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  given class have the same class ID.  Objects of
847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                  other classes have different class IDs.
848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UClassID getDynamicClassID(void) const;
851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the class ID for this class.  This is useful only for
854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * comparing to a return value from getDynamicClassID().  For example:
855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <pre>
856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * .   Base* polymorphic_pointer = createPolymorphicObject();
857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * .   if (polymorphic_pointer->getDynamicClassID() ==
858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * .      Derived::getStaticClassID()) ...
859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * </pre>
860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          The class ID for all objects of this class.
861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static UClassID U_EXPORT2 getStaticClassID(void);
86450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
865103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
866b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    /**
867b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Compares two Format objects. This is used for constructing the hash
868b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * tables.
869b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *
870b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param left pointer to a Format object. Must not be NULL.
871b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param right pointer to a Format object. Must not be NULL.
872b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *
873b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @return whether the two objects are the same
874b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @internal
875b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
876b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    static UBool equalFormats(const void* left, const void* right);
877103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
878b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprivate:
880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale              fLocale;
882b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    MessagePattern      msgPattern;
883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Format**            formatAliases; // see getFormats
884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t             formatAliasesCapacity;
885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MessageFormat(); // default constructor not implemented
887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
888b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     /**
889b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho      * This provider helps defer instantiation of a PluralRules object
890b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho      * until we actually need to select a keyword.
891b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho      * For example, if the number matches an explicit-value selector like "=1"
892b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho      * we do not need any PluralRules.
893b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho      */
894b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    class U_I18N_API PluralSelectorProvider : public PluralFormat::PluralSelector {
895b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    public:
89654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius        PluralSelectorProvider(const Locale* loc, UPluralType type);
897b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        virtual ~PluralSelectorProvider();
898b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        virtual UnicodeString select(double number, UErrorCode& ec) const;
899b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
900b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        void reset(const Locale* loc);
901b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    private:
902b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        const Locale* locale;
903b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        PluralRules* rules;
90454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius        UPluralType type;
905b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    };
906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * A MessageFormat formats an array of arguments.  Each argument
909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * has an expected type, based on the pattern.  For example, if
910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the pattern contains the subformat "{3,number,integer}", then
911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * we expect argument 3 to have type Formattable::kLong.  This
912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * array needs to grow dynamically if the MessageFormat is
913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * modified.
914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable::Type* argTypes;
916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t            argTypeCount;
917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t            argTypeCapacity;
918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
919c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
920b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * TRUE if there are different argTypes for the same argument.
921b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * This only matters when the MessageFormat is used in the plain C (umsg_xxx) API
922b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * where the pattern argTypes determine how the va_arg list is read.
923b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
924b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UBool hasArgTypeConflicts;
925c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Variable-size array management
927b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UBool allocateArgTypes(int32_t capacity, UErrorCode& status);
928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Default Format objects used when no format is specified and a
931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * numeric or date argument is formatted.  These are volatile
932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * cache objects maintained only for performance.  They do not
933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * participate in operator=(), copy constructor(), nor
934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * operator==().
935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    NumberFormat* defaultNumberFormat;
937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    DateFormat*   defaultDateFormat;
938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
939b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UHashtable* cachedFormatters;
940b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UHashtable* customFormatArgStarts;
941b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
942b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    PluralSelectorProvider pluralProvider;
94354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius    PluralSelectorProvider ordinalProvider;
944b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Method to retrieve default formats (or NULL on failure).
947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * These are semantically const, but may modify *this.
948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const NumberFormat* getDefaultNumberFormat(UErrorCode&) const;
950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const DateFormat*   getDefaultDateFormat(UErrorCode&) const;
951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Finds the word s, in the keyword list and returns the located index.
954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param s the keyword to be searched for.
955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param list the list of keywords to be searched with.
956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the index of the list which matches the keyword s.
957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static int32_t findKeyword( const UnicodeString& s,
959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                const UChar * const *list);
960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
962b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Thin wrapper around the format(... AppendableWrapper ...) variant.
963b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Wraps the destination UnicodeString into an AppendableWrapper and
964b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * supplies default values for some other parameters.
965b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
966b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UnicodeString& format(const Formattable* arguments,
967b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                          const UnicodeString *argumentNames,
968b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                          int32_t cnt,
969b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                          UnicodeString& appendTo,
970b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                          FieldPosition* pos,
971b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                          UErrorCode& status) const;
972b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
973b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    /**
974b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Formats the arguments and writes the result into the
975b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * AppendableWrapper, updates the field position.
976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
977b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param msgStart      Index to msgPattern part to start formatting from.
978b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param pluralNumber  Zero except when formatting a plural argument sub-message
979b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                      where a '#' is replaced by the format string for this number.
980b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param arguments     The formattable objects array. (Must not be NULL.)
981b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param argumentNames NULL if numbered values are used. Otherwise the same
982b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                      length as "arguments", and each entry is the name of the
983b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                      corresponding argument in "arguments".
984b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param cnt           The length of arguments (and of argumentNames if that is not NULL).
985b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param appendTo      Output parameter to receive the result.
986b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     *                      The result string is appended to existing contents.
987b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param pos           Field position status.
988b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param success       The error code status.
989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
990b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void format(int32_t msgStart,
991b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                double pluralNumber,
992b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                const Formattable* arguments,
993b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                const UnicodeString *argumentNames,
994b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                int32_t cnt,
995b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                AppendableWrapper& appendTo,
996b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                FieldPosition* pos,
997b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                UErrorCode& success) const;
998b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
999b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UnicodeString getArgName(int32_t partIndex);
1000b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1001b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void setArgStartFormat(int32_t argStart, Format* formatter, UErrorCode& status);
1002b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1003b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void setCustomArgStartFormat(int32_t argStart, Format* formatter, UErrorCode& status);
1004b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1005b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    int32_t nextTopLevelArgStart(int32_t partIndex) const;
1006b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1007b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UBool argNameMatches(int32_t partIndex, const UnicodeString& argName, int32_t argNumber);
1008b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1009b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void cacheExplicitFormats(UErrorCode& status);
1010b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1011b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    Format* createAppropriateFormat(UnicodeString& type,
1012b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                    UnicodeString& style,
1013b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                    Formattable::Type& formattableType,
1014b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                    UParseError& parseError,
1015b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                    UErrorCode& ec);
1016b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1017b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    const Formattable* getArgFromListByName(const Formattable* arguments,
1018b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                            const UnicodeString *argumentNames,
1019b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                            int32_t cnt, UnicodeString& name) const;
1020b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1021b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    Formattable* parse(int32_t msgStart,
1022b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                       const UnicodeString& source,
1023b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                       ParsePosition& pos,
1024b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                       int32_t& count,
1025b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                       UErrorCode& ec) const;
1026b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1027b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    FieldPosition* updateMetaData(AppendableWrapper& dest, int32_t prevLength,
1028b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                  FieldPosition* fp, const Formattable* argId) const;
102950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
1030b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    Format* getCachedFormatter(int32_t argumentNumber) const;
1031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1032b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    UnicodeString getLiteralStringUntilNextArgument(int32_t from) const;
1033b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1034b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void copyObjects(const MessageFormat& that, UErrorCode& ec);
1035b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1036b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void formatComplexSubMessage(int32_t msgStart,
1037b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 double pluralNumber,
1038b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 const Formattable* arguments,
1039b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 const UnicodeString *argumentNames,
1040b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 int32_t cnt,
1041b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 AppendableWrapper& appendTo,
1042b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 UErrorCode& success) const;
1043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Convenience method that ought to be in NumberFormat
1046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    NumberFormat* createIntegerFormat(const Locale& locale, UErrorCode& status) const;
1048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
105050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Returns array of argument types in the parsed pattern
1051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * for use in C API.  Only for the use of umsg_vformat().  Not
1052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * for public consumption.
1053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param listCount  Output parameter to receive the size of array
1054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return           The array of formattable types in the pattern
1055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const Formattable::Type* getArgTypeList(int32_t& listCount) const {
1058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        listCount = argTypeCount;
105950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        return argTypes;
1060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
106150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
1062c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    /**
1063b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Resets the internal MessagePattern, and other associated caches.
1064c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru     */
1065b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void resetPattern();
1066b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1067b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    /**
1068b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * A DummyFormatter that we use solely to store a NULL value. UHash does
1069b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * not support storing NULL values.
1070b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @internal
1071b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
1072b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    class U_I18N_API DummyFormat : public Format {
1073b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    public:
10748393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius        using Format::format;
1075b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        virtual UBool operator==(const Format&) const;
1076b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        virtual Format* clone() const;
107754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius        virtual UnicodeString& format(const Formattable& obj,
107854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius                              UnicodeString& appendTo,
107954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius                              UErrorCode& status) const;
1080b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        virtual UnicodeString& format(const Formattable&,
1081b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                      UnicodeString& appendTo,
1082b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                      FieldPosition&,
1083b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                      UErrorCode& status) const;
108454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius        virtual UnicodeString& format(const Formattable& obj,
108554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius                                      UnicodeString& appendTo,
108654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius                                      FieldPositionIterator* posIter,
108754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius                                      UErrorCode& status) const;
1088b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        virtual void parseObject(const UnicodeString&,
1089b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 Formattable&,
1090b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                                 ParsePosition&) const;
1091b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    };
109250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
1093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    friend class MessageFormatAdapter; // getFormatTypeList() access
1094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
1095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString&
1097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruMessageFormat::format(const Formattable& obj,
1098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                      UnicodeString& appendTo,
1099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                      UErrorCode& status) const {
1100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return Format::format(obj, appendTo, status);
1101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
110250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
1103b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
1104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_END
1105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_FORMATTING */
1107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif // _MSGFMT
1109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//eof
1110