ICU 73.2  73.2
Public Member Functions | Friends
icu::FormattedList Class Reference

An immutable class containing the result of a list formatting operation. More...

#include <listformatter.h>

Inheritance diagram for icu::FormattedList:
icu::UMemory icu::FormattedValue

Public Member Functions

 FormattedList ()
 Default constructor; makes an empty FormattedList.
 FormattedList (FormattedList &&src) noexcept
 Move constructor: Leaves the source FormattedList in an undefined state.
virtual ~FormattedList () override
 Destruct an instance of FormattedList.
 FormattedList (const FormattedList &)
 Copying not supported; use move constructor instead.
FormattedListoperator= (const FormattedList &)
 Copying not supported; use move assignment instead.
FormattedListoperator= (FormattedList &&src) noexcept
 Move assignment: Leaves the source FormattedList in an undefined state.
UnicodeString toString (UErrorCode &status) const override
UnicodeString toTempString (UErrorCode &status) const override
AppendableappendTo (Appendable &appendable, UErrorCode &status) const override
UBool nextPosition (ConstrainedFieldPosition &cfpos, UErrorCode &status) const override

Friends

class ListFormatter

Detailed Description

An immutable class containing the result of a list formatting operation.

Instances of this class are immutable and thread-safe.

When calling nextPosition(): The fields are returned from start to end. The special field category UFIELD_CATEGORY_LIST_SPAN is used to indicate which argument was inserted at the given position. The span category will always occur before the corresponding instance of UFIELD_CATEGORY_LIST in the nextPosition() iterator.

Not intended for public subclassing.

Stable:
ICU 64

Definition at line 86 of file listformatter.h.


Constructor & Destructor Documentation

Default constructor; makes an empty FormattedList.

Stable:
ICU 64

Definition at line 92 of file listformatter.h.

Move constructor: Leaves the source FormattedList in an undefined state.

Stable:
ICU 64
virtual icu::FormattedList::~FormattedList ( ) [override, virtual]

Destruct an instance of FormattedList.

Stable:
ICU 64

Copying not supported; use move constructor instead.


Member Function Documentation

Appendable& icu::FormattedList::appendTo ( Appendable appendable,
UErrorCode status 
) const [override, virtual]

Appends the formatted string to an Appendable.

Parameters:
appendableThe Appendable to which to append the string output.
statusSet if an error occurs.
Returns:
The same Appendable, for chaining.
Stable:
ICU 64
See also:
Appendable

Implements icu::FormattedValue.

UBool icu::FormattedList::nextPosition ( ConstrainedFieldPosition cfpos,
UErrorCode status 
) const [override, virtual]

Iterates over field positions in the FormattedValue.

This lets you determine the position of specific types of substrings, like a month or a decimal separator.

To loop over all field positions:

ConstrainedFieldPosition cfpos; while (fmtval.nextPosition(cfpos, status)) { // handle the field position; get information from cfpos }

Parameters:
cfposThe object used for iteration state. This can provide constraints to iterate over only one specific category or field; see ConstrainedFieldPosition::constrainCategory and ConstrainedFieldPosition::constrainField.
statusSet if an error occurs.
Returns:
true if a new occurrence of the field was found; false otherwise or if an error was set.
Stable:
ICU 64

Implements icu::FormattedValue.

FormattedList& icu::FormattedList::operator= ( const FormattedList )

Copying not supported; use move assignment instead.

FormattedList& icu::FormattedList::operator= ( FormattedList &&  src)

Move assignment: Leaves the source FormattedList in an undefined state.

Stable:
ICU 64
UnicodeString icu::FormattedList::toString ( UErrorCode status) const [override, virtual]

Returns the formatted string as a self-contained UnicodeString.

If you need the string within the current scope only, consider toTempString.

Parameters:
statusSet if an error occurs.
Returns:
a UnicodeString containing the formatted string.
Stable:
ICU 64

Implements icu::FormattedValue.

UnicodeString icu::FormattedList::toTempString ( UErrorCode status) const [override, virtual]

Returns the formatted string as a read-only alias to memory owned by the FormattedValue.

The return value is valid only as long as this FormattedValue is present and unchanged in memory. If you need the string outside the current scope, consider toString.

The buffer returned by calling UnicodeString::getBuffer() on the return value is guaranteed to be NUL-terminated.

Parameters:
statusSet if an error occurs.
Returns:
a temporary UnicodeString containing the formatted string.
Stable:
ICU 64

Implements icu::FormattedValue.


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