ICU 77.1  77.1
edits.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 
4 // edits.h
5 // created: 2016dec30 Markus W. Scherer
6 
7 #ifndef __EDITS_H__
8 #define __EDITS_H__
9 
10 #include "unicode/utypes.h"
11 
12 #if U_SHOW_CPLUSPLUS_API
13 
14 #include "unicode/uobject.h"
15 
21 U_NAMESPACE_BEGIN
22 
23 class UnicodeString;
24 
80 class U_COMMON_API Edits final : public UMemory {
81 public:
86  Edits() :
87  array(stackArray), capacity(STACK_CAPACITY), length(0), delta(0), numChanges(0),
88  errorCode_(U_ZERO_ERROR) {}
94  Edits(const Edits &other) :
95  array(stackArray), capacity(STACK_CAPACITY), length(other.length),
96  delta(other.delta), numChanges(other.numChanges),
97  errorCode_(other.errorCode_) {
98  copyArray(other);
99  }
106  Edits(Edits &&src) noexcept :
107  array(stackArray), capacity(STACK_CAPACITY), length(src.length),
108  delta(src.delta), numChanges(src.numChanges),
109  errorCode_(src.errorCode_) {
110  moveArray(src);
111  }
112 
118 
125  Edits &operator=(const Edits &other);
126 
135  Edits &operator=(Edits &&src) noexcept;
136 
141  void reset() noexcept;
142 
148  void addUnchanged(int32_t unchangedLength);
154  void addReplace(int32_t oldLength, int32_t newLength);
165  UBool copyErrorTo(UErrorCode &outErrorCode) const;
166 
172  int32_t lengthDelta() const { return delta; }
177  UBool hasChanges() const { return numChanges != 0; }
178 
183  int32_t numberOfChanges() const { return numChanges; }
184 
203  struct U_COMMON_API Iterator final : public UMemory {
209  array(nullptr), index(0), length(0),
210  remaining(0), onlyChanges_(false), coarse(false),
211  dir(0), changed(false), oldLength_(0), newLength_(0),
212  srcIndex(0), replIndex(0), destIndex(0) {}
217  Iterator(const Iterator &other) = default;
222  Iterator &operator=(const Iterator &other) = default;
223 
232