ICU 64.2  64.2
rep.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 **************************************************************************
5 * Copyright (C) 1999-2012, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 **************************************************************************
8 * Date Name Description
9 * 11/17/99 aliu Creation. Ported from java. Modified to
10 * match current UnicodeString API. Forced
11 * to use name "handleReplaceBetween" because
12 * of existing methods in UnicodeString.
13 **************************************************************************
14 */
15 
16 #ifndef REP_H
17 #define REP_H
18 
19 #include "unicode/uobject.h"
20 
27 
28 class UnicodeString;
29 
74 
75 public:
80  virtual ~Replaceable();
81 
87  inline int32_t length() const;
88 
96  inline char16_t charAt(int32_t offset) const;
97 
110  inline UChar32 char32At(int32_t offset) const;
111 
122  virtual void extractBetween(int32_t start,
123  int32_t limit,
124  UnicodeString& target) const = 0;
125 
146  virtual void handleReplaceBetween(int32_t start,
147  int32_t limit,
148  const UnicodeString& text) = 0;
149  // Note: All other methods in this class take the names of
150  // existing UnicodeString methods. This method is the exception.
151  // It is named differently because all replace methods of
152  // UnicodeString return a UnicodeString&. The 'between' is
153  // required in order to conform to the UnicodeString naming
154  // convention; API taking start/length are named <operation>, and
155  // those taking start/limit are named <operationBetween>. The
156  // 'handle' is added because 'replaceBetween' and
157  // 'doReplaceBetween' are already taken.
158 
174  virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
175 
185  virtual UBool hasMetaData() const;
186 
202  virtual Replaceable *clone() const;
203 
204 protected:
205 
210  inline Replaceable();
211 
212  /*
213  * Assignment operator not declared. The compiler will provide one
214  * which does nothing since this class does not contain any data members.
215  * API/code coverage may show the assignment operator as present and
216  * untested - ignore.
217  * Subclasses need this assignment operator if they use compiler-provided
218  * assignment operators of their own. An alternative to not declaring one
219  * here would be to declare and empty-implement a protected or public one.
220  Replaceable &Replaceable::operator=(const Replaceable &);
221  */
222 
227  virtual int32_t getLength() const = 0;
228 
233  virtual char16_t getCharAt(int32_t offset) const = 0;
234 
239  virtual UChar32 getChar32At(int32_t offset) const = 0;
240 };
241 
243 
244 inline int32_t
246  return getLength();
247 }
248 
249 inline char16_t
250 Replaceable::charAt(int32_t offset) const {
251  return getCharAt(offset);
252 }
253 
254 inline UChar32
255 Replaceable::char32At(int32_t offset) const {
256  return getChar32At(offset);
257 }
258 
259 // There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
260 
262 
263 #endif
Replaceable()
Default constructor.
Definition: rep.h:242
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
Definition: rep.h:73
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
int32_t length() const
Returns the number of 16-bit code units in the text.
Definition: rep.h:245
UChar32 char32At(int32_t offset) const
Returns the 32-bit code point at the given 16-bit offset into the text.
Definition: rep.h:255
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:389
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
char16_t charAt(int32_t offset) const
Returns the 16-bit code unit at the given offset into the text.
Definition: rep.h:250
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:300
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:289
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225