ICU 57.1 57.1
rep.h
Go to the documentation of this file.
1/*
2**************************************************************************
3* Copyright (C) 1999-2012, 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
26class UnicodeString;
27
72
73public:
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
202protected:
203
208 inline 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
241
242inline int32_t
244 return getLength();
245}
246
247inline UChar
248Replaceable::charAt(int32_t offset) const {
249 return getCharAt(offset);
250}
251
252inline UChar32
253Replaceable::char32At(int32_t offset) const {
254 return getChar32At(offset);
255}
256
257// There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
258
260
261#endif
"Smart pointer" base class; do not use directly: use LocalPointer etc.
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
Definition rep.h:71
virtual ~Replaceable()
Destructor.
virtual UBool hasMetaData() const
Returns true if this object contains metadata.
virtual UChar getCharAt(int32_t offset) const =0
Virtual version of charAt().
virtual UChar32 getChar32At(int32_t offset) const =0
Virtual version of char32At().
int32_t length() const
Returns the number of 16-bit code units in the text.
Definition rep.h:243
virtual void copy(int32_t start, int32_t limit, int32_t dest)=0
Copies a substring of this object, retaining metadata.
virtual int32_t getLength() const =0
Virtual version of length().
UChar32 char32At(int32_t offset) const
Returns the 32-bit code point at the given 16-bit offset into the text.
Definition rep.h:253
virtual void extractBetween(int32_t start, int32_t limit, UnicodeString &target) const =0
Copies characters in the range [start, limit) into the UnicodeString target.
UChar charAt(int32_t offset) const
Returns the 16-bit code unit at the given offset into the text.
Definition rep.h:248
virtual void handleReplaceBetween(int32_t start, int32_t limit, const UnicodeString &text)=0
Replaces a substring of this object with the given text.
virtual Replaceable * clone() const
Clone this object, an instance of a subclass of Replaceable.
Replaceable()
Default constructor.
Definition rep.h:240
UObject is the common ICU "boilerplate" class.
Definition uobject.h:221
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:294
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:312
C++ API: Common ICU base class UObject.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:357
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129