Movatterモバイル変換


[0]ホーム

URL:


ICU 78.2  78.2
Public Member Functions |Static Public Member Functions |Protected Member Functions
icu::MeasureFormat Class Reference

#include <measfmt.h>

Inheritance diagram for icu::MeasureFormat:

Public Member Functions

 MeasureFormat (constLocale &locale,UMeasureFormatWidth width,UErrorCode &status)
 Constructor.More...
 
 MeasureFormat (constLocale &locale,UMeasureFormatWidth width,NumberFormat *nfToAdopt,UErrorCode &status)
 Constructor.More...
 
 MeasureFormat (constMeasureFormat &other)
 Copy constructor.More...
 
MeasureFormatoperator= (constMeasureFormat &rhs)
 Assignment operator.More...
 
virtual ~MeasureFormat ()
 Destructor.More...
 
virtual bool operator== (constFormat &other) const override
 Return true if givenFormat objects are semantically equal.More...
 
virtualMeasureFormatclone () const override
 Clones this object polymorphically.More...
 
virtualUnicodeStringformat (constFormattable &obj,UnicodeString &appendTo,FieldPosition &pos,UErrorCode &status) const override
 Formats object to produce a string.More...
 
virtual void parseObject (constUnicodeString &source,Formattable &reslt,ParsePosition &pos) const override
 Parse a string to produce an object.More...
 
UnicodeStringformatMeasures (constMeasure *measures, int32_t measureCount,UnicodeString &appendTo,FieldPosition &pos,UErrorCode &status) const
 Formats measure objects to produce a string.More...
 
UnicodeStringformatMeasurePerUnit (constMeasure &measure, constMeasureUnit &perUnit,UnicodeString &appendTo,FieldPosition &pos,UErrorCode &status) const
 Formats a single measure per unit.More...
 
UnicodeString getUnitDisplayName (constMeasureUnit &unit,UErrorCode &status) const
 Gets the display name of the specifiedMeasureUnit corresponding to the current locale and format width.More...
 
virtualUClassID getDynamicClassID () const override
 Returns a unique class ID POLYMORPHICALLY.More...
 
virtualU_I18N_API void parseObject (constUnicodeString &source,Formattable &result,ParsePosition &parse_pos) const=0
 Parse a string to produce an object.More...
 
U_I18N_API void parseObject (constUnicodeString &source,Formattable &result,UErrorCode &status) const
 Parses a string to produce an object.More...
 
U_I18N_APIUnicodeStringformat (constFormattable &obj,UnicodeString &appendTo,UErrorCode &status) const
 Formats an object to produce a string.More...
 
virtualU_I18N_APIUnicodeStringformat (constFormattable &obj,UnicodeString &appendTo,FieldPosition &pos,UErrorCode &status) const=0
 Format an object to produce a string.More...
 
virtualU_I18N_APIUnicodeStringformat (constFormattable &obj,UnicodeString &appendTo,FieldPositionIterator *posIter,UErrorCode &status) const
 Format an object to produce a string.More...
 
- Public Member Functions inherited fromicu::Format
virtualU_I18N_API ~Format ()
 Destructor.More...
 
U_I18N_API bool operator!= (constFormat &other) const
 Return true if the givenFormat objects are not semantically equal.More...
 
U_I18N_APIUnicodeStringformat (constFormattable &obj,UnicodeString &appendTo,UErrorCode &status) const
 Formats an object to produce a string.More...
 
virtualU_I18N_APIUnicodeStringformat (constFormattable &obj,UnicodeString &appendTo,FieldPositionIterator *posIter,UErrorCode &status) const
 Format an object to produce a string.More...
 
U_I18N_API void parseObject (constUnicodeString &source,Formattable &result,UErrorCode &status) const
 Parses a string to produce an object.More...
 
U_I18N_APILocale getLocale (ULocDataLocaleType type,UErrorCode &status) const
 Get the locale for this format object.More...
 
U_I18N_API const char * getLocaleID (ULocDataLocaleType type,UErrorCode &status) const
 Get the locale for this format object.More...
 
- Public Member Functions inherited fromicu::UObject
virtual ~UObject ()
 Destructor.More...
 

Static Public Member Functions

staticMeasureFormatcreateCurrencyFormat (constLocale &locale,UErrorCode &ec)
 Return a formatter forCurrencyAmount objects in the given locale.More...
 
staticMeasureFormatcreateCurrencyFormat (UErrorCode &ec)
 Return a formatter forCurrencyAmount objects in the default locale.More...
 
staticUClassID getStaticClassID ()
 Return the class ID for this class.More...
 

Protected Member Functions

 MeasureFormat ()
 Default constructor.More...
 
void initMeasureFormat (constLocale &locale,UMeasureFormatWidth width,NumberFormat *nfToAdopt,UErrorCode &status)
 ICU use only.More...
 
UBool setMeasureFormatLocale (constLocale &locale,UErrorCode &status)
 ICU use only.More...
 
void adoptNumberFormat (NumberFormat *nfToAdopt,UErrorCode &status)
 ICU use only.More...
 
constNumberFormatgetNumberFormatInternal () const
 ICU use only.More...
 
constNumberFormatgetCurrencyFormatInternal () const
 ICU use only.More...
 
constPluralRulesgetPluralRules () const
 ICU use only.More...
 
Locale getLocale (UErrorCode &status) const
 ICU use only.More...
 
const char * getLocaleID (UErrorCode &status) const
 ICU use only.More...
 
- Protected Member Functions inherited fromicu::Format
U_I18N_API void setLocaleIDs (const char *valid, const char *actual)
 
U_I18N_API Format ()
 Default constructor for subclass use only.More...
 
U_I18N_API Format (constFormat &)
 
U_I18N_APIFormatoperator= (constFormat &)
 

Additional Inherited Members

- Static Protected Member Functions inherited fromicu::Format
staticU_I18N_API void syntaxError (constUnicodeString &pattern, int32_t pos,UParseError &parseError)
 Simple function for initializing aUParseError from aUnicodeString.More...
 

Detailed Description

IMPORTANT: New users are strongly encouraged to see ifnumberformatter.h fits their use case. Although not deprecated, this header is provided for backwards compatibility only, and has much more limited capabilities.

See also
Format
Author
Alan Liu
Stable:
ICU 3.0

Definition at line101 of filemeasfmt.h.

Constructor & Destructor Documentation

◆ MeasureFormat()[1/4]

icu::MeasureFormat::MeasureFormat(constLocalelocale,
UMeasureFormatWidth width,
UErrorCodestatus 
)

Constructor.

NOTE: New users are strongly encouraged to useicu::number::NumberFormatter instead ofNumberFormat.

Stable:
ICU 53

◆ MeasureFormat()[2/4]

icu::MeasureFormat::MeasureFormat(constLocalelocale,
UMeasureFormatWidth width,
NumberFormatnfToAdopt,
UErrorCodestatus 
)

Constructor.

NOTE: New users are strongly encouraged to useicu::number::NumberFormatter instead ofNumberFormat.

Stable:
ICU 53

◆ MeasureFormat()[3/4]

icu::MeasureFormat::MeasureFormat(constMeasureFormatother)

Copy constructor.

Stable:
ICU 3.0

◆ ~MeasureFormat()

virtual icu::MeasureFormat::~MeasureFormat()
virtual

Destructor.

Stable:
ICU 3.0

◆ MeasureFormat()[4/4]

icu::MeasureFormat::MeasureFormat()
protected

Default constructor.

Stable:
ICU 3.0

Member Function Documentation

◆ adoptNumberFormat()

void icu::MeasureFormat::adoptNumberFormat(NumberFormatnfToAdopt,
UErrorCodestatus 
)
protected

ICU use only.

Let subclass changeNumberFormat.

Internal:
Do not use. This API is for internal use only..

◆ clone()

virtualMeasureFormat* icu::MeasureFormat::clone() const
overridevirtual

Clones this object polymorphically.

Stable:
ICU 53

Implementsicu::Format.

Reimplemented inicu::TimeUnitFormat.

◆ createCurrencyFormat()[1/2]

staticMeasureFormat* icu::MeasureFormat::createCurrencyFormat(constLocalelocale,
UErrorCodeec 
)
static

Return a formatter forCurrencyAmount objects in the given locale.

NOTE: New users are strongly encouraged to useicu::number::NumberFormatter instead ofNumberFormat.

Parameters
localedesired locale
ecinput-output error code
Returns
a formatter object, or nullptr upon error
Stable:
ICU 3.0

◆ createCurrencyFormat()[2/2]

staticMeasureFormat* icu::MeasureFormat::createCurrencyFormat(UErrorCodeec)
static

Return a formatter forCurrencyAmount objects in the default locale.

NOTE: New users are strongly encouraged to useicu::number::NumberFormatter instead ofNumberFormat.

Parameters
ecinput-output error code
Returns
a formatter object, or nullptr upon error
Stable:
ICU 3.0

◆ format()[1/4]

virtualUnicodeString& icu::MeasureFormat::format(constFormattableobj,
UnicodeStringappendTo,
FieldPositionpos,
UErrorCodestatus 
) const
overridevirtual

Formats object to produce a string.

Stable:
ICU 53

Implementsicu::Format.

◆ format()[2/4]

virtualU_I18N_APIUnicodeString& icu::Format::format

Format an object to produce a string.

This is a pure virtual method which subclasses must implement. This method allows polymorphic formatting ofFormattable objects. If a subclass ofFormat receives aFormattable object type it doesn't handle (e.g., if a numericFormattable is passed to aDateFormat object) then it returns a failing UErrorCode.

Parameters
objThe object to format.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

◆ format()[3/4]

virtualU_I18N_APIUnicodeString& icu::Format::format

Format an object to produce a string.

Subclasses should override this method. This method allows polymorphic formatting ofFormattable objects. If a subclass ofFormat receives aFormattable object type it doesn't handle (e.g., if a numericFormattable is passed to aDateFormat object) then it returns a failing UErrorCode.

Parameters
objThe object to format.
appendToOutput parameter to receive result. Result is appended to existing contents.
posIterOn return, can be used to iterate over positions of fields generated by this format call.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 4.4

◆ format()[4/4]

U_I18N_APIUnicodeString& icu::Format::format

Formats an object to produce a string.

Parameters
objThe object to format.
appendToOutput parameter to receive result. Result is appended to existing contents.
statusOutput parameter filled in with success or failure status.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

◆ formatMeasurePerUnit()

UnicodeString& icu::MeasureFormat::formatMeasurePerUnit(constMeasuremeasure,
constMeasureUnitperUnit,
UnicodeStringappendTo,
FieldPositionpos,
UErrorCodestatus 
) const

Formats a single measure per unit.

An example of such a formatted string is 3.5 meters per second.

Parameters
measureThe measure object. In above example, 3.5 meters.
perUnitThe per unit. In above example, it is*MeasureUnit::createSecond(status).
appendToformatted string appended here.
posthe field position.
statusthe error.
Returns
appendTo reference
Stable:
ICU 55

◆ formatMeasures()

UnicodeString& icu::MeasureFormat::formatMeasures(constMeasuremeasures,
int32_t measureCount,
UnicodeStringappendTo,
FieldPositionpos,
UErrorCodestatus 
) const

Formats measure objects to produce a string.

An example of such a formatted string is 3 meters, 3.5 centimeters.Measure objects appear in the formatted string in the same order they appear in the "measures" array. TheNumberFormat of this object is used only to format the amount of the very last measure. The other amounts are formatted with zero decimal places while rounding toward zero.

Parameters
measuresarray of measure objects.
measureCountthe number of measure objects.
appendToformatted string appended here.
posthe field position.
statusthe error.
Returns
appendTo reference
Stable:
ICU 53

◆ getCurrencyFormatInternal()

constNumberFormat& icu::MeasureFormat::getCurrencyFormatInternal() const
protected

ICU use only.

Always returns the short form currency formatter.

Internal:
Do not use. This API is for internal use only..

◆ getDynamicClassID()

virtualUClassID icu::MeasureFormat::getDynamicClassID() const
overridevirtual

Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphicoperator==() andclone() methods call this method.

Returns
The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.
Stable:
ICU 53

Reimplemented fromicu::UObject.

Reimplemented inicu::TimeUnitFormat.

◆ getLocale()

Locale icu::MeasureFormat::getLocale(UErrorCodestatus) const
protected

ICU use only.

Internal:
Do not use. This API is for internal use only..

◆ getLocaleID()

const char* icu::MeasureFormat::getLocaleID(UErrorCodestatus) const
protected

ICU use only.

Internal:
Do not use. This API is for internal use only..

◆ getNumberFormatInternal()

constNumberFormat& icu::MeasureFormat::getNumberFormatInternal() const
protected

ICU use only.

Internal:
Do not use. This API is for internal use only..

◆ getPluralRules()

constPluralRules& icu::MeasureFormat::getPluralRules() const
protected

ICU use only.

Internal:
Do not use. This API is for internal use only..

◆ getStaticClassID()

staticUClassID icu::MeasureFormat::getStaticClassID()
static

Return the class ID for this class.

This is useful only for comparing to a return value fromgetDynamicClassID(). For example:

.   Base* polymorphic_pointer = createPolymorphicObject();.   if (polymorphic_pointer->getDynamicClassID() ==.       erived::getStaticClassID()) ...
Returns
The class ID for all objects of this class.
Stable:
ICU 53

◆ getUnitDisplayName()

UnicodeString icu::MeasureFormat::getUnitDisplayName(constMeasureUnitunit,
UErrorCodestatus 
) const

Gets the display name of the specifiedMeasureUnit corresponding to the current locale and format width.

Parameters
unitThe unit for which to get a display name.
statusthe error.
Returns
The display name in the locale and width specified in theMeasureFormat constructor, or null if there is no display name available for the specified unit.
Stable:
ICU 58

◆ initMeasureFormat()

void icu::MeasureFormat::initMeasureFormat(constLocalelocale,
UMeasureFormatWidth width,
NumberFormatnfToAdopt,
UErrorCodestatus 
)
protected

ICU use only.

Initialize or changeMeasureFormat class from subclass.

Internal:
Do not use. This API is for internal use only..

◆ operator=()

MeasureFormat& icu::MeasureFormat::operator=(constMeasureFormatrhs)

Assignment operator.

Stable:
ICU 3.0

◆ operator==()

virtual bool icu::MeasureFormat::operator==(constFormatother) const
overridevirtual

Return true if givenFormat objects are semantically equal.

Stable:
ICU 53

Implementsicu::Format.

◆ parseObject()[1/3]

virtual void icu::MeasureFormat::parseObject(constUnicodeStringsource,
Formattablereslt,
ParsePositionpos 
) const
overridevirtual

Parse a string to produce an object.

This implementation sets status to U_UNSUPPORTED_ERROR.

Draft:
This API may be changed in the future versions and was introduced in ICU 53

Implementsicu::Format.

Reimplemented inicu::TimeUnitFormat.

◆ parseObject()[2/3]

virtualU_I18N_API void icu::Format::parseObject

Parse a string to produce an object.

This is a pure virtual method which subclasses must implement. This method allows polymorphic parsing of strings intoFormattable 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.
Stable:
ICU 2.0

◆ parseObject()[3/3]

U_I18N_API void icu::Format::parseObject

Parses a string to produce an object.

This is a convenience method which calls the pure virtualparseObject() method, and returns a failure UErrorCode if theParsePosition indicates failure.

Parameters
sourceThe string to be parsed into an object.
resultFormattable to be set to the parse result. If parse fails, return contents are undefined.
statusOutput param to be filled with success/failure result code.
Stable:
ICU 2.0

◆ setMeasureFormatLocale()

UBool icu::MeasureFormat::setMeasureFormatLocale(constLocalelocale,
UErrorCodestatus 
)
protected

ICU use only.

Allows subclass to change locale. Note that this method also changes theNumberFormat object. Returns true if locale changed; false if no change was made.

Internal:
Do not use. This API is for internal use only..

The documentation for this class was generated from the following file:

Generated by doxygen 1.9.1
[8]ページ先頭

©2009-2026 Movatter.jp