ICU 60.2 60.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

Public Member Functions | Friends
icu::Edits::Iterator Struct Referencefinal

Access to the list of edits. More...

`#include <edits.h>`

Inheritance diagram for icu::Edits::Iterator:

## Public Member Functions
| Iterator ()
| Default constructor, empty iterator. More...
| Iterator (const Iterator &other)=default
| Copy constructor. More...
Iterator & | operator= (const Iterator &other)=default
| Assignment operator. More...
UBool | next (UErrorCode &errorCode)
| Advances to the next edit. More...
UBool | findSourceIndex (int32_t i, UErrorCode &errorCode)
| Finds the edit that contains the source index. More...
UBool | findDestinationIndex (int32_t i, UErrorCode &errorCode)
| Finds the edit that contains the destination index. More...
int32_t | destinationIndexFromSourceIndex (int32_t i, UErrorCode &errorCode)
| Returns the destination index corresponding to the given source index. More...
int32_t | sourceIndexFromDestinationIndex (int32_t i, UErrorCode &errorCode)
| Returns the source index corresponding to the given destination index. More...
UBool | hasChange () const
int32_t | oldLength () const
int32_t | newLength () const
int32_t | sourceIndex () const
int32_t | replacementIndex () const
int32_t | destinationIndex () const

## Friends
class | Edits

## Detailed Description

Access to the list of edits.

See also
  getCoarseIterator
  getFineIterator

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

Definition at line 143 of file edits.h.

## Constructor & Destructor Documentation

icu::Edits::Iterator::Iterator | ( |  | ) |
| inline

Default constructor, empty iterator.

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

Definition at line 148 of file edits.h.

icu::Edits::Iterator::Iterator | ( | const Iterator & | other | ) |
| default

Copy constructor.

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

## Member Function Documentation

int32_t icu::Edits::Iterator::destinationIndex | ( |  | ) | const
| inline

Returns
  the current index into the full destination string

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

Definition at line 301 of file edits.h.

int32_t icu::Edits::Iterator::destinationIndexFromSourceIndex | ( | int32_t | i,
|  | UErrorCode & | errorCode
| ) |  |

Returns the destination index corresponding to the given source index.

If the source index is inside a change edit (not at its start), then the destination index at the end of that edit is returned, since there is no information about index mapping inside a change edit.

(This means that indexes to the start and middle of an edit, for example around a grapheme cluster, are mapped to indexes encompassing the entire edit. The alternative, mapping an interior index to the start, would map such an interval to an empty one.)

This operation will usually but not always modify this object. The iterator state after this search is undefined.

Parameters

  i | source index
  errorCode | ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  destination index; undefined if i is not 0..string length

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

UBool icu::Edits::Iterator::findDestinationIndex | ( | int32_t | i,
|  | UErrorCode & | errorCode
| ) |  |
| inline

Finds the edit that contains the destination index.

The destination index may be found in a non-change even if normal iteration would skip non-changes. Normal iteration can continue from a found edit.

The iterator state before this search logically does not matter. (It may affect the performance of the search.)

The iterator state after this search is undefined if the source index is out of bounds for the source string.

Parameters

  i | destination index
  errorCode | ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  TRUE if the edit for the destination index was found

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

Definition at line 216 of file edits.h.

References FALSE.

UBool icu::Edits::Iterator::findSourceIndex | ( | int32_t | i,
|  | UErrorCode & | errorCode
| ) |  |
| inline

Finds the edit that contains the source index.

The source index may be found in a non-change even if normal iteration would skip non-changes. Normal iteration can continue from a found edit.

The iterator state before this search logically does not matter. (It may affect the performance of the search.)

The iterator state after this search is undefined if the source index is out of bounds for the source string.

Parameters

  i | source index
  errorCode | ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  TRUE if the edit for the source index was found

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

Definition at line 193 of file edits.h.

References TRUE.

UBool icu::Edits::Iterator::hasChange | ( |  | ) | const
| inline

Returns
  TRUE if this edit replaces oldLength() units with newLength() different ones. FALSE if oldLength units remain unchanged.

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

Definition at line 273 of file edits.h.

int32_t icu::Edits::Iterator::newLength | ( |  | ) | const
| inline

Returns
  the number of units in the modified string, if hasChange() is TRUE. Same as oldLength if hasChange() is FALSE.

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

Definition at line 284 of file edits.h.

UBool icu::Edits::Iterator::next | ( | UErrorCode & | errorCode | ) |
| inline

Advances to the next edit.

Parameters

  errorCode | ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  TRUE if there is another edit

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

Definition at line 172 of file edits.h.

References next().

Referenced by next().

int32_t icu::Edits::Iterator::oldLength | ( |  | ) | const
| inline

Returns
  the number of units in the original string which are replaced or remain unchanged.

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

Definition at line 278 of file edits.h.

Iterator& icu::Edits::Iterator::operator= | ( | const Iterator & | other | ) |
| default

Assignment operator.

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

int32_t icu::Edits::Iterator::replacementIndex | ( |  | ) | const
| inline

Returns
  the current index into the replacement-characters-only string, not counting unchanged spans

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

Definition at line 296 of file edits.h.

int32_t icu::Edits::Iterator::sourceIndex | ( |  | ) | const
| inline

Returns
  the current index into the source string

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

Definition at line 290 of file edits.h.

int32_t icu::Edits::Iterator::sourceIndexFromDestinationIndex | ( | int32_t | i,
|  | UErrorCode & | errorCode
| ) |  |

Returns the source index corresponding to the given destination index.

If the destination index is inside a change edit (not at its start), then the source index at the end of that edit is returned, since there is no information about index mapping inside a change edit.

(This means that indexes to the start and middle of an edit, for example around a grapheme cluster, are mapped to indexes encompassing the entire edit. The alternative, mapping an interior index to the start, would map such an interval to an empty one.)

This operation will usually but not always modify this object. The iterator state after this search is undefined.

Parameters

  i | destination index
  errorCode | ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  source index; undefined if i is not 0..string length

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

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

- edits.h