ICU-7468 Use C++ "using" in Format class hierarchy, so inheritance of format() and parse() functions works normally, without unwanted function hiding.

X-SVN-Rev: 33457
This commit is contained in:
Andy Heninger 2013-03-21 22:09:06 +00:00
parent 600e3d4a59
commit 3b379f4c28
12 changed files with 14 additions and 657 deletions

View File

@ -1,6 +1,6 @@
/* /*
******************************************************************************* *******************************************************************************
* Copyright (C) 1997-2012, International Business Machines Corporation and * * Copyright (C) 1997-2013, International Business Machines Corporation and *
* others. All Rights Reserved. * * others. All Rights Reserved. *
******************************************************************************* *******************************************************************************
* *
@ -490,18 +490,6 @@ ChoiceFormat::format(const Formattable* objs,
return appendTo; return appendTo;
} }
// -------------------------------------
// Formats an array of objects. Checks if the data type of the objects
// to get the right value for formatting.
UnicodeString&
ChoiceFormat::format(const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const
{
return NumberFormat::format(obj, appendTo, pos, status);
}
// ------------------------------------- // -------------------------------------
void void
@ -571,17 +559,6 @@ ChoiceFormat::matchStringUntilLimitPart(
} }
} }
// -------------------------------------
// Parses the text and return the Formattable object.
void
ChoiceFormat::parse(const UnicodeString& text,
Formattable& result,
UErrorCode& status) const
{
NumberFormat::parse(text, result, status);
}
// ------------------------------------- // -------------------------------------
Format* Format*

View File

@ -1492,15 +1492,6 @@ DecimalFormat::_format(const DigitList &number,
return subformat(appendTo, handler, adjustedNum, FALSE, status); return subformat(appendTo, handler, adjustedNum, FALSE, status);
} }
UnicodeString&
DecimalFormat::format( const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& fieldPosition,
UErrorCode& status) const
{
return NumberFormat::format(obj, appendTo, fieldPosition, status);
}
/** /**
* Return true if a grouping separator belongs at the given * Return true if a grouping separator belongs at the given
* position, based on whether grouping is in use and the values of * position, based on whether grouping is in use and the values of
@ -1900,14 +1891,6 @@ void DecimalFormat::addPadding(UnicodeString& appendTo,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void
DecimalFormat::parse(const UnicodeString& text,
Formattable& result,
UErrorCode& status) const
{
NumberFormat::parse(text, result, status);
}
void void
DecimalFormat::parse(const UnicodeString& text, DecimalFormat::parse(const UnicodeString& text,
Formattable& result, Formattable& result,

View File

@ -1,6 +1,6 @@
/* /*
******************************************************************************* *******************************************************************************
* Copyright (C) 1997-2012, International Business Machines Corporation * Copyright (C) 1997-2013, International Business Machines Corporation
* and others. All Rights Reserved. * and others. All Rights Reserved.
******************************************************************************* *******************************************************************************
*/ */
@ -1110,16 +1110,6 @@ RuleBasedNumberFormat::format(int64_t number,
} }
// make linker happy
UnicodeString&
RuleBasedNumberFormat::format(const Formattable& obj,
UnicodeString& toAppendTo,
FieldPosition& pos,
UErrorCode& status) const
{
return NumberFormat::format(obj, toAppendTo, pos, status);
}
UnicodeString& UnicodeString&
RuleBasedNumberFormat::format(double number, RuleBasedNumberFormat::format(double number,
const UnicodeString& ruleSetName, const UnicodeString& ruleSetName,

View File

@ -2037,21 +2037,6 @@ ExitParse:
} }
} }
UDate
SimpleDateFormat::parse( const UnicodeString& text,
ParsePosition& pos) const {
// redefined here because the other parse() function hides this function's
// cunterpart on DateFormat
return DateFormat::parse(text, pos);
}
UDate
SimpleDateFormat::parse(const UnicodeString& text, UErrorCode& status) const
{
// redefined here because the other parse() function hides this function's
// counterpart on DateFormat
return DateFormat::parse(text, status);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
static UBool static UBool

View File

@ -1,6 +1,6 @@
/* /*
******************************************************************************** ********************************************************************************
* Copyright (C) 1997-2011, International Business Machines * Copyright (C) 1997-2013, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
******************************************************************************** ********************************************************************************
* *
@ -420,67 +420,8 @@ public:
UnicodeString& appendTo, UnicodeString& appendTo,
FieldPosition& pos, FieldPosition& pos,
UErrorCode& success) const; UErrorCode& success) const;
/**
* Formats an object using this object's choices.
*
*
* @param obj The object to be formatted.
* @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.
* @return Reference to 'appendTo' parameter.
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
*/
virtual UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
/** using NumberFormat::parse;
* Redeclared NumberFormat method.
*
* @param obj The object to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param status Output param set to success/failure code on
* exit.
* @return Reference to 'appendTo' parameter.
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
*/
UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const;
/**
* Redeclared NumberFormat method.
* Formats a double number. These methods call the NumberFormat
* pure virtual format() methods with the default FieldPosition.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @return Reference to 'appendTo' parameter.
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
*/
UnicodeString& format( double number,
UnicodeString& appendTo) const;
/**
* Redeclared NumberFormat method.
* Formats an int32_t number. These methods call the NumberFormat
* pure virtual format() methods with the default FieldPosition.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @return Reference to 'appendTo' parameter.
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
*/
UnicodeString& format( int32_t number,
UnicodeString& appendTo) const;
/** /**
* Looks for the longest match of any message string on the input text and, * Looks for the longest match of any message string on the input text and,
@ -500,22 +441,6 @@ public:
Formattable& result, Formattable& result,
ParsePosition& parsePosition) const; ParsePosition& parsePosition) const;
/**
* Looks for the longest match of any message string on the input text and,
* if there is a match, sets the result object to the corresponding range's number.
*
* If no string matches, then the UErrorCode is set to U_INVALID_FORMAT_ERROR.
*
* @param text The text to be parsed.
* @param result Formattable to be set to the parse result.
* If parse fails, return contents are undefined.
* @param status Output param with the formatted string.
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
*/
virtual void parse(const UnicodeString& text,
Formattable& result,
UErrorCode& status) const;
/** /**
* Returns a unique class ID POLYMORPHICALLY. Part of ICU's "poor man's RTTI". * Returns a unique class ID POLYMORPHICALLY. Part of ICU's "poor man's RTTI".
* *
@ -659,26 +584,7 @@ private:
// int32_t fCount; // int32_t fCount;
}; };
inline UnicodeString&
ChoiceFormat::format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const {
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
return NumberFormat::format(obj, appendTo, status);
}
inline UnicodeString&
ChoiceFormat::format(double number,
UnicodeString& appendTo) const {
return NumberFormat::format(number, appendTo);
}
inline UnicodeString&
ChoiceFormat::format(int32_t number,
UnicodeString& appendTo) const {
return NumberFormat::format(number, appendTo);
}
U_NAMESPACE_END U_NAMESPACE_END
#endif // U_HIDE_DEPRECATED_API #endif // U_HIDE_DEPRECATED_API

View File

@ -1,6 +1,6 @@
/* /*
******************************************************************************** ********************************************************************************
* Copyright (C) 1997-2012, International Business Machines * Copyright (C) 1997-2013, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
******************************************************************************** ********************************************************************************
* *
@ -372,20 +372,6 @@ public:
*/ */
UnicodeString& format(UDate date, UnicodeString& appendTo) const; UnicodeString& format(UDate date, UnicodeString& appendTo) const;
/**
* Redeclared Format method.
*
* @param obj The object to be formatted into a string.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const;
/** /**
* Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT" * Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT"
* will be parsed into a UDate that is equivalent to Date(837039928046). * will be parsed into a UDate that is equivalent to Date(837039928046).
@ -781,12 +767,6 @@ public:
#endif /* U_HIDE_OBSOLETE_API */ #endif /* U_HIDE_OBSOLETE_API */
}; };
inline UnicodeString&
DateFormat::format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const {
return Format::format(obj, appendTo, status);
}
U_NAMESPACE_END U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */ #endif /* #if !UCONFIG_NO_FORMATTING */

View File

@ -1104,79 +1104,8 @@ public:
FieldPosition& pos, FieldPosition& pos,
UErrorCode& status) const; UErrorCode& status) const;
using NumberFormat::parse;
/**
* Format a Formattable using base-10 representation.
*
* @param obj The value to be formatted.
* @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 Error code indicating success or failure.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
virtual UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
/**
* Redeclared NumberFormat method.
* Formats an object to produce a string.
*
* @param obj The object to format.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param status Output parameter filled in with success or failure status.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const;
/**
* Redeclared NumberFormat method.
* Format a double number.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(double number,
UnicodeString& appendTo) const;
/**
* Redeclared NumberFormat method.
* Format a long number. These methods call the NumberFormat
* pure virtual format() methods with the default FieldPosition.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(int32_t number,
UnicodeString& appendTo) const;
/**
* Redeclared NumberFormat method.
* Format an int64 number. These methods call the NumberFormat
* pure virtual format() methods with the default FieldPosition.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.8
*/
UnicodeString& format(int64_t number,
UnicodeString& appendTo) const;
/** /**
* Parse the given string using this object's choices. The method * Parse the given string using this object's choices. The method
* does string comparisons to try to find an optimal match. * does string comparisons to try to find an optimal match.
@ -1200,19 +1129,6 @@ public:
Formattable& result, Formattable& result,
ParsePosition& parsePosition) const; ParsePosition& parsePosition) const;
// Declare here again to get rid of function hiding problems.
/**
* Parse the given string using this object's choices.
*
* @param text The text to be parsed.
* @param result Formattable to be set to the parse result.
* @param status Output parameter filled in with success or failure status.
* @stable ICU 2.0
*/
virtual void parse(const UnicodeString& text,
Formattable& result,
UErrorCode& status) const;
/** /**
* Parses text from the given string as a currency amount. Unlike * Parses text from the given string as a currency amount. Unlike
* the parse() method, this method will attempt to parse a generic * the parse() method, this method will attempt to parse a generic
@ -2437,29 +2353,6 @@ protected:
#endif #endif
}; };
inline UnicodeString&
DecimalFormat::format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const {
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
return NumberFormat::format(obj, appendTo, status);
}
inline UnicodeString&
DecimalFormat::format(double number,
UnicodeString& appendTo) const {
FieldPosition pos(0);
return format(number, appendTo, pos);
}
inline UnicodeString&
DecimalFormat::format(int32_t number,
UnicodeString& appendTo) const {
FieldPosition pos(0);
return format((int64_t)number, appendTo, pos);
}
inline const UnicodeString & inline const UnicodeString &
DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const { DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
return fSymbols->getConstSymbol(symbol); return fSymbols->getConstSymbol(symbol);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007-2012, International Business Machines Corporation and * Copyright (C) 2007-2013, International Business Machines Corporation and
* others. All Rights Reserved. * others. All Rights Reserved.
******************************************************************************** ********************************************************************************
* *
@ -695,25 +695,6 @@ public:
FieldPosition& pos, FieldPosition& pos,
UErrorCode& status) const; UErrorCode& status) const;
/**
* Formats the given array of arguments into a user-readable
* string. The array must be stored within a single Formattable
* object of type kArray. If the Formattable object type is not of
* type kArray, then returns a failing UErrorCode.
*
* @param obj The object to format
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param status Input/output error code. If the
* pattern cannot be parsed, set to failure code.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const;
/** /**
* Formats the given array of arguments into a user-defined argument name * Formats the given array of arguments into a user-defined argument name
* array. This function supports both named and numbered * array. This function supports both named and numbered
@ -1092,14 +1073,6 @@ private:
friend class MessageFormatAdapter; // getFormatTypeList() access friend class MessageFormatAdapter; // getFormatTypeList() access
}; };
inline UnicodeString&
MessageFormat::format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const {
return Format::format(obj, appendTo, status);
}
U_NAMESPACE_END U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */ #endif /* #if !UCONFIG_NO_FORMATTING */

View File

@ -569,20 +569,6 @@ public:
public: public:
/**
* Redeclared Format method.
* @param obj The object to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param status Output parameter set to a failure error code
* when a failure occurs.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const;
/** /**
* Return a long if possible (e.g. within range LONG_MAX, * Return a long if possible (e.g. within range LONG_MAX,
* LONG_MAX], and with no decimals), otherwise a double. If * LONG_MAX], and with no decimals), otherwise a double. If
@ -1127,13 +1113,6 @@ NumberFormat::isLenient() const
return fLenient; return fLenient;
} }
inline UnicodeString&
NumberFormat::format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const {
return Format::format(obj, appendTo, status);
}
U_NAMESPACE_END U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */ #endif /* #if !UCONFIG_NO_FORMATTING */

View File

@ -450,10 +450,12 @@ public:
*/ */
virtual Format* clone(void) const; virtual Format* clone(void) const;
/** /**
* Redeclared Format method. * Formats a plural message for a number taken from a Formattable object.
* *
* @param obj The object to be formatted into a string. * @param obj The object containing a number for which the
* plural message should be formatted.
* The object must be of a numeric type.
* @param appendTo output parameter to receive result. * @param appendTo output parameter to receive result.
* Result is appended to existing contents. * Result is appended to existing contents.
* @param pos On input: an alignment field, if desired. * @param pos On input: an alignment field, if desired.

View File

@ -808,50 +808,7 @@ public:
FieldPosition& pos, FieldPosition& pos,
UErrorCode& status) const; UErrorCode& status) const;
/** using NumberFormat::parse;
* Formats the specified number using the default ruleset.
* @param obj The number to format.
* @param toAppendTo the string that will hold the (appended) result
* @param pos the fieldposition
* @param status the status
* @return A textual representation of the number.
* @stable ICU 2.0
*/
virtual UnicodeString& format(const Formattable& obj,
UnicodeString& toAppendTo,
FieldPosition& pos,
UErrorCode& status) const;
/**
* Redeclared Format method.
* @param obj the object to be formatted.
* @param result Output param which will receive the formatted string.
* @param status Output param set to success/failure code
* @return A reference to 'result'.
* @stable ICU 2.0
*/
UnicodeString& format(const Formattable& obj,
UnicodeString& result,
UErrorCode& status) const;
/**
* Redeclared NumberFormat method.
* @param number the double value to be formatted.
* @param output Output param which will receive the formatted string.
* @return A reference to 'output'.
* @stable ICU 2.0
*/
UnicodeString& format(double number,
UnicodeString& output) const;
/**
* Redeclared NumberFormat method.
* @param number the long value to be formatted.
* @param output Output param which will receive the formatted string.
* @return A reference to 'output'.
* @stable ICU 2.0
*/
UnicodeString& format(int32_t number,
UnicodeString& output) const;
/** /**
* Parses the specfied string, beginning at the specified position, according * Parses the specfied string, beginning at the specified position, according
@ -871,18 +828,6 @@ public:
Formattable& result, Formattable& result,
ParsePosition& parsePosition) const; ParsePosition& parsePosition) const;
/**
* Redeclared Format method.
* @param text The string to parse
* @param result the result of the parse, either a double or a long.
* @param status Output param set to failure code when a problem occurs.
* @stable ICU 2.0
*/
virtual inline void parse(const UnicodeString& text,
Formattable& result,
UErrorCode& status) const;
#if !UCONFIG_NO_COLLATION #if !UCONFIG_NO_COLLATION
/** /**
@ -1024,37 +969,6 @@ private:
// --------------- // ---------------
inline UnicodeString&
RuleBasedNumberFormat::format(const Formattable& obj,
UnicodeString& result,
UErrorCode& status) const
{
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
// dlf - the above comment is bogus, if there were a reason to modify
// it, it would be virtual, and there's no reason because it is
// a one-line macro in NumberFormat anyway, just like this one.
return NumberFormat::format(obj, result, status);
}
inline UnicodeString&
RuleBasedNumberFormat::format(double number, UnicodeString& output) const {
FieldPosition pos(0);
return format(number, output, pos);
}
inline UnicodeString&
RuleBasedNumberFormat::format(int32_t number, UnicodeString& output) const {
FieldPosition pos(0);
return format(number, output, pos);
}
inline void
RuleBasedNumberFormat::parse(const UnicodeString& text, Formattable& result, UErrorCode& status) const
{
NumberFormat::parse(text, result, status);
}
#if !UCONFIG_NO_COLLATION #if !UCONFIG_NO_COLLATION
inline UBool inline UBool

View File

@ -901,108 +901,7 @@ public:
FieldPositionIterator* posIter, FieldPositionIterator* posIter,
UErrorCode& status) const; UErrorCode& status) const;
/** using DateFormat::parse;
* Format a date or time, which is the standard millis since 24:00 GMT, Jan
* 1, 1970. Overrides DateFormat pure virtual method.
* <P>
* Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
* 1996.07.10 AD at 15:08:56 PDT
*
* @param obj A Formattable containing the date-time value to be formatted
* into a date-time string. If the type of the Formattable
* is a numeric type, it is treated as if it were an
* instance of Date.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos The formatting position. On input: an alignment field,
* if desired. On output: the offsets of the alignment field.
* @param status Input/output param set to success/failure code.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
virtual UnicodeString& format( const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
/**
* Format a date or time, which is the standard millis since 24:00 GMT, Jan
* 1, 1970. Overrides DateFormat pure virtual method.
* <P>
* Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
* 1996.07.10 AD at 15:08:56 PDT
*
* @param obj A Formattable containing the date-time value to be formatted
* into a date-time string. If the type of the Formattable
* is a numeric type, it is treated as if it were an
* instance of Date.
* @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. Field values
* are defined in UDateFormatField.
* @param status Input/output param set to success/failure code.
* @return Reference to 'appendTo' parameter.
* @stable ICU 4.4
*/
virtual UnicodeString& format( const Formattable& obj,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Redeclared DateFormat method.
* @param date the Date value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param fieldPosition The formatting position. On input: an alignment field,
* if desired. On output: the offsets of the alignment field.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.1
*/
UnicodeString& format(UDate date,
UnicodeString& appendTo,
FieldPosition& fieldPosition) const;
/**
* Redeclared DateFormat method.
* @param date the Date value to be formatted.
* @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. Field values
* are defined in UDateFormatField.
* @param status Input/output param set to success/failure code.
* @return Reference to 'appendTo' parameter.
* @stable ICU 4.4
*/
UnicodeString& format(UDate date,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Redeclared DateFormat method.
* @param obj Object to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param status Input/output success/failure code.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const;
/**
* Redeclared DateFormat method.
* @param date Date value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @return Reference to 'appendTo' parameter.
* @stable ICU 2.0
*/
UnicodeString& format(UDate date, UnicodeString& appendTo) const;
/** /**
* Parse a date/time string beginning at the given parse position. For * Parse a date/time string beginning at the given parse position. For
@ -1034,75 +933,6 @@ public:
Calendar& cal, Calendar& cal,
ParsePosition& pos) const; ParsePosition& pos) const;
/**
* Parse a date/time string starting at the given parse position. For
* example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
* that is equivalent to Date(837039928046).
* <P>
* By default, parsing is lenient: If the input is not in the form used by
* this object's format method but can still be parsed as a date, then the
* parse succeeds. Clients may insist on strict adherence to the format by
* calling setLenient(false).
* @see DateFormat::setLenient(boolean)
* <P>
* Note that the normal date formats associated with some calendars - such
* as the Chinese lunar calendar - do not specify enough fields to enable
* dates to be parsed unambiguously. In the case of the Chinese lunar
* calendar, while the year within the current 60-year cycle is specified,
* the number of such cycles since the start date of the calendar (in the
* ERA field of the Calendar object) is not normally part of the format,
* and parsing may assume the wrong era. For cases such as this it is
* recommended that clients parse using the method
* parse(const UnicodeString&, Calendar& cal, ParsePosition&)
* with the Calendar passed in set to the current date, or to a date
* within the era/cycle that should be assumed if absent in the format.
*
* @param text The date/time string to be parsed
* @param pos On input, the position at which to start parsing; on
* output, the position at which parsing terminated, or the
* start position if the parse failed.
* @return A valid UDate if the input could be parsed.
* @stable ICU 2.0
*/
UDate parse( const UnicodeString& text,
ParsePosition& pos) const;
/**
* Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT"
* will be parsed into a UDate that is equivalent to Date(837039928046).
* Parsing begins at the beginning of the string and proceeds as far as
* possible. Assuming no parse errors were encountered, this function
* doesn't return any information about how much of the string was consumed
* by the parsing. If you need that information, use the version of
* parse() that takes a ParsePosition.
* <P>
* By default, parsing is lenient: If the input is not in the form used by
* this object's format method but can still be parsed as a date, then the
* parse succeeds. Clients may insist on strict adherence to the format by
* calling setLenient(false).
* @see DateFormat::setLenient(boolean)
* <P>
* Note that the normal date formats associated with some calendars - such
* as the Chinese lunar calendar - do not specify enough fields to enable
* dates to be parsed unambiguously. In the case of the Chinese lunar
* calendar, while the year within the current 60-year cycle is specified,
* the number of such cycles since the start date of the calendar (in the
* ERA field of the Calendar object) is not normally part of the format,
* and parsing may assume the wrong era. For cases such as this it is
* recommended that clients parse using the method
* parse(const UnicodeString&, Calendar& cal, ParsePosition&)
* with the Calendar passed in set to the current date, or to a date
* within the era/cycle that should be assumed if absent in the format.
*
* @param text The date/time string to be parsed into a UDate value.
* @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
* an error value if there was a parse error.
* @return A valid UDate if the input could be parsed.
* @stable ICU 2.0
*/
virtual UDate parse( const UnicodeString& text,
UErrorCode& status) const;
/** /**
* Set the start UDate used to interpret two-digit year strings. * Set the start UDate used to interpret two-digit year strings.
@ -1714,61 +1544,6 @@ SimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const
return fDefaultCenturyStart; return fDefaultCenturyStart;
} }
inline UnicodeString&
SimpleDateFormat::format(const Formattable& obj,
UnicodeString& appendTo,
UErrorCode& status) const {
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
return DateFormat::format(obj, appendTo, status);
}
inline UnicodeString&
SimpleDateFormat::format(const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const
{
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
return DateFormat::format(obj, appendTo, pos, status);
}
inline UnicodeString&
SimpleDateFormat::format(const Formattable& obj,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const
{
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
return DateFormat::format(obj, appendTo, posIter, status);
}
inline UnicodeString&
SimpleDateFormat::format(UDate date,
UnicodeString& appendTo,
FieldPosition& fieldPosition) const {
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
return DateFormat::format(date, appendTo, fieldPosition);
}
inline UnicodeString&
SimpleDateFormat::format(UDate date,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const {
// Don't use Format:: - use immediate base class only,
// in case immediate base modifies behavior later.
return DateFormat::format(date, appendTo, posIter, status);
}
inline UnicodeString&
SimpleDateFormat::format(UDate date, UnicodeString& appendTo) const {
return DateFormat::format(date, appendTo);
}
U_NAMESPACE_END U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */ #endif /* #if !UCONFIG_NO_FORMATTING */