ICU-7452 add using Xxx:format statements to all Format subclasses that override format
X-SVN-Rev: 27662
This commit is contained in:
parent
6058b10dea
commit
b9fb4a7858
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2004-2008, International Business Machines
|
||||
* Copyright (c) 2004-2010, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Alan Liu
|
||||
@ -62,6 +62,9 @@ class CurrencyFormat : public MeasureFormat {
|
||||
*/
|
||||
virtual Format* clone() const;
|
||||
|
||||
|
||||
using MeasureFormat::format;
|
||||
|
||||
/**
|
||||
* Override Format API.
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2009, International Business Machines Corporation and *
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
@ -18,7 +18,7 @@
|
||||
// *****************************************************************************
|
||||
// This file was generated from the java source file Format.java
|
||||
// *****************************************************************************
|
||||
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/*
|
||||
@ -96,10 +96,10 @@ Format::operator=(const Format& that)
|
||||
// -------------------------------------
|
||||
// Formats the obj and append the result in the buffer, toAppendTo.
|
||||
// This calls the actual implementation in the concrete subclasses.
|
||||
|
||||
|
||||
UnicodeString&
|
||||
Format::format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
Format::format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
if (U_FAILURE(status)) return toAppendTo;
|
||||
@ -116,7 +116,7 @@ Format::format(const Formattable& obj,
|
||||
UnicodeString&
|
||||
Format::format(const Formattable& /* unused obj */,
|
||||
UnicodeString& toAppendTo,
|
||||
FieldPositionIterator& /* unused posIter */,
|
||||
FieldPositionIterator* /* unused posIter */,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
if (!U_FAILURE(status)) {
|
||||
@ -126,12 +126,12 @@ Format::format(const Formattable& /* unused obj */,
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Parses the source string and create the corresponding
|
||||
// Parses the source string and create the corresponding
|
||||
// result object. Checks the parse position for errors.
|
||||
|
||||
|
||||
void
|
||||
Format::parseObject(const UnicodeString& source,
|
||||
Formattable& result,
|
||||
Format::parseObject(const UnicodeString& source,
|
||||
Formattable& result,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
if (U_FAILURE(status)) return;
|
||||
@ -142,7 +142,7 @@ Format::parseObject(const UnicodeString& source,
|
||||
status = U_INVALID_FORMAT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
UBool
|
||||
@ -166,7 +166,7 @@ void Format::syntaxError(const UnicodeString& pattern,
|
||||
UParseError& parseError) {
|
||||
parseError.offset = pos;
|
||||
parseError.line=0; // we are not using line number
|
||||
|
||||
|
||||
// for pre-context
|
||||
int32_t start = (pos < U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1
|
||||
/* subtract 1 so that we have room for null*/));
|
||||
@ -174,17 +174,17 @@ void Format::syntaxError(const UnicodeString& pattern,
|
||||
pattern.extract(start,stop-start,parseError.preContext,0);
|
||||
//null terminate the buffer
|
||||
parseError.preContext[stop-start] = 0;
|
||||
|
||||
|
||||
//for post-context
|
||||
start = pos+1;
|
||||
stop = ((pos+U_PARSE_CONTEXT_LEN)<=pattern.length()) ? (pos+(U_PARSE_CONTEXT_LEN-1)) :
|
||||
stop = ((pos+U_PARSE_CONTEXT_LEN)<=pattern.length()) ? (pos+(U_PARSE_CONTEXT_LEN-1)) :
|
||||
pattern.length();
|
||||
pattern.extract(start,stop-start,parseError.postContext,0);
|
||||
//null terminate the buffer
|
||||
parseError.postContext[stop-start]= 0;
|
||||
}
|
||||
|
||||
Locale
|
||||
Locale
|
||||
Format::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
|
||||
U_LOCALE_BASED(locBased, *this);
|
||||
return locBased.getLocale(type, status);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007-2009, International Business Machines Corporation and *
|
||||
* Copyright (C) 2007-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -11,10 +11,10 @@
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \file
|
||||
* \brief C++ API: Format and parse relative dates and times.
|
||||
*/
|
||||
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/datefmt.h"
|
||||
@ -28,11 +28,12 @@ class MessageFormat;
|
||||
struct URelativeString;
|
||||
|
||||
/**
|
||||
* This class is normally accessed using the kRelative or k...Relative values of EStyle as parameters to DateFormat::createDateInstance.
|
||||
*
|
||||
* Example:
|
||||
* This class is normally accessed using the kRelative or k...Relative values of EStyle as
|
||||
* parameters to DateFormat::createDateInstance.
|
||||
*
|
||||
* Example:
|
||||
* DateFormat *fullrelative = DateFormat::createDateInstance(DateFormat::kFullRelative, loc);
|
||||
*
|
||||
*
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
|
||||
@ -76,6 +77,9 @@ public:
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
|
||||
using DateFormat::format;
|
||||
|
||||
/**
|
||||
* Format a date or time, which is the standard millis since 24:00 GMT, Jan
|
||||
* 1, 1970. Overrides DateFormat pure virtual method.
|
||||
@ -137,7 +141,7 @@ public:
|
||||
*/
|
||||
virtual void parse( const UnicodeString& text,
|
||||
Calendar& cal,
|
||||
ParsePosition& pos) const;
|
||||
ParsePosition& pos) const;
|
||||
|
||||
/**
|
||||
* Parse a date/time string starting at the given parse position. For
|
||||
@ -218,38 +222,38 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
DateFormat *fDateFormat; // the held date format
|
||||
DateFormat *fDateFormat; // the held date format
|
||||
DateFormat *fTimeFormat; // the held time format
|
||||
MessageFormat *fCombinedFormat; // the {0} {1} format.
|
||||
|
||||
MessageFormat *fCombinedFormat; // the {0} {1} format.
|
||||
|
||||
UDateFormatStyle fDateStyle;
|
||||
UDateFormatStyle fTimeStyle;
|
||||
Locale fLocale;
|
||||
|
||||
|
||||
int32_t fDayMin; // day id of lowest #
|
||||
int32_t fDayMax; // day id of highest #
|
||||
int32_t fDatesLen; // Length of array
|
||||
URelativeString *fDates; // array of strings
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the string at a specific offset.
|
||||
* @param day day offset ( -1, 0, 1, etc.. )
|
||||
* @param len on output, length of string.
|
||||
* @param len on output, length of string.
|
||||
* @return the string, or NULL if none at that location.
|
||||
*/
|
||||
const UChar *getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Load the Date string array
|
||||
*/
|
||||
void loadDates(UErrorCode &status);
|
||||
|
||||
|
||||
/**
|
||||
* @return the number of days in "until-now"
|
||||
*/
|
||||
static int32_t dayDifference(Calendar &until, UErrorCode &status);
|
||||
|
||||
|
||||
/**
|
||||
* initializes fCalendar from parameters. Returns fCalendar as a convenience.
|
||||
* @param adoptZone Zone to be adopted, or NULL for TimeZone::createDefault().
|
||||
@ -259,7 +263,7 @@ private:
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
Calendar* initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status);
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2008, International Business Machines
|
||||
* Copyright (C) 1997-2010, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
@ -10,7 +10,7 @@
|
||||
*
|
||||
* Date Name Description
|
||||
* 02/19/97 aliu Converted from java.
|
||||
* 03/20/97 helena Finished first cut of implementation and got rid
|
||||
* 03/20/97 helena Finished first cut of implementation and got rid
|
||||
* of nextDouble/previousDouble and replaced with
|
||||
* boolean array.
|
||||
* 4/10/97 aliu Clean up. Modified to work on AIX.
|
||||
@ -18,17 +18,17 @@
|
||||
* 07/22/98 stephen Removed operator!= (implemented in Format)
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CHOICFMT_H
|
||||
#define CHOICFMT_H
|
||||
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \file
|
||||
* \brief C++ API: Choice Format.
|
||||
*/
|
||||
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/unistr.h"
|
||||
@ -48,32 +48,32 @@ class MessageFormat;
|
||||
* string. <code>ChoiceFormat</code> is generally used in a
|
||||
* <code>MessageFormat</code> for displaying grammatically correct
|
||||
* plurals such as "There are 2 files."</p>
|
||||
*
|
||||
*
|
||||
* <p>There are two methods of defining a <code>ChoiceFormat</code>; both
|
||||
* are equivalent. The first is by using a string pattern. This is the
|
||||
* preferred method in most cases. The second method is through direct
|
||||
* specification of the arrays that make up the
|
||||
* <code>ChoiceFormat</code>.</p>
|
||||
*
|
||||
*
|
||||
* <p><strong>Patterns</strong></p>
|
||||
*
|
||||
*
|
||||
* <p>In most cases, the preferred way to define a
|
||||
* <code>ChoiceFormat</code> is with a pattern. Here is an example of a
|
||||
* <code>ChoiceFormat</code> pattern:</p>
|
||||
*
|
||||
* \htmlonly<pre> 0≤are no files|1≤is one file|1<are many files</pre>\endhtmlonly
|
||||
*
|
||||
*
|
||||
* <p>or equivalently,</p>
|
||||
*
|
||||
*
|
||||
* \htmlonly<pre> 0#are no files|1#is one file|1<are many files</pre>\endhtmlonly
|
||||
*
|
||||
*
|
||||
* <p>The pattern consists of a number or <em>range specifiers</em>
|
||||
* separated by vertical bars '|' (U+007C). There is no
|
||||
* vertical bar after the last range. Each range specifier is of the
|
||||
* form:</p>
|
||||
*
|
||||
* \htmlonly<blockquote><em>Number Separator String</em></blockquote>\endhtmlonly
|
||||
*
|
||||
*
|
||||
* <p><em>Number</em> is a floating point number that can be parsed by a
|
||||
* default <code>NumberFormat</code> for the US locale. It gives the
|
||||
* lower limit of this range. The lower limit is either inclusive or
|
||||
@ -81,14 +81,14 @@ class MessageFormat;
|
||||
* given by the lower limit of the next range. The Unicode infinity
|
||||
* sign \htmlonly∞ \endhtmlonly (U+221E) is recognized for positive infinity. It may be preceded by
|
||||
* '-' (U+002D) to indicate negative infinity.</p>
|
||||
*
|
||||
*
|
||||
* <p><em>String</em> is the format string for this range, with special
|
||||
* characters enclosed in single quotes (<code>'The #
|
||||
* sign'</code>). Single quotes themselves are indicated by two single
|
||||
* quotes in a row (<code>'o''clock'</code>).</p>
|
||||
*
|
||||
*
|
||||
* <p><em>Separator</em> is one of the following single characters:
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li>\htmlonly'≤' \endhtmlonly (U+2264) or '#' (U+0023)
|
||||
* indicates that the lower limit given by <em>Number</em> is
|
||||
@ -103,15 +103,15 @@ class MessageFormat;
|
||||
* saying this is that the corresponding closure is
|
||||
* <code>TRUE</code>.
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <p>See below for more information about closures.</p>
|
||||
*
|
||||
*
|
||||
* <p><strong>Arrays</strong></p>
|
||||
*
|
||||
*
|
||||
* <p>A <code>ChoiceFormat</code> defining <code>n</code> intervals
|
||||
* (<code>n</code> >= 2) is specified by three arrays of
|
||||
* <code>n</code> items:
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>double limits[]</code> gives the start of each
|
||||
* interval. This must be a non-decreasing list of values, none of
|
||||
@ -127,19 +127,19 @@ class MessageFormat;
|
||||
* <li><code>UnicodeString formats[]</code> gives the string label
|
||||
* associated with each interval.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <p><strong>Formatting and Parsing</strong></p>
|
||||
*
|
||||
*
|
||||
* <p>During formatting, a number is converted to a
|
||||
* string. <code>ChoiceFormat</code> accomplishes this by mapping the
|
||||
* number to an interval using the following rule. Given a number
|
||||
* <code>X</code> and and index value <code>j</code> in the range
|
||||
* <code>0..n-1</code>, where <code>n</code> is the number of ranges:</p>
|
||||
*
|
||||
*
|
||||
* \htmlonly<blockquote>\endhtmlonly<code>X</code> matches <code>j</code> if and only if
|
||||
* <code>limit[j] <= X < limit[j+1]</code>
|
||||
* \htmlonly</blockquote>\endhtmlonly
|
||||
*
|
||||
*
|
||||
* <p>(This assumes that all closures are <code>FALSE</code>. If some
|
||||
* closures are <code>TRUE</code> then the relations must be changed to
|
||||
* <code><=</code> or <code><</code> as appropriate.) If there is
|
||||
@ -147,14 +147,14 @@ class MessageFormat;
|
||||
* whether the number is too low or too high. Once a number is mapped to
|
||||
* an interval <code>j</code>, the string <code>formats[j]</code> is
|
||||
* output.</p>
|
||||
*
|
||||
*
|
||||
* <p>During parsing, a string is converted to a
|
||||
* number. <code>ChoiceFormat</code> finds the element
|
||||
* <code>formats[j]</code> equal to the string, and returns
|
||||
* <code>limits[j]</code> as the parsed value.</p>
|
||||
*
|
||||
*
|
||||
* <p><strong>Notes</strong></p>
|
||||
*
|
||||
*
|
||||
* <p>The first limit value does not define a range boundary. For
|
||||
* example, in the pattern \htmlonly"<code>1.0#a|2.0#b</code>"\endhtmlonly, the
|
||||
* intervals are [-Inf, 2.0) and [2.0, +Inf]. It appears that the first
|
||||
@ -163,39 +163,39 @@ class MessageFormat;
|
||||
* [-Inf, 2.0). However, the first limit value <em>is</em> used during
|
||||
* formatting. In this example, <code>parse("a")</code> returns
|
||||
* 1.0.</p>
|
||||
*
|
||||
*
|
||||
* <p>There are no gaps between intervals and the entire number line is
|
||||
* covered. A <code>ChoiceFormat</code> maps <em>all</em> possible
|
||||
* double values to a finite set of intervals.</p>
|
||||
*
|
||||
*
|
||||
* <p>The non-number <code>NaN</code> is mapped to interval zero during
|
||||
* formatting.</p>
|
||||
*
|
||||
*
|
||||
* <p><strong>Examples</strong></p>
|
||||
*
|
||||
*
|
||||
* <p>Here is an example of two arrays that map the number
|
||||
* <code>1..7</code> to the English day of the week abbreviations
|
||||
* <code>Sun..Sat</code>. No closures array is given; this is the same as
|
||||
* specifying all closures to be <code>FALSE</code>.</p>
|
||||
*
|
||||
*
|
||||
* <pre> {1,2,3,4,5,6,7},
|
||||
* {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}</pre>
|
||||
*
|
||||
*
|
||||
* <p>Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1,
|
||||
* +Inf] to three strings. That is, the number line is split into three
|
||||
* ranges: x < 1.0, x = 1.0, and x > 1.0.</p>
|
||||
*
|
||||
*
|
||||
* <pre> {0, 1, 1},
|
||||
* {FALSE, FALSE, TRUE},
|
||||
* {"no files", "one file", "many files"}</pre>
|
||||
*
|
||||
*
|
||||
* <p>Here is a simple example that shows formatting and parsing: </p>
|
||||
*
|
||||
*
|
||||
* \code
|
||||
* #include <unicode/choicfmt.h>
|
||||
* #include <unicode/unistr.h>
|
||||
* #include <iostream.h>
|
||||
*
|
||||
*
|
||||
* int main(int argc, char *argv[]) {
|
||||
* double limits[] = {1,2,3,4,5,6,7};
|
||||
* UnicodeString monthNames[] = {
|
||||
@ -214,17 +214,17 @@ class MessageFormat;
|
||||
* return 0;
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
*
|
||||
* <p>Here is a more complex example using a <code>ChoiceFormat</code>
|
||||
* constructed from a pattern together with a
|
||||
* <code>MessageFormat</code>.</p>
|
||||
*
|
||||
*
|
||||
* \code
|
||||
* #include <unicode/choicfmt.h>
|
||||
* #include <unicode/msgfmt.h>
|
||||
* #include <unicode/unistr.h>
|
||||
* #include <iostream.h>
|
||||
*
|
||||
*
|
||||
* int main(int argc, char *argv[]) {
|
||||
* UErrorCode status = U_ZERO_ERROR;
|
||||
* double filelimits[] = {0,1,2};
|
||||
@ -280,7 +280,7 @@ public:
|
||||
* @param count Size of 'limits' and 'formats' arrays.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
|
||||
|
||||
ChoiceFormat(const double* limits,
|
||||
const UnicodeString* formats,
|
||||
int32_t count );
|
||||
@ -342,8 +342,8 @@ public:
|
||||
* Return true if the given Format objects are semantically equal.
|
||||
* Objects of different subclasses are considered unequal.
|
||||
*
|
||||
* @param other ChoiceFormat object to be compared
|
||||
* @return true if other is the same as this.
|
||||
* @param other ChoiceFormat object to be compared
|
||||
* @return true if other is the same as this.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
@ -362,7 +362,7 @@ public:
|
||||
/**
|
||||
* Sets the pattern.
|
||||
* @param pattern The pattern to be applied.
|
||||
* @param parseError Struct to recieve information on position
|
||||
* @param parseError Struct to recieve information on position
|
||||
* of error if an error is encountered
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit. If the pattern is invalid, this will be
|
||||
@ -374,7 +374,7 @@ public:
|
||||
UErrorCode& status);
|
||||
/**
|
||||
* Gets the pattern.
|
||||
*
|
||||
*
|
||||
* @param pattern Output param which will recieve the pattern
|
||||
* Previous contents are deleted.
|
||||
* @return A reference to 'pattern'
|
||||
@ -396,7 +396,7 @@ public:
|
||||
*/
|
||||
virtual void setChoices(const double* limitsToCopy,
|
||||
const UnicodeString* formatsToCopy,
|
||||
int32_t count );
|
||||
int32_t count );
|
||||
|
||||
/**
|
||||
* Set the choices to be used in formatting. See class description
|
||||
@ -420,7 +420,7 @@ public:
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual const double* getLimits(int32_t& count) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the limit booleans passed in the constructor. The caller
|
||||
* must not delete the result.
|
||||
@ -440,6 +440,9 @@ public:
|
||||
*/
|
||||
virtual const UnicodeString* getFormats(int32_t& count) const;
|
||||
|
||||
|
||||
using NumberFormat::format;
|
||||
|
||||
/**
|
||||
* Format a double or long number using this object's choices.
|
||||
*
|
||||
@ -494,7 +497,7 @@ public:
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param success Output param set to success/failure code on
|
||||
* exit.
|
||||
* exit.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
@ -513,13 +516,13 @@ public:
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit.
|
||||
* exit.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
@ -529,7 +532,7 @@ public:
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit.
|
||||
* exit.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
@ -586,7 +589,7 @@ public:
|
||||
virtual void parse(const UnicodeString& text,
|
||||
Formattable& result,
|
||||
ParsePosition& parsePosition) const;
|
||||
|
||||
|
||||
/**
|
||||
* Return a long if possible (e.g. within range LONG_MAX,
|
||||
* LONG_MAX], and with no decimals), otherwise a double. If
|
||||
@ -606,8 +609,8 @@ public:
|
||||
virtual void parse(const UnicodeString& text,
|
||||
Formattable& result,
|
||||
UErrorCode& status) const;
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override.
|
||||
@ -639,7 +642,7 @@ private:
|
||||
// static cache management (thread-safe)
|
||||
// static NumberFormat* getNumberFormat(UErrorCode &status); // call this function to 'check out' a numberformat from the cache.
|
||||
// static void releaseNumberFormat(NumberFormat *adopt); // call this function to 'return' the number format to the cache.
|
||||
|
||||
|
||||
/**
|
||||
* Converts a string to a double value using a default NumberFormat object
|
||||
* which is static (shared by all ChoiceFormat instances).
|
||||
@ -664,7 +667,7 @@ private:
|
||||
* based on the pattern.
|
||||
*
|
||||
* @param newPattern Pattern used to construct object.
|
||||
* @param parseError Struct to recieve information on position
|
||||
* @param parseError Struct to recieve information on position
|
||||
* of error if an error is encountered.
|
||||
* @param status Output param to receive success code. If the
|
||||
* pattern cannot be parsed, set to failure code.
|
||||
@ -717,7 +720,7 @@ private:
|
||||
UnicodeString* fChoiceFormats;
|
||||
int32_t fCount;
|
||||
};
|
||||
|
||||
|
||||
inline UnicodeString&
|
||||
ChoiceFormat::format(const Formattable& obj,
|
||||
UnicodeString& appendTo,
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "unicode/locid.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \file
|
||||
* \brief C++ API: Abstract class for converting dates.
|
||||
*/
|
||||
|
||||
@ -141,7 +141,7 @@ public:
|
||||
/**
|
||||
* Constants for various style patterns. These reflect the order of items in
|
||||
* the DateTimePatterns resource. There are 4 time patterns, 4 date patterns,
|
||||
* the default date-time pattern, and 4 date-time patterns. Each block of 4 values
|
||||
* the default date-time pattern, and 4 date-time patterns. Each block of 4 values
|
||||
* in the resource occurs in the order full, long, medium, short.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
@ -171,15 +171,15 @@ public:
|
||||
|
||||
// relative dates
|
||||
kRelative = (1 << 7),
|
||||
|
||||
|
||||
kFullRelative = (kFull | kRelative),
|
||||
|
||||
|
||||
kLongRelative = kLong | kRelative,
|
||||
|
||||
|
||||
kMediumRelative = kMedium | kRelative,
|
||||
|
||||
|
||||
kShortRelative = kShort | kRelative,
|
||||
|
||||
|
||||
|
||||
kDefault = kMedium,
|
||||
|
||||
@ -211,6 +211,9 @@ public:
|
||||
*/
|
||||
virtual UBool operator==(const Format&) const;
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Format an object to produce a string. This method handles Formattable
|
||||
* objects with a UDate type. If a the Formattable object type is not a Date,
|
||||
|
@ -823,6 +823,9 @@ public:
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
|
||||
using NumberFormat::format;
|
||||
|
||||
/**
|
||||
* Format a double or long number using base-10 representation.
|
||||
*
|
||||
@ -833,7 +836,7 @@ public:
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
*/
|
||||
virtual UnicodeString& format(double number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
|
@ -1,5 +1,6 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2008-2010, International Business Machines Corporation and others. All Rights Reserved.
|
||||
* Copyright (C) 2008-2010, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*
|
||||
* File DTITVFMT.H
|
||||
@ -14,10 +15,10 @@
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \file
|
||||
* \brief C++ API: Format and parse date interval in a language-independent manner.
|
||||
*/
|
||||
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/ucal.h"
|
||||
@ -31,8 +32,8 @@ U_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* DateIntervalFormat is a class for formatting and parsing date
|
||||
* intervals in a language-independent manner.
|
||||
* DateIntervalFormat is a class for formatting and parsing date
|
||||
* intervals in a language-independent manner.
|
||||
* Date interval formatting is supported in Gregorian calendar only.
|
||||
* And only formatting is supported. Parsing is not supported.
|
||||
*
|
||||
@ -40,26 +41,26 @@ U_NAMESPACE_BEGIN
|
||||
* Date interval means from one date to another date,
|
||||
* for example, from "Jan 11, 2008" to "Jan 18, 2008".
|
||||
* We introduced class DateInterval to represent it.
|
||||
* DateInterval is a pair of UDate, which is
|
||||
* DateInterval is a pair of UDate, which is
|
||||
* the standard milliseconds since 24:00 GMT, Jan 1, 1970.
|
||||
*
|
||||
* <P>
|
||||
* DateIntervalFormat formats a DateInterval into
|
||||
* text as compactly as possible.
|
||||
* text as compactly as possible.
|
||||
* For example, the date interval format from "Jan 11, 2008" to "Jan 18,. 2008"
|
||||
* is "Jan 11-18, 2008" for English.
|
||||
* And it parses text into DateInterval,
|
||||
* although initially, parsing is not supported.
|
||||
* And it parses text into DateInterval,
|
||||
* although initially, parsing is not supported.
|
||||
*
|
||||
* <P>
|
||||
* There is no structural information in date time patterns.
|
||||
* For any punctuations and string literals inside a date time pattern,
|
||||
* we do not know whether it is just a separator, or a prefix, or a suffix.
|
||||
* Without such information, so, it is difficult to generate a sub-pattern
|
||||
* There is no structural information in date time patterns.
|
||||
* For any punctuations and string literals inside a date time pattern,
|
||||
* we do not know whether it is just a separator, or a prefix, or a suffix.
|
||||
* Without such information, so, it is difficult to generate a sub-pattern
|
||||
* (or super-pattern) by algorithm.
|
||||
* So, formatting a DateInterval is pattern-driven. It is very
|
||||
* similar to formatting in SimpleDateFormat.
|
||||
* We introduce class DateIntervalInfo to save date interval
|
||||
* We introduce class DateIntervalInfo to save date interval
|
||||
* patterns, similar to date time pattern in SimpleDateFormat.
|
||||
*
|
||||
* <P>
|
||||
@ -68,26 +69,26 @@ U_NAMESPACE_BEGIN
|
||||
* to (date_interval_pattern).
|
||||
*
|
||||
* <P>
|
||||
* A skeleton
|
||||
* A skeleton
|
||||
* <ol>
|
||||
* <li>
|
||||
* only keeps the field pattern letter and ignores all other parts
|
||||
* only keeps the field pattern letter and ignores all other parts
|
||||
* in a pattern, such as space, punctuations, and string literals.
|
||||
* </li>
|
||||
* <li>
|
||||
* hides the order of fields.
|
||||
* hides the order of fields.
|
||||
* </li>
|
||||
* <li>
|
||||
* might hide a field's pattern letter length.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* For those non-digit calendar fields, the pattern letter length is
|
||||
* important, such as MMM, MMMM, and MMMMM; EEE and EEEE,
|
||||
* For those non-digit calendar fields, the pattern letter length is
|
||||
* important, such as MMM, MMMM, and MMMMM; EEE and EEEE,
|
||||
* and the field's pattern letter length is honored.
|
||||
*
|
||||
* For the digit calendar fields, such as M or MM, d or dd, yy or yyyy,
|
||||
* the field pattern length is ignored and the best match, which is defined
|
||||
*
|
||||
* For the digit calendar fields, such as M or MM, d or dd, yy or yyyy,
|
||||
* the field pattern length is ignored and the best match, which is defined
|
||||
* in date time patterns, will be returned without honor the field pattern
|
||||
* letter length in skeleton.
|
||||
*
|
||||
@ -95,26 +96,26 @@ U_NAMESPACE_BEGIN
|
||||
* The calendar fields we support for interval formatting are:
|
||||
* year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.
|
||||
* Those calendar fields can be defined in the following order:
|
||||
* year > month > date > hour (in day) > minute
|
||||
*
|
||||
* year > month > date > hour (in day) > minute
|
||||
*
|
||||
* The largest different calendar fields between 2 calendars is the
|
||||
* first different calendar field in above order.
|
||||
*
|
||||
* For example: the largest different calendar fields between "Jan 10, 2007"
|
||||
* For example: the largest different calendar fields between "Jan 10, 2007"
|
||||
* and "Feb 20, 2008" is year.
|
||||
*
|
||||
* <P>
|
||||
* For other calendar fields, the compact interval formatting is not
|
||||
* supported. And the interval format will be fall back to fall-back
|
||||
* patterns, which is mostly "{date0} - {date1}".
|
||||
*
|
||||
*
|
||||
* <P>
|
||||
* There is a set of pre-defined static skeleton strings.
|
||||
* There are pre-defined interval patterns for those pre-defined skeletons
|
||||
* in locales' resource files.
|
||||
* For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is "yMMMd",
|
||||
* in en_US, if the largest different calendar field between date1 and date2
|
||||
* is "year", the date interval pattern is "MMM d, yyyy - MMM d, yyyy",
|
||||
* in en_US, if the largest different calendar field between date1 and date2
|
||||
* is "year", the date interval pattern is "MMM d, yyyy - MMM d, yyyy",
|
||||
* such as "Jan 10, 2007 - Jan 10, 2008".
|
||||
* If the largest different calendar field between date1 and date2 is "month",
|
||||
* the date interval pattern is "MMM d - MMM d, yyyy",
|
||||
@ -122,7 +123,7 @@ U_NAMESPACE_BEGIN
|
||||
* If the largest different calendar field between date1 and date2 is "day",
|
||||
* the date interval pattern is "MMM d-d, yyyy", such as "Jan 10-20, 2007".
|
||||
*
|
||||
* For date skeleton, the interval patterns when year, or month, or date is
|
||||
* For date skeleton, the interval patterns when year, or month, or date is
|
||||
* different are defined in resource files.
|
||||
* For time skeleton, the interval patterns when am/pm, or hour, or minute is
|
||||
* different are defined in resource files.
|
||||
@ -130,60 +131,60 @@ U_NAMESPACE_BEGIN
|
||||
* <P>
|
||||
* If a skeleton is not found in a locale's DateIntervalInfo, which means
|
||||
* the interval patterns for the skeleton is not defined in resource file,
|
||||
* the interval pattern will falls back to the interval "fallback" pattern
|
||||
* the interval pattern will falls back to the interval "fallback" pattern
|
||||
* defined in resource file.
|
||||
* If the interval "fallback" pattern is not defined, the default fall-back
|
||||
* is "{date0} - {data1}".
|
||||
*
|
||||
* <P>
|
||||
* For the combination of date and time,
|
||||
* For the combination of date and time,
|
||||
* The rule to generate interval patterns are:
|
||||
* <ol>
|
||||
* <li>
|
||||
* when the year, month, or day differs, falls back to fall-back
|
||||
* interval pattern, which mostly is the concatenate the two original
|
||||
* expressions with a separator between,
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 11, 2007 10:10am" is
|
||||
* "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
|
||||
* interval pattern, which mostly is the concatenate the two original
|
||||
* expressions with a separator between,
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 11, 2007 10:10am" is
|
||||
* "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
|
||||
* </li>
|
||||
* <li>
|
||||
* otherwise, present the date followed by the range expression
|
||||
* otherwise, present the date followed by the range expression
|
||||
* for the time.
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 10, 2007 11:10am" is "Jan 10, 2007 10:10 am - 11:10am"
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 10, 2007 11:10am" is "Jan 10, 2007 10:10 am - 11:10am"
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* <P>
|
||||
* If two dates are the same, the interval pattern is the single date pattern.
|
||||
* For example, interval pattern from "Jan 10, 2007" to "Jan 10, 2007" is
|
||||
* For example, interval pattern from "Jan 10, 2007" to "Jan 10, 2007" is
|
||||
* "Jan 10, 2007".
|
||||
*
|
||||
* Or if the presenting fields between 2 dates have the exact same values,
|
||||
* the interval pattern is the single date pattern.
|
||||
* the interval pattern is the single date pattern.
|
||||
* For example, if user only requests year and month,
|
||||
* the interval pattern from "Jan 10, 2007" to "Jan 20, 2007" is "Jan 2007".
|
||||
*
|
||||
* <P>
|
||||
* DateIntervalFormat needs the following information for correct
|
||||
* formatting: time zone, calendar type, pattern, date format symbols,
|
||||
* DateIntervalFormat needs the following information for correct
|
||||
* formatting: time zone, calendar type, pattern, date format symbols,
|
||||
* and date interval patterns.
|
||||
* It can be instantiated in 2 ways:
|
||||
* <ol>
|
||||
* <li>
|
||||
* create an instance using default or given locale plus given skeleton.
|
||||
* Users are encouraged to created date interval formatter this way and
|
||||
* Users are encouraged to created date interval formatter this way and
|
||||
* to use the pre-defined skeleton macros, such as
|
||||
* UDAT_YEAR_NUM_MONTH, which consists the calendar fields and
|
||||
* the format style.
|
||||
* the format style.
|
||||
* </li>
|
||||
* <li>
|
||||
* create an instance using default or given locale plus given skeleton
|
||||
* plus a given DateIntervalInfo.
|
||||
* This factory method is for powerful users who want to provide their own
|
||||
* interval patterns.
|
||||
* This factory method is for powerful users who want to provide their own
|
||||
* interval patterns.
|
||||
* Locale provides the timezone, calendar, and format symbols information.
|
||||
* Local plus skeleton provides full pattern information.
|
||||
* DateIntervalInfo provides the date interval patterns.
|
||||
@ -194,7 +195,7 @@ U_NAMESPACE_BEGIN
|
||||
* For the calendar field pattern letter, such as G, y, M, d, a, h, H, m, s etc.
|
||||
* DateIntervalFormat uses the same syntax as that of
|
||||
* DateTime format.
|
||||
*
|
||||
*
|
||||
* <P>
|
||||
* Code Sample: general usage
|
||||
* <pre>
|
||||
@ -204,7 +205,7 @@ U_NAMESPACE_BEGIN
|
||||
* DateInterval* dtInterval = new DateInterval(1000*3600*24, 1000*3600*24*2);
|
||||
* UErrorCode status = U_ZERO_ERROR;
|
||||
* DateIntervalFormat* dtIntervalFmt = DateIntervalFormat::createInstance(
|
||||
* UDAT_YEAR_MONTH_DAY,
|
||||
* UDAT_YEAR_MONTH_DAY,
|
||||
* Locale("en", "GB", ""), status);
|
||||
* UnicodeUnicodeString dateIntervalString;
|
||||
* FieldPosition pos = 0;
|
||||
@ -221,9 +222,9 @@ public:
|
||||
/**
|
||||
* Construct a DateIntervalFormat from skeleton and the default locale.
|
||||
*
|
||||
* This is a convenient override of
|
||||
* This is a convenient override of
|
||||
* createInstance(const UnicodeString& skeleton, const Locale& locale,
|
||||
* UErrorCode&)
|
||||
* UErrorCode&)
|
||||
* with the value of locale as default locale.
|
||||
*
|
||||
* @param skeleton the skeleton on which interval format based.
|
||||
@ -238,17 +239,17 @@ public:
|
||||
/**
|
||||
* Construct a DateIntervalFormat from skeleton and a given locale.
|
||||
* <P>
|
||||
* In this factory method,
|
||||
* In this factory method,
|
||||
* the date interval pattern information is load from resource files.
|
||||
* Users are encouraged to created date interval formatter this way and
|
||||
* Users are encouraged to created date interval formatter this way and
|
||||
* to use the pre-defined skeleton macros.
|
||||
*
|
||||
* <P>
|
||||
* There are pre-defined skeletons (defined in udate.h) having predefined
|
||||
* There are pre-defined skeletons (defined in udate.h) having predefined
|
||||
* interval patterns in resource files.
|
||||
* Users are encouraged to use those macros.
|
||||
* For example:
|
||||
* DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
|
||||
* For example:
|
||||
* DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
|
||||
*
|
||||
* The given Locale provides the interval patterns.
|
||||
* For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY,
|
||||
@ -274,12 +275,12 @@ public:
|
||||
* DateIntervalInfo, and default locale.
|
||||
*
|
||||
* This is a convenient override of
|
||||
* createInstance(const UnicodeString& skeleton, const Locale& locale,
|
||||
* createInstance(const UnicodeString& skeleton, const Locale& locale,
|
||||
* const DateIntervalInfo& dtitvinf, UErrorCode&)
|
||||
* with the locale value as default locale.
|
||||
*
|
||||
* @param skeleton the skeleton on which interval format based.
|
||||
* @param dtitvinf the DateIntervalInfo object.
|
||||
* @param dtitvinf the DateIntervalInfo object.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @return a date time interval formatter which the caller owns.
|
||||
* @stable ICU 4.0
|
||||
@ -295,18 +296,18 @@ public:
|
||||
*
|
||||
* <P>
|
||||
* In this factory method, user provides its own date interval pattern
|
||||
* information, instead of using those pre-defined data in resource file.
|
||||
* This factory method is for powerful users who want to provide their own
|
||||
* interval patterns.
|
||||
* information, instead of using those pre-defined data in resource file.
|
||||
* This factory method is for powerful users who want to provide their own
|
||||
* interval patterns.
|
||||
* <P>
|
||||
* There are pre-defined skeletons (defined in udate.h) having predefined
|
||||
* There are pre-defined skeletons (defined in udate.h) having predefined
|
||||
* interval patterns in resource files.
|
||||
* Users are encouraged to use those macros.
|
||||
* For example:
|
||||
* DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
|
||||
* For example:
|
||||
* DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
|
||||
*
|
||||
* The DateIntervalInfo provides the interval patterns.
|
||||
* and the DateIntervalInfo ownership remains to the caller.
|
||||
* and the DateIntervalInfo ownership remains to the caller.
|
||||
*
|
||||
* User are encouraged to set default interval pattern in DateIntervalInfo
|
||||
* as well, if they want to set other interval patterns ( instead of
|
||||
@ -315,7 +316,7 @@ public:
|
||||
* field is not found ( if user not set it ), interval format fallback to
|
||||
* the default interval pattern.
|
||||
* If user does not provide default interval pattern, it fallback to
|
||||
* "{date0} - {date1}"
|
||||
* "{date0} - {date1}"
|
||||
*
|
||||
* @param skeleton the skeleton on which interval format based.
|
||||
* @param locale the given locale
|
||||
@ -354,7 +355,7 @@ public:
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
/**
|
||||
* Return true if the given Format objects are not semantically equal.
|
||||
* Return true if the given Format objects are not semantically equal.
|
||||
* Objects of different subclasses are considered unequal.
|
||||
* @param other the object to be compared with.
|
||||
* @return true if the given Format objects are not semantically equal.
|
||||
@ -362,13 +363,16 @@ public:
|
||||
*/
|
||||
UBool operator!=(const Format& other) const;
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Format an object to produce a string. This method handles Formattable
|
||||
* objects with a DateInterval type.
|
||||
* objects with a DateInterval type.
|
||||
* If a the Formattable object type is not a DateInterval,
|
||||
* then it returns a failing UErrorCode.
|
||||
*
|
||||
* @param obj The object to format.
|
||||
* @param obj The object to format.
|
||||
* Must be a DateInterval.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
@ -382,11 +386,11 @@ public:
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UErrorCode& status) const ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Format a DateInterval to produce a string.
|
||||
* Format a DateInterval to produce a string.
|
||||
*
|
||||
* @param dtInterval DateInterval to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
@ -401,10 +405,10 @@ public:
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UErrorCode& status) const ;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Format 2 Calendars to produce a string.
|
||||
* Format 2 Calendars to produce a string.
|
||||
*
|
||||
* Note: "fromCalendar" and "toCalendar" are not const,
|
||||
* since calendar is not const in SimpleDateFormat::format(Calendar&),
|
||||
@ -433,7 +437,7 @@ public:
|
||||
* Date interval parsing is not supported. Please do not use.
|
||||
* <P>
|
||||
* This method should handle parsing of
|
||||
* date time interval strings into Formattable objects with
|
||||
* date time interval strings into Formattable objects with
|
||||
* DateInterval type, which is a pair of UDate.
|
||||
* <P>
|
||||
* Before calling, set parse_pos.index to the offset you want to start
|
||||
@ -470,7 +474,7 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* Set the date time interval patterns.
|
||||
* Set the date time interval patterns.
|
||||
* @param newIntervalPatterns the given interval patterns to copy.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.0
|
||||
@ -537,7 +541,7 @@ private:
|
||||
* and a separator "-".
|
||||
* The pattern is divided into 2 parts. For above example,
|
||||
* the first part is "MMM d - ", and the second part is "MMM d, yyyy".
|
||||
* Also, the first date appears in an interval pattern could be
|
||||
* Also, the first date appears in an interval pattern could be
|
||||
* the earlier date or the later date.
|
||||
* And such information is saved in the interval pattern as well.
|
||||
* @internal ICU 4.0
|
||||
@ -548,22 +552,22 @@ private:
|
||||
/**
|
||||
* Whether the first date in interval pattern is later date or not.
|
||||
* Fallback format set the default ordering.
|
||||
* And for a particular interval pattern, the order can be
|
||||
* overriden by prefixing the interval pattern with "latestFirst:" or
|
||||
* And for a particular interval pattern, the order can be
|
||||
* overriden by prefixing the interval pattern with "latestFirst:" or
|
||||
* "earliestFirst:"
|
||||
* For example, given 2 date, Jan 10, 2007 to Feb 10, 2007.
|
||||
* if the fallback format is "{0} - {1}",
|
||||
* if the fallback format is "{0} - {1}",
|
||||
* and the pattern is "d MMM - d MMM yyyy", the interval format is
|
||||
* "10 Jan - 10 Feb, 2007".
|
||||
* If the pattern is "latestFirst:d MMM - d MMM yyyy",
|
||||
* If the pattern is "latestFirst:d MMM - d MMM yyyy",
|
||||
* the interval format is "10 Feb - 10 Jan, 2007"
|
||||
*/
|
||||
UBool laterDateFirst;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
* default constructor
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
DateIntervalFormat();
|
||||
@ -573,12 +577,12 @@ private:
|
||||
* a DateIntervalInfo, and skeleton.
|
||||
* DateFormat provides the timezone, calendar,
|
||||
* full pattern, and date format symbols information.
|
||||
* It should be a SimpleDateFormat object which
|
||||
* It should be a SimpleDateFormat object which
|
||||
* has a pattern in it.
|
||||
* the DateIntervalInfo provides the interval patterns.
|
||||
*
|
||||
* Note: the DateIntervalFormat takes ownership of both
|
||||
* DateFormat and DateIntervalInfo objects.
|
||||
* Note: the DateIntervalFormat takes ownership of both
|
||||
* DateFormat and DateIntervalInfo objects.
|
||||
* Caller should not delete them.
|
||||
*
|
||||
* @param locale the locale of this date interval formatter.
|
||||
@ -590,7 +594,7 @@ private:
|
||||
DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
|
||||
const UnicodeString* skeleton, UErrorCode& status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from DateFormat
|
||||
* and a DateIntervalInfo.
|
||||
@ -630,7 +634,7 @@ private:
|
||||
|
||||
|
||||
/**
|
||||
* Below are for generating interval patterns local to the formatter
|
||||
* Below are for generating interval patterns local to the formatter
|
||||
*/
|
||||
|
||||
|
||||
@ -660,10 +664,10 @@ private:
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Initialize interval patterns locale to this formatter
|
||||
*
|
||||
* This code is a bit complicated since
|
||||
*
|
||||
* This code is a bit complicated since
|
||||
* 1. the interval patterns saved in resource bundle files are interval
|
||||
* patterns based on date or time only.
|
||||
* It does not have interval patterns based on both date and time.
|
||||
@ -671,32 +675,32 @@ private:
|
||||
*
|
||||
* For example, it has interval patterns on skeleton "dMy" and "hm",
|
||||
* but it does not have interval patterns on skeleton "dMyhm".
|
||||
*
|
||||
* The rule to generate interval patterns for both date and time skeleton are
|
||||
* 1) when the year, month, or day differs, concatenate the two original
|
||||
* expressions with a separator between,
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 11, 2007 10:10am" is
|
||||
* "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
|
||||
*
|
||||
* 2) otherwise, present the date followed by the range expression
|
||||
* The rule to generate interval patterns for both date and time skeleton are
|
||||
* 1) when the year, month, or day differs, concatenate the two original
|
||||
* expressions with a separator between,
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 11, 2007 10:10am" is
|
||||
* "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
|
||||
*
|
||||
* 2) otherwise, present the date followed by the range expression
|
||||
* for the time.
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 10, 2007 11:10am" is
|
||||
* "Jan 10, 2007 10:10 am - 11:10am"
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 10, 2007 11:10am" is
|
||||
* "Jan 10, 2007 10:10 am - 11:10am"
|
||||
*
|
||||
* 2. even a pattern does not request a certain calendar field,
|
||||
* the interval pattern needs to include such field if such fields are
|
||||
* different between 2 dates.
|
||||
* For example, a pattern/skeleton is "hm", but the interval pattern
|
||||
* For example, a pattern/skeleton is "hm", but the interval pattern
|
||||
* includes year, month, and date when year, month, and date differs.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @internal ICU 4.0
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
void initializePattern(UErrorCode& status);
|
||||
|
||||
void initializePattern(UErrorCode& status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -705,15 +709,15 @@ private:
|
||||
* @param field the largest different calendar field
|
||||
* @param skeleton a skeleton
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @internal ICU 4.0
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
void setFallbackPattern(UCalendarDateFields field,
|
||||
void setFallbackPattern(UCalendarDateFields field,
|
||||
const UnicodeString& skeleton,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* get separated date and time skeleton from a combined skeleton.
|
||||
*
|
||||
* The difference between date skeleton and normalizedDateSkeleton are:
|
||||
@ -736,7 +740,7 @@ private:
|
||||
* @param normalizedTime Output parameter for normalized time only
|
||||
* skeleton.
|
||||
*
|
||||
* @internal ICU 4.0
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
static void U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
|
||||
UnicodeString& date,
|
||||
@ -750,7 +754,7 @@ private:
|
||||
* Generate date or time interval pattern from resource,
|
||||
* and set them into the interval pattern locale to this formatter.
|
||||
*
|
||||
* It needs to handle the following:
|
||||
* It needs to handle the following:
|
||||
* 1. need to adjust field width.
|
||||
* For example, the interval patterns saved in DateIntervalInfo
|
||||
* includes "dMMMy", but not "dMMMMy".
|
||||
@ -770,9 +774,9 @@ private:
|
||||
* FALSE otherwise.
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
|
||||
UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
|
||||
const UnicodeString& timeSkeleton);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -790,20 +794,20 @@ private:
|
||||
* 0 means the best matched skeleton is the same as input skeleton
|
||||
* 1 means the fields are the same, but field width are different
|
||||
* 2 means the only difference between fields are v/z,
|
||||
* -1 means there are other fields difference
|
||||
* -1 means there are other fields difference
|
||||
*
|
||||
* @param extendedSkeleton extended skeleton
|
||||
* @param extendedBestSkeleton extended best match skeleton
|
||||
* @return whether the interval pattern is found
|
||||
* @return whether the interval pattern is found
|
||||
* through extending skeleton or not.
|
||||
* TRUE if interval pattern is found by
|
||||
* extending skeleton, FALSE otherwise.
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
UBool setIntervalPattern(UCalendarDateFields field,
|
||||
const UnicodeString* skeleton,
|
||||
const UnicodeString* bestSkeleton,
|
||||
int8_t differenceInfo,
|
||||
UBool setIntervalPattern(UCalendarDateFields field,
|
||||
const UnicodeString* skeleton,
|
||||
const UnicodeString* bestSkeleton,
|
||||
int8_t differenceInfo,
|
||||
UnicodeString* extendedSkeleton = NULL,
|
||||
UnicodeString* extendedBestSkeleton = NULL);
|
||||
|
||||
@ -847,29 +851,29 @@ private:
|
||||
* Concat a single date pattern with a time interval pattern,
|
||||
* set it into the intervalPatterns, while field is time field.
|
||||
* This is used to handle time interval patterns on skeleton with
|
||||
* both time and date. Present the date followed by
|
||||
* both time and date. Present the date followed by
|
||||
* the range expression for the time.
|
||||
* @param format date and time format
|
||||
* @param formatLen format string length
|
||||
* @param datePattern date pattern
|
||||
* @param field time calendar field: AM_PM, HOUR, MINUTE
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @internal ICU 4.0
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
void concatSingleDate2TimeInterval(const UChar* format,
|
||||
int32_t formatLen,
|
||||
const UnicodeString& datePattern,
|
||||
UCalendarDateFields field,
|
||||
UErrorCode& status);
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* check whether a calendar field present in a skeleton.
|
||||
* @param field calendar field need to check
|
||||
* @param skeleton given skeleton on which to check the calendar field
|
||||
* @return true if field present in a skeleton.
|
||||
* @internal ICU 4.0
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
|
||||
static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
|
||||
const UnicodeString& skeleton);
|
||||
|
||||
|
||||
@ -953,17 +957,12 @@ private:
|
||||
UnicodeString fSkeleton;
|
||||
PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline UBool
|
||||
inline UBool
|
||||
DateIntervalFormat::operator!=(const Format& other) const {
|
||||
return !operator==(other);
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
@ -178,7 +178,7 @@ public:
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator& posIter,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2010, International Business Machines Corporation and
|
||||
* Copyright (C) 2007-2010, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
@ -20,10 +20,10 @@
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \file
|
||||
* \brief C++ API: Formats messages in a language-neutral way.
|
||||
*/
|
||||
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/format.h"
|
||||
@ -41,16 +41,16 @@ class DateFormat;
|
||||
* MessageFormat produces concatenated messages in a language-neutral
|
||||
* way. Use this whenever concatenating strings that are displayed to
|
||||
* end users.
|
||||
*
|
||||
*
|
||||
* <P>A MessageFormat contains an array of <EM>subformats</EM> arranged
|
||||
* within a <EM>template string</EM>. Together, the subformats and
|
||||
* template string determine how the MessageFormat will operate during
|
||||
* formatting and parsing.
|
||||
*
|
||||
*
|
||||
* <P>Typically, both the subformats and the template string are
|
||||
* specified at once in a <EM>pattern</EM>. By using different
|
||||
* patterns for different locales, messages may be localized.
|
||||
*
|
||||
*
|
||||
* <P>When formatting, MessageFormat takes an array of arguments
|
||||
* and produces a user-readable string. Each argument is a
|
||||
* Formattable object; they may be passed in in an array, or as a
|
||||
@ -59,31 +59,31 @@ class DateFormat;
|
||||
* formats it into a string. The resulting strings are then assembled
|
||||
* within the string template of the MessageFormat to produce the
|
||||
* final output string.
|
||||
*
|
||||
*
|
||||
* <p><strong>Note:</strong>
|
||||
* In ICU 4.0 MessageFormat supports named arguments. If a named argument
|
||||
* is used, all arguments must be named. Names start with a character in
|
||||
* <code>UCHAR_ID_START</code> and continue with characters in
|
||||
* is used, all arguments must be named. Names start with a character in
|
||||
* <code>UCHAR_ID_START</code> and continue with characters in
|
||||
* <code>UCHARID_CONTINUE</code>, in particular they do not start with a digit.
|
||||
* If named arguments are used, {@link #usesNamedArguments()} will return true.
|
||||
*
|
||||
* <p>The other new methods supporting named arguments are
|
||||
*
|
||||
* <p>The other new methods supporting named arguments are
|
||||
* {@link #getFormatNames(UErrorCode& status)},
|
||||
* {@link #getFormat(const UnicodeString& formatName, UErrorCode& status)}
|
||||
* {@link #setFormat(const UnicodeString& formatName, const Format& format, UErrorCode& status)},
|
||||
* {@link #adoptFormat(const UnicodeString& formatName, Format* formatToAdopt, UErrorCode& status)},
|
||||
* {@link #format(const UnicodeString* argumentNames, const Formattable* arguments,
|
||||
* {@link #format(const UnicodeString* argumentNames, const Formattable* arguments,
|
||||
* int32_t count, UnicodeString& appendTo,UErrorCode& status)}.
|
||||
* These methods are all compatible with patterns that do not used named arguments--
|
||||
* in these cases the keys in the input or output use <code>UnicodeString</code>s
|
||||
* These methods are all compatible with patterns that do not used named arguments--
|
||||
* in these cases the keys in the input or output use <code>UnicodeString</code>s
|
||||
* that name the argument indices, e.g. "0", "1", "2"... etc.
|
||||
*
|
||||
*
|
||||
* <p>If this format uses named arguments, certain methods that take or
|
||||
* return arrays do not perform any action, since it is not possible to
|
||||
* identify positions in an array using a name. Of these methods,
|
||||
* identify positions in an array using a name. Of these methods,
|
||||
* UErrorCode is set to U_ILLEGAL_ARGUMENT_ERROR by format, and to
|
||||
* U_ARGUMENT_TYPE_MISMATCH by parse.
|
||||
* These methods are
|
||||
* These methods are
|
||||
* {@link #adoptFormats(Format** formatsToAdopt, int32_t count)},
|
||||
* {@link #setFormats(const Format** newFormats,int32_t count)},
|
||||
* {@link #adoptFormat(int32_t n, Format *newFormat)},
|
||||
@ -208,7 +208,7 @@ class DateFormat;
|
||||
* | numberFormatPattern
|
||||
*
|
||||
* choiceStyle := choiceFormatPattern
|
||||
*
|
||||
*
|
||||
* pluralStyle := pluralFormatPattern
|
||||
*
|
||||
* selectStyle := selectFormatPattern
|
||||
@ -219,10 +219,10 @@ class DateFormat;
|
||||
* 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::createInstance(),
|
||||
* DateFormat::createTimeInstance(DateFormat::kDefault, ...) or
|
||||
* DateFormat::createTimeInstance(DateFormat::kDefault, ...) or
|
||||
* DateFormat::createDateInstance(DateFormat::kDefault, ...). For
|
||||
* a RuleBasedNumberFormat, if there is no ruleSetName, the default
|
||||
* rule set is used. For a ChoiceFormat or PluralFormat or SelectFormat, the pattern
|
||||
* a RuleBasedNumberFormat, if there is no ruleSetName, the default
|
||||
* rule set is used. For a ChoiceFormat or PluralFormat or SelectFormat, the pattern
|
||||
* must always be specified, since there is no default.
|
||||
* <P>
|
||||
* In strings, single quotes can be used to quote syntax characters.
|
||||
@ -357,7 +357,7 @@ public:
|
||||
* Constructs a new MessageFormat using the given pattern and locale.
|
||||
* @param pattern Pattern used to construct object.
|
||||
* @param newLocale The locale to use for formatting dates and numbers.
|
||||
* @param parseError Struct to recieve information on position
|
||||
* @param parseError Struct to recieve information on position
|
||||
* of error within the pattern.
|
||||
* @param status Input/output error code. If the
|
||||
* pattern cannot be parsed, set to failure code.
|
||||
@ -431,7 +431,7 @@ public:
|
||||
* Applies the given pattern string to this message format.
|
||||
*
|
||||
* @param pattern The pattern to be applied.
|
||||
* @param parseError Struct to recieve information on position
|
||||
* @param parseError Struct to recieve information on position
|
||||
* of error within pattern.
|
||||
* @param status Input/output error code. If the
|
||||
* pattern cannot be parsed, set to failure code.
|
||||
@ -459,7 +459,7 @@ public:
|
||||
* ownership is retained by the caller. If the call fails because
|
||||
* memory cannot be allocated, then the formats will be deleted
|
||||
* by this method, and this object will remain unchanged.
|
||||
*
|
||||
*
|
||||
* <p>If this format uses named arguments, the new formats are discarded
|
||||
* and this format remains unchanged.
|
||||
*
|
||||
@ -475,7 +475,7 @@ public:
|
||||
* Each item in the array is cloned into the internal array.
|
||||
* If the call fails because memory cannot be allocated, then this
|
||||
* object will remain unchanged.
|
||||
*
|
||||
*
|
||||
* <p>If this format uses named arguments, the new formats are discarded
|
||||
* and this format remains unchanged.
|
||||
*
|
||||
@ -515,32 +515,32 @@ public:
|
||||
|
||||
/**
|
||||
* Gets format names. This function returns formatNames in StringEnumerations
|
||||
* which can be used with getFormat() and setFormat() to export formattable
|
||||
* array from current MessageFormat to another. It is caller's resposibility
|
||||
* which can be used with getFormat() and setFormat() to export formattable
|
||||
* array from current MessageFormat to another. It is caller's resposibility
|
||||
* to delete the returned formatNames.
|
||||
* @param status output param set to success/failure code.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual StringEnumeration* getFormatNames(UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Gets subformat pointer for given format name.
|
||||
* Gets subformat pointer for given format name.
|
||||
* This function supports both named and numbered
|
||||
* arguments-- if numbered, the formatName is the
|
||||
* corresponding UnicodeStrings (e.g. "0", "1", "2"...).
|
||||
* The returned Format object should not be deleted by the caller,
|
||||
* nor should the ponter of other object . The pointer and its
|
||||
* nor should the ponter of other object . The pointer and its
|
||||
* contents remain valid only until the next call to any method
|
||||
* of this class is made with this object.
|
||||
* of this class is made with this object.
|
||||
* @param formatName the name or number specifying a format
|
||||
* @param status output param set to success/failure code.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual Format* getFormat(const UnicodeString& formatName, UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Sets one subformat for given format name.
|
||||
* See the class description about format name.
|
||||
* See the class description about format name.
|
||||
* This function supports both named and numbered
|
||||
* arguments-- if numbered, the formatName is the
|
||||
* corresponding UnicodeStrings (e.g. "0", "1", "2"...).
|
||||
@ -552,10 +552,10 @@ public:
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual void setFormat(const UnicodeString& formatName, const Format& format, UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Sets one subformat for given format name.
|
||||
* See the class description about format name.
|
||||
* See the class description about format name.
|
||||
* This function supports both named and numbered
|
||||
* arguments-- if numbered, the formatName is the
|
||||
* corresponding UnicodeStrings (e.g. "0", "1", "2"...).
|
||||
@ -573,7 +573,7 @@ public:
|
||||
* Gets an array of subformats of this object. The returned array
|
||||
* should not be deleted by the caller, nor should the pointers
|
||||
* within the array. The array and its contents remain valid only
|
||||
* until the next call to this format. See the class description
|
||||
* until the next call to this format. See the class description
|
||||
* about format numbering.
|
||||
*
|
||||
* @param count output parameter to receive the size of the array
|
||||
@ -583,6 +583,9 @@ public:
|
||||
*/
|
||||
virtual const Format** getFormats(int32_t& count) const;
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Formats the given array of arguments into a user-readable string.
|
||||
* Does not take ownership of the Formattable* array or its contents.
|
||||
@ -671,7 +674,7 @@ public:
|
||||
UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& appendTo,
|
||||
UErrorCode& status) const;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formats the given array of arguments into a user-defined argument name
|
||||
@ -681,7 +684,7 @@ public:
|
||||
*
|
||||
* @param argumentNames argument name array
|
||||
* @param arguments An array of objects to be formatted.
|
||||
* @param count The number of elements of 'argumentNames' and
|
||||
* @param count The number of elements of 'argumentNames' and
|
||||
* arguments. The number of argumentNames and arguments
|
||||
* must be the same.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
@ -716,16 +719,16 @@ public:
|
||||
/**
|
||||
* Parses the given string into an array of output arguments.
|
||||
*
|
||||
* <p>If this format uses named arguments, status is set to
|
||||
* <p>If this format uses named arguments, status is set to
|
||||
* U_ARGUMENT_TYPE_MISMATCH.
|
||||
*
|
||||
* @param source String to be parsed.
|
||||
* @param count Output param to receive size of returned array.
|
||||
* @param status Input/output error code. If the
|
||||
* pattern cannot be parsed, set to failure code.
|
||||
* pattern cannot be parsed, set to failure code.
|
||||
* @return an array of parsed arguments. The caller owns both
|
||||
* the array and its contents. Returns NULL if status is not U_ZERO_ERROR.
|
||||
*
|
||||
*
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual Formattable* parse(const UnicodeString& source,
|
||||
@ -751,7 +754,7 @@ public:
|
||||
/**
|
||||
* Convert an 'apostrophe-friendly' pattern into a standard
|
||||
* pattern. Standard patterns treat all apostrophes as
|
||||
* quotes, which is problematic in some languages, e.g.
|
||||
* quotes, which is problematic in some languages, e.g.
|
||||
* French, where apostrophe is commonly used. This utility
|
||||
* assumes that only an unpaired apostrophe immediately before
|
||||
* a brace is a true quote. Other unpaired apostrophes are paired,
|
||||
@ -767,9 +770,9 @@ public:
|
||||
* @return the standard equivalent of the original pattern
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
static UnicodeString autoQuoteApostrophe(const UnicodeString& pattern,
|
||||
static UnicodeString autoQuoteApostrophe(const UnicodeString& pattern,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this MessageFormat uses named arguments,
|
||||
* and false otherwise. See class description.
|
||||
@ -778,7 +781,7 @@ public:
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UBool usesNamedArguments() const;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This API is for ICU internal use only.
|
||||
@ -817,7 +820,7 @@ public:
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Locale fLocale;
|
||||
@ -860,7 +863,7 @@ private:
|
||||
|
||||
/**
|
||||
* Is true iff all argument names are non-negative numbers.
|
||||
*
|
||||
*
|
||||
*/
|
||||
UBool isArgNumeric;
|
||||
|
||||
@ -916,8 +919,8 @@ private:
|
||||
FieldPosition& status,
|
||||
int32_t recursionProtection,
|
||||
UErrorCode& success) const;
|
||||
|
||||
UnicodeString& format( const Formattable* arguments,
|
||||
|
||||
UnicodeString& format( const Formattable* arguments,
|
||||
const UnicodeString *argumentNames,
|
||||
int32_t cnt,
|
||||
UnicodeString& appendTo,
|
||||
@ -947,7 +950,7 @@ private:
|
||||
static void copyAndFixQuotes(const UnicodeString& appendTo, int32_t start, int32_t end, UnicodeString& target);
|
||||
|
||||
/**
|
||||
* Returns array of argument types in the parsed pattern
|
||||
* Returns array of argument types in the parsed pattern
|
||||
* for use in C API. Only for the use of umsg_vformat(). Not
|
||||
* for public consumption.
|
||||
* @param listCount Output parameter to receive the size of array
|
||||
@ -956,16 +959,16 @@ private:
|
||||
*/
|
||||
const Formattable::Type* getArgTypeList(int32_t& listCount) const {
|
||||
listCount = argTypeCount;
|
||||
return argTypes;
|
||||
return argTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns FALSE if the argument name is not legal.
|
||||
* @param argName argument name.
|
||||
* @return TRUE if the argument name is legal, otherwise return FALSE.
|
||||
*/
|
||||
UBool isLegalArgName(const UnicodeString& argName) const;
|
||||
|
||||
|
||||
friend class MessageFormatAdapter; // getFormatTypeList() access
|
||||
};
|
||||
|
||||
@ -975,10 +978,10 @@ MessageFormat::format(const Formattable& obj,
|
||||
UErrorCode& status) const {
|
||||
return Format::format(obj, appendTo, status);
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // _MSGFMT
|
||||
//eof
|
||||
|
||||
|
@ -234,6 +234,9 @@ public:
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Format an object to produce a string. This method handles
|
||||
* Formattable objects with numeric types. If the Formattable
|
||||
@ -264,7 +267,7 @@ public:
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call. Can be
|
||||
* of fields generated by this format call. Can be
|
||||
* NULL.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
|
@ -307,6 +307,9 @@ public:
|
||||
*/
|
||||
void applyPattern(const UnicodeString& pattern, UErrorCode& status);
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Formats a plural message for a given number.
|
||||
*
|
||||
@ -319,8 +322,8 @@ public:
|
||||
* @return the string containing the formatted plural message.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UnicodeString format(int32_t number, UErrorCode& status) const;
|
||||
|
||||
UnicodeString format(int32_t number, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Formats a plural message for a given number.
|
||||
*
|
||||
@ -355,7 +358,7 @@ public:
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
|
||||
/**
|
||||
* Formats a plural message for a given number.
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2009, International Business Machines Corporation and others.
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -11,7 +11,7 @@
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \file
|
||||
* \brief C++ API: Rule Based Number Format
|
||||
*/
|
||||
|
||||
@ -490,9 +490,9 @@ class Collator;
|
||||
* <p>In the syntax, angle brackets '<', '>' are used to delimit the arrays, and comma ',' is used
|
||||
* to separate elements of an array. Whitespace is ignored, unless quoted.</p>
|
||||
* <p>For example:<pre>
|
||||
* < < %foo, %bar, %baz >,
|
||||
* < en, Foo, Bar, Baz >,
|
||||
* < fr, 'le Foo', 'le Bar', 'le Baz' >
|
||||
* < < %foo, %bar, %baz >,
|
||||
* < en, Foo, Bar, Baz >,
|
||||
* < fr, 'le Foo', 'le Bar', 'le Baz' >
|
||||
* < zh, \\u7532, \\u4e59, \\u4e19 > >
|
||||
* </pre></p>
|
||||
* @author Richard Gillam
|
||||
@ -521,7 +521,7 @@ public:
|
||||
|
||||
/**
|
||||
* Creates a RuleBasedNumberFormat that behaves according to the description
|
||||
* passed in. The formatter uses the default locale.
|
||||
* passed in. The formatter uses the default locale.
|
||||
* <p>
|
||||
* The localizations data provides information about the public
|
||||
* rule sets and their localized display names for different
|
||||
@ -565,7 +565,7 @@ public:
|
||||
|
||||
/**
|
||||
* Creates a RuleBasedNumberFormat that behaves according to the description
|
||||
* passed in. The formatter uses the default locale.
|
||||
* passed in. The formatter uses the default locale.
|
||||
* <p>
|
||||
* The localizations data provides information about the public
|
||||
* rule sets and their localized display names for different
|
||||
@ -697,7 +697,7 @@ public:
|
||||
/**
|
||||
* Return the rule set display names for the provided locale. These are in the same order
|
||||
* as those returned by getRuleSetName. The locale is matched against the locales for
|
||||
* which there is display name data, using normal fallback rules. If no locale matches,
|
||||
* which there is display name data, using normal fallback rules. If no locale matches,
|
||||
* the default display names are returned. (These are the internal rule set names minus
|
||||
* the leading '%'.)
|
||||
* @param index the index of the rule set
|
||||
@ -707,20 +707,23 @@ public:
|
||||
* @see #getRuleSetName
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual UnicodeString getRuleSetDisplayName(int32_t index,
|
||||
virtual UnicodeString getRuleSetDisplayName(int32_t index,
|
||||
const Locale& locale = Locale::getDefault());
|
||||
|
||||
/**
|
||||
* Return the rule set display name for the provided rule set and locale.
|
||||
* Return the rule set display name for the provided rule set and locale.
|
||||
* The locale is matched against the locales for which there is display name data, using
|
||||
* normal fallback rules. If no locale matches, the default display name is returned.
|
||||
* @return the display name for the rule set
|
||||
* @stable ICU 3.2
|
||||
* @see #getRuleSetDisplayName
|
||||
*/
|
||||
virtual UnicodeString getRuleSetDisplayName(const UnicodeString& ruleSetName,
|
||||
virtual UnicodeString getRuleSetDisplayName(const UnicodeString& ruleSetName,
|
||||
const Locale& locale = Locale::getDefault());
|
||||
|
||||
|
||||
using NumberFormat::format;
|
||||
|
||||
/**
|
||||
* Formats the specified 32-bit number using the default ruleset.
|
||||
* @param number The number to format.
|
||||
@ -965,8 +968,8 @@ private:
|
||||
RuleBasedNumberFormat(); // default constructor not implemented
|
||||
|
||||
// this will ref the localizations if they are not NULL
|
||||
// caller must deref to get adoption
|
||||
RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* localizations,
|
||||
// caller must deref to get adoption
|
||||
RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* localizations,
|
||||
const Locale& locale, UParseError& perror, UErrorCode& status);
|
||||
|
||||
void init(const UnicodeString& rules, LocalizationInfo* localizations, UParseError& perror, UErrorCode& status);
|
||||
|
@ -1,8 +1,8 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2010, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
* Copyright (C) 2010 , Yahoo! Inc.
|
||||
* Copyright (C) 2010 , Yahoo! Inc.
|
||||
********************************************************************
|
||||
*
|
||||
* File SELFMT.H
|
||||
@ -108,12 +108,12 @@ class Hashtable;
|
||||
* <p>Patterns can be nested, so that it's possible to handle interactions of
|
||||
* number and gender where necessary. For example, if the above sentence should
|
||||
* allow for the names of several people to be inserted, the following sentence
|
||||
* pattern can be used (with argument 0 the list of people's names,
|
||||
* argument 1 the number of people, argument 2 their combined gender, and
|
||||
* pattern can be used (with argument 0 the list of people's names,
|
||||
* argument 1 the number of people, argument 2 their combined gender, and
|
||||
* argument 3 the city name):</p>
|
||||
*
|
||||
* \htmlonly
|
||||
* <pre>{0} {1, plural,
|
||||
* <pre>{0} {1, plural,
|
||||
* one {est {2, select, female {allée} other {allé}}}
|
||||
* other {sont {2, select, female {allées} other {allés}}}
|
||||
* }à {3}.</pre>
|
||||
@ -124,7 +124,7 @@ class Hashtable;
|
||||
* <p>The <code>SelectFormat</code> pattern text defines the phrase output
|
||||
* for each user-defined keyword.
|
||||
* The pattern is a sequence of <code><i>keyword</i>{<i>phrase</i>}</code>
|
||||
* clauses.
|
||||
* clauses.
|
||||
* Each clause assigns the phrase <code><i>phrase</i></code>
|
||||
* to the user-defined <code><i>keyword</i></code>.</p>
|
||||
*
|
||||
@ -132,7 +132,7 @@ class Hashtable;
|
||||
* that don't match this pattern result in the error code
|
||||
* <code>U_ILLEGAL_CHARACTER</code>.
|
||||
* You always have to define a phrase for the default keyword
|
||||
* <code>other</code>; this phrase is returned when the keyword
|
||||
* <code>other</code>; this phrase is returned when the keyword
|
||||
* provided to
|
||||
* the <code>format</code> method matches no other keyword.
|
||||
* If a pattern does not provide a phrase for <code>other</code>, the method
|
||||
@ -219,17 +219,20 @@ public:
|
||||
*/
|
||||
void applyPattern(const UnicodeString& pattern, UErrorCode& status);
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Selects the phrase for the given keyword
|
||||
*
|
||||
* @param keyword The keyword that is used to select an alternative.
|
||||
* @param keyword The keyword that is used to select an alternative.
|
||||
* @param appendTo output parameter to receive result.
|
||||
* result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status output param set to success/failure code on exit, which
|
||||
* must not indicate a failure before the function call.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
UnicodeString& format(const UnicodeString& keyword,
|
||||
@ -271,12 +274,12 @@ public:
|
||||
virtual Format* clone(void) const;
|
||||
|
||||
/**
|
||||
* Format an object to produce a string.
|
||||
* This method handles keyword strings.
|
||||
* If the Formattable object is not a <code>UnicodeString</code>,
|
||||
* Format an object to produce a string.
|
||||
* This method handles keyword strings.
|
||||
* If the Formattable object is not a <code>UnicodeString</code>,
|
||||
* then it returns a failing UErrorCode.
|
||||
*
|
||||
* @param obj A keyword string that is used to select an alternative.
|
||||
* @param obj A keyword string that is used to select an alternative.
|
||||
* @param appendTo output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
@ -355,7 +358,7 @@ private:
|
||||
SelectFormat(); // default constructor not implemented.
|
||||
void init(UErrorCode& status);
|
||||
//For the applyPattern , classifies char.s in one of the characterClass.
|
||||
CharacterClass classifyCharacter(UChar ch) const;
|
||||
CharacterClass classifyCharacter(UChar ch) const;
|
||||
//Checks if the "other" keyword is present in pattern.
|
||||
UBool checkSufficientDefinition();
|
||||
//Checks if the keyword passed is valid.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*
|
||||
@ -367,6 +367,9 @@ public:
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
|
||||
using DateFormat::format;
|
||||
|
||||
/**
|
||||
* Format a date or time, which is the standard millis since 24:00 GMT, Jan
|
||||
* 1, 1970. Overrides DateFormat pure virtual method.
|
||||
|
@ -40,7 +40,7 @@ class Hashtable;
|
||||
* Format or parse a TimeUnitAmount, using plural rules for the units where available.
|
||||
*
|
||||
* <P>
|
||||
* Code Sample:
|
||||
* Code Sample:
|
||||
* <pre>
|
||||
* // create time unit amount instance - a combination of Number and time unit
|
||||
* UErrorCode status = U_ZERO_ERROR;
|
||||
@ -56,7 +56,7 @@ class Hashtable;
|
||||
* Formattable result;
|
||||
* ((Format*)format)->parseObject(formatted, result, status);
|
||||
* if (U_SUCCESS(status)) {
|
||||
* assert (result == formattable);
|
||||
* assert (result == formattable);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
@ -81,9 +81,9 @@ public:
|
||||
kAbbreviate = 1,
|
||||
kTotal = kAbbreviate + 1
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create TimeUnitFormat with default locale, and full name style.
|
||||
* Create TimeUnitFormat with default locale, and full name style.
|
||||
* Use setLocale and/or setFormat to modify.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
@ -138,7 +138,7 @@ public:
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
/**
|
||||
* Return true if the given Format objects are not semantically equal.
|
||||
* Return true if the given Format objects are not semantically equal.
|
||||
* Objects of different subclasses are considered unequal.
|
||||
* @param other the object to be compared with.
|
||||
* @return true if the given Format objects are not semantically equal.
|
||||
@ -156,13 +156,16 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* Set the number format used for formatting or parsing.
|
||||
* Set the number format used for formatting or parsing.
|
||||
* @param format the number formatter to be set
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
void setNumberFormat(const NumberFormat& format, UErrorCode& status);
|
||||
|
||||
|
||||
using MeasureFormat::format;
|
||||
|
||||
/**
|
||||
* Format a TimeUnitAmount.
|
||||
* If the formattable object is not a time unit amount object,
|
||||
@ -171,17 +174,17 @@ public:
|
||||
* @see Format#format(const Formattable&, UnicodeString&, FieldPosition&, UErrorCode&) const
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& toAppendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Parse a TimeUnitAmount.
|
||||
* @see Format#parseObject(const UnicodeString&, Formattable&, ParsePosition&) const;
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual void parseObject(const UnicodeString& source,
|
||||
virtual void parseObject(const UnicodeString& source,
|
||||
Formattable& result,
|
||||
ParsePosition& pos) const;
|
||||
|
||||
@ -222,8 +225,8 @@ private:
|
||||
|
||||
// it might actually be simpler to make them Decimal Formats later.
|
||||
// initialize all private data members
|
||||
void setup(UErrorCode& status);
|
||||
|
||||
void setup(UErrorCode& status);
|
||||
|
||||
// initialize data member without fill in data for fTimeUnitToCountToPattern
|
||||
void initDataMembers(UErrorCode& status);
|
||||
|
||||
@ -235,8 +238,8 @@ private:
|
||||
void checkConsistency(EStyle style, const char* key, UErrorCode& status);
|
||||
|
||||
// fill in fTimeUnitToCountToPatterns from locale fall-back chain
|
||||
void searchInLocaleChain(EStyle style, const char* key,
|
||||
TimeUnit::UTimeUnitFields field, const char*,
|
||||
void searchInLocaleChain(EStyle style, const char* key,
|
||||
TimeUnit::UTimeUnitFields field, const char*,
|
||||
const char*, Hashtable*, UErrorCode&);
|
||||
|
||||
// initialize hash table
|
||||
|
Loading…
Reference in New Issue
Block a user