Loading...
Searching...
No Matches
icu::FormattedRelativeDateTime Class Reference

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

`#include <reldatefmt.h>`

Inheritance diagram for icu::FormattedRelativeDateTime:

## Public Member Functions

| FormattedRelativeDateTime ()
| Default constructor; makes an empty FormattedRelativeDateTime.
| FormattedRelativeDateTime (FormattedRelativeDateTime &&src) noexcept
| Move constructor: Leaves the source FormattedRelativeDateTime in an undefined state.
virtual | ~FormattedRelativeDateTime () override
| Destruct an instance of FormattedRelativeDateTime.
| FormattedRelativeDateTime (const FormattedRelativeDateTime &)=delete
| Copying not supported; use move constructor instead.
FormattedRelativeDateTime & | operator= (const FormattedRelativeDateTime &)=delete
| Copying not supported; use move assignment instead.
FormattedRelativeDateTime & | operator= (FormattedRelativeDateTime &&src) noexcept
| Move assignment: Leaves the source FormattedRelativeDateTime in an undefined state.
UnicodeString | toString (UErrorCode &status) const override
| Returns the formatted string as a self-contained UnicodeString.
UnicodeString | toTempString (UErrorCode &status) const override
| Returns the formatted string as a read-only alias to memory owned by the FormattedValue.
Appendable & | appendTo (Appendable &appendable, UErrorCode &status) const override
| Appends the formatted string to an Appendable.
UBool | nextPosition (ConstrainedFieldPosition &cfpos, UErrorCode &status) const override
| Iterates over field positions in the FormattedValue.
Public Member Functions inherited from icu::FormattedValue
virtual | ~FormattedValue ()

## Friends

class | RelativeDateTimeFormatter

## Detailed Description

An immutable class containing the result of a relative datetime formatting operation.

Instances of this class are immutable and thread-safe.

Not intended for public subclassing.

Stable
  ICU 64

Definition at line 272 of file reldatefmt.h.

## Constructor & Destructor Documentation

## FormattedRelativeDateTime() [1/2]

icu::FormattedRelativeDateTime::FormattedRelativeDateTime | ( |  | ) |

inline

Default constructor; makes an empty FormattedRelativeDateTime.

Stable
  ICU 64

Definition at line 278 of file reldatefmt.h.

References U_INVALID_STATE_ERROR.

Referenced by FormattedRelativeDateTime(), FormattedRelativeDateTime(), nextPosition(), operator=(), and operator=().

## FormattedRelativeDateTime() [2/2]

icu::FormattedRelativeDateTime::FormattedRelativeDateTime | ( | FormattedRelativeDateTime && | src | ) |

noexcept

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

Stable
  ICU 64

References FormattedRelativeDateTime().

## ~FormattedRelativeDateTime()

virtual icu::FormattedRelativeDateTime::~FormattedRelativeDateTime | ( |  | ) |

override virtual

Destruct an instance of FormattedRelativeDateTime.

Stable
  ICU 64

## Member Function Documentation

## appendTo()

Appendable & icu::FormattedRelativeDateTime::appendTo | ( | Appendable & | appendable,
|  | UErrorCode & | status ) const

override virtual

Appends the formatted string to an Appendable.

Parameters

  appendable | The Appendable to which to append the string output.
  status | Set if an error occurs.

Returns
  The same Appendable, for chaining.

Stable
  ICU 64

See also
  Appendable

Implements icu::FormattedValue.

## nextPosition()

UBool icu::FormattedRelativeDateTime::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

  cfpos | The object used for iteration state. This can provide constraints to iterate over only one specific category or field; see ConstrainedFieldPosition::constrainCategory and ConstrainedFieldPosition::constrainField.
  status | Set 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.

References FormattedRelativeDateTime(), and U_ZERO_ERROR.

## operator=()

FormattedRelativeDateTime & icu::FormattedRelativeDateTime::operator= | ( | FormattedRelativeDateTime && | src | ) |

noexcept

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

Stable
  ICU 64

References FormattedRelativeDateTime().

## toString()

UnicodeString icu::FormattedRelativeDateTime::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

  status | Set if an error occurs.

Returns
  a UnicodeString containing the formatted string.

Stable
  ICU 64

Implements icu::FormattedValue.

## toTempString()

UnicodeString icu::FormattedRelativeDateTime::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

  status | Set if an error occurs.

Returns
  a temporary UnicodeString containing the formatted string.

Stable
  ICU 64

Implements icu::FormattedValue.

## Friends And Related Symbol Documentation

## RelativeDateTimeFormatter

friend class RelativeDateTimeFormatter

friend

Definition at line 323 of file reldatefmt.h.

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

- i18n/unicode/reldatefmt.h