ICU 60.2 60.2

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

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

Data Structures | Public Member Functions
icu::Edits Class Referencefinal

Records lengths of string edits but not replacement text. More...

`#include <edits.h>`

Inheritance diagram for icu::Edits:

## Data Structures
struct | Iterator
| Access to the list of edits. More...

## Public Member Functions
| Edits ()
| Constructs an empty object. More...
| Edits (const Edits &other)
| Copy constructor. More...
| Edits (Edits &&src)
| Move constructor, might leave src empty. More...
| ~Edits ()
| Destructor. More...
Edits & | operator= (const Edits &other)
| Assignment operator. More...
Edits & | operator= (Edits &&src)
| Move assignment operator, might leave src empty. More...
void | reset ()
| Resets the data but may not release memory. More...
void | addUnchanged (int32_t unchangedLength)
| Adds a record for an unchanged segment of text. More...
void | addReplace (int32_t oldLength, int32_t newLength)
| Adds a record for a text replacement/insertion/deletion. More...
UBool | copyErrorTo (UErrorCode &outErrorCode)
| Sets the UErrorCode if an error occurred while recording edits. More...
int32_t | lengthDelta () const
| How much longer is the new text compared with the old text? More...
UBool | hasChanges () const
int32_t | numberOfChanges () const
Iterator | getCoarseChangesIterator () const
| Returns an Iterator for coarse-grained changes for simple string updates. More...
Iterator | getCoarseIterator () const
| Returns an Iterator for coarse-grained changes and non-changes for simple string updates. More...
Iterator | getFineChangesIterator () const
| Returns an Iterator for fine-grained changes for modifying styled text. More...
Iterator | getFineIterator () const
| Returns an Iterator for fine-grained changes and non-changes for modifying styled text. More...
Edits & | mergeAndAppend (const Edits &ab, const Edits &bc, UErrorCode &errorCode)
| Merges the two input Edits and appends the result to this object. More...

## Detailed Description

Records lengths of string edits but not replacement text.

Supports replacements, insertions, deletions in linear progression. Does not support moving/reordering of text.

An Edits object tracks a separate UErrorCode, but ICU string transformation functions (e.g., case mapping functions) merge any such errors into their API's UErrorCode.

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

Definition at line 32 of file edits.h.

## Constructor & Destructor Documentation

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

Constructs an empty object.

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

Definition at line 38 of file edits.h.

icu::Edits::Edits | ( | const Edits & | other | ) |
| inline

Copy constructor.

Parameters

  other | source edits

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

Definition at line 46 of file edits.h.

icu::Edits::Edits | ( | Edits && | src | ) |
| inline

Move constructor, might leave src empty.

This object will have the same contents that the source object had.

Parameters

  src | source edits

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

Definition at line 58 of file edits.h.

icu::Edits::~Edits | ( |  | ) |

Destructor.

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

## Member Function Documentation

void icu::Edits::addReplace | ( | int32_t | oldLength,
|  | int32_t | newLength
| ) |  |

Adds a record for a text replacement/insertion/deletion.

Normally called from inside ICU string transformation functions, not user code.

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

void icu::Edits::addUnchanged | ( | int32_t | unchangedLength | ) |

Adds a record for an unchanged segment of text.

Normally called from inside ICU string transformation functions, not user code.

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

UBool icu::Edits::copyErrorTo | ( | UErrorCode & | outErrorCode | ) |

Sets the UErrorCode if an error occurred while recording edits.

Preserves older error codes in the outErrorCode. Normally called from inside ICU string transformation functions, not user code.

Parameters

  outErrorCode | Set to an error code if it does not contain one already and an error occurred while recording edits. Otherwise unchanged.

Returns
  TRUE if U_FAILURE(outErrorCode)

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

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

Returns an Iterator for coarse-grained changes for simple string updates.

Skips non-changes.

Returns
  an Iterator that merges adjacent changes.

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

Definition at line 336 of file edits.h.

References TRUE.

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

Returns an Iterator for coarse-grained changes and non-changes for simple string updates.

Returns
  an Iterator that merges adjacent changes.

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

Definition at line 345 of file edits.h.

References FALSE, and TRUE.

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

Returns an Iterator for fine-grained changes for modifying styled text.

Skips non-changes.

Returns
  an Iterator that separates adjacent changes.

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

Definition at line 355 of file edits.h.

References FALSE, and TRUE.

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

Returns an Iterator for fine-grained changes and non-changes for modifying styled text.

Returns
  an Iterator that separates adjacent changes.

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

Definition at line 364 of file edits.h.

References FALSE, and U_NAMESPACE_END.

UBool icu::Edits::hasChanges | ( |  | ) | const
| inline

Returns
  TRUE if there are any change edits

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

Definition at line 129 of file edits.h.

int32_t icu::Edits::lengthDelta | ( |  | ) | const
| inline

How much longer is the new text compared with the old text?

Returns
  new length minus old length

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

Definition at line 124 of file edits.h.

Edits& icu::Edits::mergeAndAppend | ( | const Edits & | ab,
|  | const Edits & | bc,
|  | UErrorCode & | errorCode
| ) |  |

Merges the two input Edits and appends the result to this object.

Consider two string transformations (for example, normalization and case mapping) where each records Edits in addition to writing an output string.
Edits ab reflect how substrings of input string a map to substrings of intermediate string b.
Edits bc reflect how substrings of intermediate string b map to substrings of output string c.
This function merges ab and bc such that the additional edits recorded in this object reflect how substrings of input string a map to substrings of output string c.

If unrelated Edits are passed in where the output string of the first has a different length than the input string of the second, then a U_ILLEGAL_ARGUMENT_ERROR is reported.

Parameters

  ab | reflects how substrings of input string a map to substrings of intermediate string b.
  bc | reflects how substrings of intermediate string b map to substrings of output string c.
  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
  *this, with the merged edits appended

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

int32_t icu::Edits::numberOfChanges | ( |  | ) | const
| inline

Returns
  the number of change edits

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

Definition at line 135 of file edits.h.

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

Assignment operator.

Parameters

  other | source edits

Returns
  *this

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

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

Move assignment operator, might leave src empty.

This object will have the same contents that the source object had. The behavior is undefined if *this and src are the same object.

Parameters

  src | source edits

Returns
  *this

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

void icu::Edits::reset | ( |  | ) |

Resets the data but may not release memory.

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

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

- edits.h