Logo Search packages:      
Sourcecode: icu version File versions  Download package

virtual void Format::parseObject ( const UnicodeString source,
Formattable result,
ParsePosition parse_pos 
) const [pure virtual, inherited]

Parse a string to produce an object. This is a pure virtual method which subclasses must implement. This method allows polymorphic parsing of strings into Formattable objects.

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

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

Example:

Parsing "_12_xy" (where _ represents a space) for a number, with index == 0 will result in the number 12, with parse_pos.index updated to 3 (just before the second space). Parsing a second time will result in a failing UErrorCode since "xy" is not a number, and leave index at 3.

Subclasses will typically supply specific parse methods that return different types of values. Since methods can't overload on return types, these will typically be named "parse", while this polymorphic method will always be called parseObject. Any parse method that does not take a parse_pos should set status to an error value when no text in the required format is at the start position.

Parameters:
sourceThe string to be parsed into an object.
resultFormattable to be set to the parse result. If parse fails, return contents are undefined.
parse_posThe position to start parsing at. Upon return this param is set to the position after the last character successfully parsed. If the source is not parsed successfully, this param will remain unchanged. ICU 2.0

Implemented in MessageFormat::DummyFormat, MessageFormat, DateFormat, PluralFormat, DateIntervalFormat, SelectFormat, NumberFormat, TimeUnitFormat, and CurrencyFormat.

Referenced by Format::parseObject().

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index