class U_I18N_API MessageFormat : public Format

Provides means to produce concatenated messages in language-neutral way

Inheritance:


Public Fields

static const Locale ENGLISH
Useful constants for language
static const Locale FRANCE
Useful constants for country

Public Methods

Locale()
Construct an empty locale
Locale( const UnicodeString& language, const UnicodeString& country, const UnicodeString& variant )
Construct a locale from language, country, variant
Locale(const Locale& other)
Initializes a Locale object from another Locale object
~Locale()
Destructor
Locale& operator=(const Locale& other)
Replaces the entire contents of *this with the specified value
bool_t operator==(const Locale& other) const
Checks if two locale keys are the same
bool_t operator!=(const Locale& other) const
Checks if two locale keys are not the same
static Locale& getDefault(void)
Common methods of getting the current default Locale
static void setDefault(const Locale& newLocale, UErrorCode& success)
Sets the default
UnicodeString& getLanguage( UnicodeString& lang) const
Fills in "lang" with the locale's two-letter ISO-639 language code
UnicodeString& getCountry( UnicodeString& cntry) const
Fills in "cntry" with the locale's two-letter ISO-3166 country code
UnicodeString& getVariant( UnicodeString& var) const
Fills in "var" with the locale's variant code
UnicodeString& getName( UnicodeString& name) const
Fills in "name" the programmatic name of the entire locale, with the language, country and variant separated by underbars
UnicodeString& getISO3Language(UnicodeString& name, UErrorCode& status) const
Fills in "name" with the locale's three-letter language code, as specified in ISO draft standard ISO-639-2
UnicodeString& getISO3Country( UnicodeString& name, UErrorCode& status) const
Fills in "name" with the locale's three-letter ISO-3166 country code
uint32_t getLCID(void) const
Returns the Windows LCID value corresponding to this locale
UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const
Fills in "dispLang" with the name of this locale's language in a format suitable for user display in the default locale
UnicodeString& getDisplayLanguage( const Locale& inLocale, UnicodeString& dispLang) const
Fills in "dispLang" with the name of this locale's language in a format suitable for user display in the locale specified by "inLocale"
UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const
Fills in "dispCountry" with the name of this locale's country in a format suitable for user display in the default locale
UnicodeString& getDisplayCountry( const Locale& inLocale, UnicodeString& dispCountry) const
Fills in "dispCountry" with the name of this locale's country in a format suitable for user display in the locale specified by "inLocale"
UnicodeString& getDisplayVariant( UnicodeString& dispVar) const
Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the default locale
UnicodeString& getDisplayVariant( const Locale& inLocale, UnicodeString& dispVar) const
Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the locale specified by "inLocale"
UnicodeString& getDisplayName( UnicodeString& name) const
Fills in "name" with the name of this locale in a format suitable for user display in the default locale
UnicodeString& getDisplayName( const Locale& inLocale, UnicodeString& name) const
Fills in "name" with the name of this locale in a format suitable for user display in the locale specfied by "inLocale"
int32_t hashCode(void) const
Generates a hash code for the locale
static const Locale* getAvailableLocales(int32_t& count)
Returns a list of all installed locales
static const UnicodeString* getISOCountries(int32_t& count)
Returns a list of all 2-letter country codes defined in ISO 3166
static const UnicodeString* getISOLanguages(int32_t& count)
Returns a list of all 2-letter language codes defined in ISO 639
static const char* getDataDirectory(void)
Get the path to the ResourceBundle locale files
static void setDataDirectory(const char* path)
Set the path to the ResourceBundle locale files
MessageFormat(const UnicodeString& pattern, UErrorCode &status)
Construct a new MessageFormat using the given pattern
MessageFormat(const UnicodeString& pattern, const Locale& newLocale, UErrorCode& success)
Constructor that allows locale specification
MessageFormat(const MessageFormat&)
Copy constructor
const MessageFormat& operator=(const MessageFormat&)
Assignment operator
virtual ~MessageFormat()
Destructor
virtual Format* clone(void) const
Clone this Format object polymorphically
virtual bool_t operator==(const Format& other) const
Return true if the given Format objects are semantically equal
virtual void setLocale(const Locale& theLocale)
Sets the locale
virtual const Locale& getLocale(void) const
Gets the locale
virtual void applyPattern(const UnicodeString& pattern, UErrorCode& status)
Apply the given pattern string to this message format
virtual UnicodeString& toPattern(UnicodeString& result) const
Gets the pattern
virtual void adoptFormats(Format** formatsToAdopt, int32_t count)
Sets formats to use on parameters
virtual void setFormats(const Format** newFormats, int32_t cnt)
Sets formats to use on parameters
virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt)
Sets formats individually to use on parameters
virtual void setFormat(int32_t variable, const Format& newFormat)
Sets formats individually to use on parameters
virtual const Format** getFormats(int32_t& count) const
Gets formats that were set with setFormats
UnicodeString& format( const Formattable* source, int32_t count, UnicodeString& result, FieldPosition& ignore, UErrorCode& success) const
Returns pattern with formatted objects
static UnicodeString& format( const UnicodeString& pattern, const Formattable* arguments, int32_t count, UnicodeString& result, UErrorCode& success)
Convenience routine
virtual UnicodeString& format(const Formattable& obj, UnicodeString& toAppendTo, FieldPosition& pos, UErrorCode& status) const
Format an object to produce a message
UnicodeString& format(const Formattable& obj, UnicodeString& result, UErrorCode& status) const
Redeclared Format method
virtual Formattable* parse( const UnicodeString& source, ParsePosition& status, int32_t& count) const
Parses the string
virtual Formattable* parse( const UnicodeString& source, int32_t& count, UErrorCode& status) const
Parses the string
virtual void parseObject(const UnicodeString& source, Formattable& result, ParsePosition& parse_pos) const
Parse a string to produce an object
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY
static UClassID getStaticClassID(void)
Return the class ID for this class

Protected Methods

static const UnicodeString* getLanguagesForCountry( const UnicodeString& country, int32_t& count)
Given an ISO country code, returns an array of Strings containing the ISO codes of the languages spoken in that country

Inherited from Format:


Documentation

Provides means to produce concatenated messages in language-neutral way. Use this for all concatenations that show up to end users.

Takes a set of objects, formats them, then inserts the formatted strings into the pattern at the appropriate places.

Here are some examples of usage: Example 1:

.    UErrorCode success = U_ZERO_ERROR;
.    GregorianCalendar cal(success);
.    Formattable arguments[] = {
.        7L,
.        Formattable( (Date) cal.getTime(success), Formattable::kIsDate),
.        "a disturbance in the Force"
.    };
.    
.    UnicodeString result;
.    MessageFormat::format(
.         "At {1,time} on {1,date}, there was {2} on planet {0,number}.",
.         arguments, 3, result, success );
.    
.    cout << "result: " << result << endl;
.    //<output>: At 4:34:20 PM on 23-Mar-98, there was a disturbance
.    //             in the Force on planet 7.
Typically, the message format will come from resources, and the arguments will be dynamically set at runtime.

Example 2:

.    success = U_ZERO_ERROR;
.    Formattable testArgs[] = {3L, "MyDisk"};
.   
.    MessageFormat* form = new MessageFormat(
.        "The disk \"{1}\" contains {0} file(s).", success );
.        
.    UnicodeString string;
.    FieldPosition fpos = 0;
.    cout << "format: " << form->format(testArgs, 2, string, fpos, success ) << endl;
.
.    // output, with different testArgs:
.    // output: The disk "MyDisk" contains 0 file(s).
.    // output: The disk "MyDisk" contains 1 file(s).
.    // output: The disk "MyDisk" contains 1,273 file(s).
.    de lete form;
The pattern is of the following form. Legend:
.      {optional item}
.      (group that may be repeated)*
Do not confuse optional items with items inside quotes braces, such as this: "{". Quoted braces are literals.
.      messageFormatPattern := string ( "{" messageFormatElement "}" string )*
.       
.      messageFormatElement := argument { "," elementFormat }
.       
.      elementFormat := "time" { "," datetimeStyle }
.                     | "date" { "," datetimeStyle }
.                     | "number" { "," numberStyle }
.                     | "choice" "," choiceStyle
.  
.      datetimeStyle := "short"
.                     | "medium"
.                     | "long"
.                     | "full"
.                     | dateFormatPattern
.
.      numberStyle :=   "currency"
.                     | "percent"
.                     | "integer"
.                     | numberFormatPattern
. 
.      choiceStyle :=   choiceFormatPattern
If there is no elementFormat, then the argument must be a string, which is substituted. If there is no dateTimeStyle or numberStyle, then the default format is used (e.g. NumberFormat.getInstance(), DateFormat.getDefaultTime() or DateFormat.getDefaultDate(). For a ChoiceFormat, the pattern must always be specified, since there is no default.

In strings, single quotes can be used to quote the "{" sign if necessary. A real single quote is represented by ''. Inside a messageFormatElement, quotes are [not] removed. For example, {1,number,$'#',##} will produce a number format with the pound-sign quoted, with a result such as: "$#31,45".

If a pattern is used, then unquoted braces in the pattern, if any, must match: that is, "ab {0} de" and "ab '}' de" are ok, but "ab {0'}' de" and "ab } de" are not.

The argument is a number from 0 to 9, which corresponds to the arguments presented in an array to be formatted.

It is ok to have unused arguments in the array. With missing arguments or arguments that are not of the right class for the specified format, a failing UErrorCode result is set.

For more sophisticated patterns, you can use a ChoiceFormat to get output such as:

.    UErrorCode success = U_ZERO_ERROR;
.    MessageFormat* form = new MessageFormat("The disk \"{1}\" contains {0}.", success);
.    double filelimits[] = {0,1,2};
.    UnicodeString filepart[] = {"no files","one file","{0,number} files"};
.    ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3);
.    form->setFormat(1, *fileform); // NOT zero, see below
.    
.    Formattable testArgs[] = {1273L, "MyDisk"};
.     
.    UnicodeString string;
.    FieldPosition fpos = 0;
.    cout << form->format(testArgs, 2, string, fpos, success) << endl;
.    
.    // output, with different testArgs
.    // output: The disk "MyDisk" contains no files.
.    // output: The disk "MyDisk" contains one file.
.    // output: The disk "MyDisk" contains 1,273 files.
You can either do this programmatically, as in the above example, or by using a pattern (see ChoiceFormat for more information) as in:
.   form->applyPattern(
.     "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.");

[Note:] As we see above, the string produced by a ChoiceFormat in MessageFormat is treated specially; occurances of '{' are used to indicated subformats, and cause recursion. If you create both a MessageFormat and ChoiceFormat programmatically (instead of using the string patterns), then be careful not to produce a format that recurses on itself, which will cause an infinite loop.

[Note:] Formats are numbered by order of variable in the string. This is [not] the same as the argument numbering!

.   For example: with "abc{2}def{3}ghi{0}...",
.   
.   format0 affects the first variable {2}
.   format1 affects the second variable {3}
.   format2 affects the second variable {0}
and so on.
static const Locale ENGLISH
Useful constants for language

static const Locale FRANCE
Useful constants for country

Locale()
Construct an empty locale. It's only used when a fill-in parameter is needed.

Locale( const UnicodeString& language, const UnicodeString& country, const UnicodeString& variant )
Construct a locale from language, country, variant.
Parameters:
language - Lowercase two-letter ISO-639 code.
country - Uppercase two-letter ISO-3166 code. (optional)
variant - Uppercase vendor and browser specific code. See class description. (optional)

Locale(const Locale& other)
Initializes a Locale object from another Locale object.
Parameters:
other - The Locale object being copied in.

~Locale()
Destructor

Locale& operator=(const Locale& other)
Replaces the entire contents of *this with the specified value.
Returns:
*this
Parameters:
other - The Locale object being copied in.

bool_t operator==(const Locale& other) const
Checks if two locale keys are the same.
Returns:
True if the two locale keys are the same, false otherwise.
Parameters:
other - The locale key object to be compared with this.

bool_t operator!=(const Locale& other) const
Checks if two locale keys are not the same.
Returns:
True if the two locale keys are not the same, false otherwise.
Parameters:
other - The locale key object to be compared with this.

static Locale& getDefault(void)
Common methods of getting the current default Locale. Used for the presentation: menus, dialogs, etc. Generally set once when your applet or application is initialized, then never reset. (If you do reset the default locale, you probably want to reload your GUI, so that the change is reflected in your interface.) More advanced programs will allow users to use different locales for different fields, e.g. in a spreadsheet. Note that the initial setting will match the host system.

static void setDefault(const Locale& newLocale, UErrorCode& success)
Sets the default. Normally set once at the beginning of applet or application, then never reset. setDefault does NOT reset the host locale.
Parameters:
newLocale - Locale to set to.

UnicodeString& getLanguage( UnicodeString& lang) const
Fills in "lang" with the locale's two-letter ISO-639 language code
Returns:
A reference to "lang".
Parameters:
lang - Receives the language code.

UnicodeString& getCountry( UnicodeString& cntry) const
Fills in "cntry" with the locale's two-letter ISO-3166 country code
Returns:
A reference to "cntry".
Parameters:
cntry - Receives the country code.

UnicodeString& getVariant( UnicodeString& var) const
Fills in "var" with the locale's variant code
Returns:
A reference to "var".
Parameters:
var - Receives the variant code.

UnicodeString& getName( UnicodeString& name) const
Fills in "name" the programmatic name of the entire locale, with the language, country and variant separated by underbars. If a field is missing, at most one underbar will occur. Example: "en", "de_DE", "en_US_WIN", "de_POSIX", "fr_MAC"
Returns:
A reference to "name".
Parameters:
var - Receives the programmatic locale name.

UnicodeString& getISO3Language(UnicodeString& name, UErrorCode& status) const
Fills in "name" with the locale's three-letter language code, as specified in ISO draft standard ISO-639-2..
Returns:
A reference to "name".
Parameters:
name - Receives the three-letter language code.
status - An UErrorCode to receive any MISSING_RESOURCE_ERRORs

UnicodeString& getISO3Country( UnicodeString& name, UErrorCode& status) const
Fills in "name" with the locale's three-letter ISO-3166 country code
Returns:
A reference to "name".
Parameters:
name - Receives the three-letter country code.
status - An UErrorCode to receive any MISSING_RESOURCE_ERRORs

uint32_t getLCID(void) const
Returns the Windows LCID value corresponding to this locale. This value is stored in the resource data for the locale as a one-to-four-digit hexadecimal number. If the resource is missing, in the wrong format, or there is no Windows LCID value that corresponds to this locale, returns 0.

UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const
Fills in "dispLang" with the name of this locale's language in a format suitable for user display in the default locale. For example, if the locale's language code is "fr" and the default locale's language code is "en", this function would set dispLang to "French".
Returns:
A reference to "dispLang".
Parameters:
dispLang - Receives the language's display name.

UnicodeString& getDisplayLanguage( const Locale& inLocale, UnicodeString& dispLang) const
Fills in "dispLang" with the name of this locale's language in a format suitable for user display in the locale specified by "inLocale". For example, if the locale's language code is "en" and inLocale's language code is "fr", this function would set dispLang to "Anglais".
Returns:
A reference to "dispLang".
Parameters:
inLocale - Specifies the locale to be used to display the name. In other words, if the locale's language code is "en", passing Locale::FRENCH for inLocale would result in "Anglais", while passing Locale::GERMAN for inLocale would result in "Englisch".
dispLang - Receives the language's display name.

UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const
Fills in "dispCountry" with the name of this locale's country in a format suitable for user display in the default locale. For example, if the locale's country code is "FR" and the default locale's language code is "en", this function would set dispCountry to "France".
Returns:
A reference to "dispCountry".
Parameters:
dispCountry - Receives the country's display name.

UnicodeString& getDisplayCountry( const Locale& inLocale, UnicodeString& dispCountry) const
Fills in "dispCountry" with the name of this locale's country in a format suitable for user display in the locale specified by "inLocale". For example, if the locale's country code is "US" and inLocale's language code is "fr", this function would set dispCountry to "Etats-Unis".
Returns:
A reference to "dispCountry".
Parameters:
inLocale - Specifies the locale to be used to display the name. In other words, if the locale's country code is "US", passing Locale::FRENCH for inLocale would result in "�tats-Unis", while passing Locale::GERMAN for inLocale would result in "Vereinigte Staaten".
dispCountry - Receives the country's display name.

UnicodeString& getDisplayVariant( UnicodeString& dispVar) const
Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the default locale
Returns:
A reference to "dispVar".
Parameters:
dispVar - Receives the variant's name.

UnicodeString& getDisplayVariant( const Locale& inLocale, UnicodeString& dispVar) const
Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the locale specified by "inLocale"
Returns:
A reference to "dispVar".
Parameters:
inLocale - Specifies the locale to be used to display the name.
dispVar - Receives the variant's display name.

UnicodeString& getDisplayName( UnicodeString& name) const
Fills in "name" with the name of this locale in a format suitable for user display in the default locale. This function uses getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display name in the format "language (country[,variant])". For example, if the default locale is en_US, then fr_FR's display name would be "French (France)", and es_MX_Traditional's display name would be "Spanish (Mexico,Traditional)".
Returns:
A reference to "name".
Parameters:
name - Receives the locale's display name.

UnicodeString& getDisplayName( const Locale& inLocale, UnicodeString& name) const
Fills in "name" with the name of this locale in a format suitable for user display in the locale specfied by "inLocale". This function uses getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display name in the format "language (country[,variant])". For example, if inLocale is fr_FR, then en_US's display name would be "Anglais (�tats-Unis)", and no_NO_NY's display name would be "norv�gien (Norv�ge,NY)".
Returns:
A reference to "name".
Parameters:
inLocale - Specifies the locale to be used to display the name.
name - Receives the locale's display name.

int32_t hashCode(void) const
Generates a hash code for the locale. Since Locales are often used in hashtables, caches the value for speed.

static const Locale* getAvailableLocales(int32_t& count)
Returns a list of all installed locales
Returns:
A pointer to an array of Locale objects. This array is the list of all locales with installed resource files. The called does NOT get ownership of this list, and must NOT delete it.
Parameters:
count - Receives the number of locales in the list.

static const UnicodeString* getISOCountries(int32_t& count)
Returns a list of all 2-letter country codes defined in ISO 3166. Can be used to create Locales.
Returns:
A pointer to an array of UnicodeString objects. The caller does NOT get ownership of this list, and must NOT delete it.
Parameters:
count - Receives the number of countries in the list.

static const UnicodeString* getISOLanguages(int32_t& count)
Returns a list of all 2-letter language codes defined in ISO 639. Can be used to create Locales. [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. The list this function returns includes both the new and the old codes for the languages whose codes have changed.]
Returns:
A pointer to an array of UnicodeString objects. The caller does NOT get ownership of this list, and must NOT delete it.
Parameters:
count - Receives the number of languages in the list.

static const char* getDataDirectory(void)
Get the path to the ResourceBundle locale files. This path will be a platform-specific path name ending in a directory separator, so that file names may be concatenated to it. This path may be changed by calling setDataDirectory(). If setDataDirectory() has not been called yet, getDataDirectory() will return a platform-dependent default path as specified by TPlatformUtilities::getDefaultDataDirectory().
Returns:
Current data path.

static void setDataDirectory(const char* path)
Set the path to the ResourceBundle locale files. After making this call, all objects in the Unicode Analytics package will read ResourceBundle data files in the specified directory in order to obtain locale data.
Parameters:
path - The new data path to be set to.

static const UnicodeString* getLanguagesForCountry( const UnicodeString& country, int32_t& count)
Given an ISO country code, returns an array of Strings containing the ISO codes of the languages spoken in that country. Official languages are listed in the returned table before unofficial languages, but other than that, the order of the returned list is indeterminate. If the value the user passes in for "country" is not a valid ISO 316 country code, or if we don't have language information for the specified country, this function returns an empty array. [This function is not currently part of Locale's API, but is needed in the implementation. We hope to add it to the API in a future release.]
Returns:
A pointer to an array of UnicodeString objects. The caller does NOT get ownership of this list, and must NOT delete it.
Parameters:
country - The ISO 2-letter country code of the desired country
count - Receives the number of languages in the list.

MessageFormat(const UnicodeString& pattern, UErrorCode &status)
Construct a new MessageFormat using the given pattern.
Parameters:
pattern - Pattern used to construct object.
status - Output param to receive success code. If the pattern cannot be parsed, set to failure code.

MessageFormat(const UnicodeString& pattern, const Locale& newLocale, UErrorCode& success)
Constructor that allows locale specification
Parameters:
pattern - Pattern used to construct object.
newLocale - The locale to use for formatting dates and numbers.
status - Output param to receive success code. If the pattern cannot be parsed, set to failure code.

MessageFormat(const MessageFormat&)
Copy constructor

const MessageFormat& operator=(const MessageFormat&)
Assignment operator

virtual ~MessageFormat()
Destructor

virtual Format* clone(void) const
Clone this Format object polymorphically. The caller owns the result and should delete it when done.

virtual bool_t operator==(const Format& other) const
Return true if the given Format objects are semantically equal. Objects of different subclasses are considered unequal.

virtual void setLocale(const Locale& theLocale)
Sets the locale. This locale is used for fetching default number or date format information.

virtual const Locale& getLocale(void) const
Gets the locale. This locale is used for fetching default number or date format information.

virtual void applyPattern(const UnicodeString& pattern, UErrorCode& status)
Apply the given pattern string to this message format.
Parameters:
pattern - The pattern to be applied.
status - Output param set to success/failure code on exit. If the pattern is invalid, this will be set to a failure result.

virtual UnicodeString& toPattern(UnicodeString& result) const
Gets the pattern. See the class description.

virtual void adoptFormats(Format** formatsToAdopt, int32_t count)
Sets formats to use on parameters. See the class description about format numbering. The caller should not delete the Format objects after this call.

virtual void setFormats(const Format** newFormats, int32_t cnt)
Sets formats to use on parameters. See the class description about format numbering.

virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt)
Sets formats individually to use on parameters. See the class description about format numbering. The caller should not delete the Format object after this call.

virtual void setFormat(int32_t variable, const Format& newFormat)
Sets formats individually to use on parameters. See the class description about format numbering.

virtual const Format** getFormats(int32_t& count) const
Gets formats that were set with setFormats. See the class description about format numbering.

UnicodeString& format( const Formattable* source, int32_t count, UnicodeString& result, FieldPosition& ignore, UErrorCode& success) const
Returns pattern with formatted objects. Does not take ownership of the Formattable* array; just reads it and uses it to generate the format string.
Parameters:
source - An array of objects to be formatted & substituted.
result - Where text is appended.
ignore - No useful status is returned.

static UnicodeString& format( const UnicodeString& pattern, const Formattable* arguments, int32_t count, UnicodeString& result, UErrorCode& success)
Convenience routine. Avoids explicit creation of MessageFormat, but doesn't allow future optimizations.

virtual UnicodeString& format(const Formattable& obj, UnicodeString& toAppendTo, FieldPosition& pos, UErrorCode& status) const
Format an object to produce a message. This method handles Formattable objects of type kArray. If the Formattable object type is not of type kArray, then it returns a failing UErrorCode.
Returns:
The value passed in as toAppendTo (this allows chaining, as with UnicodeString::append())
Parameters:
obj - The object to format
toAppendTo - Where the text is to be appended
pos - On input: an alignment field, if desired. On output: the offsets of the alignment field.
status - Output param filled with success/failure status.

UnicodeString& format(const Formattable& obj, UnicodeString& result, UErrorCode& status) const
Redeclared Format method

virtual Formattable* parse( const UnicodeString& source, ParsePosition& status, int32_t& count) const
Parses the string.

Caveats: The parse may fail in a number of circumstances. For example:

If one of the arguments does not occur in the pattern.

If the format of an argument is loses information, such as with a choice format where a large number formats to "many".

Does not yet handle recursion (where the substituted strings contain {n} references.)

Will not always find a match (or the correct match) if some part of the parse is ambiguous. For example, if the pattern "{1},{2}" is used with the string arguments {"a,b", "c"}, it will format as "a,b,c". When the result is parsed, it will return {"a", "b,c"}.

If a single argument is formatted twice in the string, then the later parse wins.

Parameters:
source - String to be parsed.
status - On input, starting position for parse. On output, final position after parse.
count - Output param to receive size of returned array. @result Array of Formattable objects, with length 'count', owned by the caller.

virtual Formattable* parse( const UnicodeString& source, int32_t& count, UErrorCode& status) const
Parses the string. Does not yet handle recursion (where the substituted strings contain {n} references.)
Parameters:
source - String to be parsed.
count - Output param to receive size of returned array.
status - Output param to receive success/error code. @result Array of Formattable objects, with length 'count', owned by the caller.

virtual void parseObject(const UnicodeString& source, Formattable& result, ParsePosition& parse_pos) const
Parse a string to produce an object. This methods handles parsing of message strings into arrays of Formattable objects. Does not yet handle recursion (where the substituted strings contain %n references.)

Before calling, set parse_pos.index to the offset you want to start parsing at in the source. After calling, parse_pos.index is the end of the text you parsed. If error occurs, index is unchanged.

When parsing, leading whitespace is discarded (with successful parse), while trailing whitespace is left as is.

See Format::parseObject() for more.

Returns:
A newly created Formattable* object, or NULL on failure. The caller owns this and should delete it when done.
Parameters:
source - The string to be parsed into an object.
result - Formattable to be set to the parse result. If parse fails, return contents are undefined.
parse_pos - The position to start parsing at. Upon return this param is set to the position after the last character successfully parsed. If the source is not parsed successfully, this param will remain unchanged.

virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.
Returns:
The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.

static UClassID getStaticClassID(void)
Return the class ID for this class. This is useful only for comparing to a return value from getDynamicClassID(). For example:
.   Base* polymorphic_pointer = createPolymorphicObject();
.   if (polymorphic_pointer->getDynamicClassID() ==
.      Derived::getStaticClassID()) ...
Returns:
The class ID for all objects of this class.


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de