ICU 50.1.2  50.1.2
rep.h
Go to the documentation of this file.
1 /*
2 **************************************************************************
3 * Copyright (C) 1999-2005, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 **************************************************************************
6 * Date Name Description
7 * 11/17/99 aliu Creation. Ported from java. Modified to
8 * match current UnicodeString API. Forced
9 * to use name "handleReplaceBetween" because
10 * of existing methods in UnicodeString.
11 **************************************************************************
12 */
13 
14 #ifndef REP_H
15 #define REP_H
16 
17 #include "unicode/uobject.h"
18 
25 
26 class UnicodeString;
27 
72 
73 public:
78  virtual ~Replaceable();
79 
85  inline int32_t length() const;
86 
94  inline UChar charAt(int32_t offset) const;
95 
108  inline UChar32 char32At(int32_t offset) const;
109 
120  virtual void extractBetween(int32_t start,
121  int32_t limit,
122  UnicodeString& target) const = 0;
123 
144  virtual void handleReplaceBetween(int32_t start,
145  int32_t limit,
146  const UnicodeString& text) = 0;
147  // Note: All other methods in this class take the names of
148  // existing UnicodeString methods. This method is the exception.
149  // It is named differently because all replace methods of
150  // UnicodeString return a UnicodeString&. The 'between' is
151  // required in order to conform to the UnicodeString naming
152  // convention; API taking start/length are named <operation>, and
153  // those taking start/limit are named <operationBetween>. The
154  // 'handle' is added because 'replaceBetween' and
155  // 'doReplaceBetween' are already taken.
156 
172  virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
173 
183  virtual UBool hasMetaData() const;
184 
200  virtual Replaceable *clone() const;
201 
202 protected:
203 
208  Replaceable();
209 
210  /*
211  * Assignment operator not declared. The compiler will provide one
212  * which does nothing since this class does not contain any data members.
213  * API/code coverage may show the assignment operator as present and
214  * untested - ignore.
215  * Subclasses need this assignment operator if they use compiler-provided
216  * assignment operators of their own. An alternative to not declaring one
217  * here would be to declare and empty-implement a protected or public one.
218  Replaceable &Replaceable::operator=(const Replaceable &);
219  */
220 
225  virtual int32_t getLength() const = 0;
226 
231  virtual UChar getCharAt(int32_t offset) const = 0;
232 
237  virtual UChar32 getChar32At(int32_t offset) const = 0;
238 };
239 
240 inline int32_t
241 Replaceable::length() const {
242  return getLength();
243 }
244 
245 inline UChar
246 Replaceable::charAt(int32_t offset) const {
247  return getCharAt(offset);
248 }
249 
250 inline UChar32
251 Replaceable::char32At(int32_t offset) const {
252  return getChar32At(offset);
253 }
254 
255 // There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
256 
258 
259 #endif
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
Definition: rep.h:71
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:298
C++ API: Common ICU base class UObject.
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:278
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:357
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
UObject is the common ICU &quot;boilerplate&quot; class.
Definition: uobject.h:229
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200