Replaceable
is an abstract base class representing a string of characters that supports the replacement of a range of itself with a new string of characters.
More...
#include <rep.h>
Class diagram for Replaceable:
Public Members | |||
![]() | ![]() | virtual | ~Replaceable () |
![]() | ![]() | Destructor. More... | |
![]() | ![]() | virtual int32_t | length () const = 0 |
![]() | ![]() | Return the number of characters in the text. More... | |
![]() | ![]() | virtual UChar | charAt (UTextOffset offset) const = 0 |
![]() | ![]() | Return the character at the given offset into the text. More... | |
![]() | ![]() | virtual void | extractBetween (UTextOffset srcStart, UTextOffset srcLimit, UChar* dst, UTextOffset dstStart = 0) const = 0 |
![]() | ![]() | Copy characters from this object into the destination character array. More... | |
![]() | ![]() | virtual void | handleReplaceBetween (UTextOffset start, UTextOffset limit, const UnicodeString& text) = 0 |
![]() | ![]() | Replace a substring of this object with the given text. More... | |
Protected Members | |||
![]() | ![]() | Replaceable () | |
![]() | ![]() | Default constructor. |
Replaceable
is an abstract base class representing a string of characters that supports the replacement of a range of itself with a new string of characters.
It is used by APIs that change a piece of text while retaining style attributes. In other words, an implicit aspect of the Replaceable
API is that during a replace operation, new characters take on the attributes, if any, of the old characters. For example, if the string "the bold font" has range (4, 8) replaced with "strong", then it becomes "the strong font".
Replaceable
specifies ranges using an initial offset and a limit offset. The range of characters thus specified includes the characters at offset initial..limit-1. That is, the start offset is inclusive, and the limit offset is exclusive.
Replaceable
also includes API to access characters in the string: length()
, charAt()
, and extractBetween()
.
Replaceable::~Replaceable () [inline, virtual]
|
Destructor.
virtual int32_t Replaceable::length (void) const [pure virtual]
|
Return the number of characters in the text.
Reimplemented in UnicodeString.
virtual UChar Replaceable::charAt (UTextOffset offset) const [pure virtual]
|
Return the character at the given offset into the text.
offset |
an integer between 0 and length() -1 inclusive |
Reimplemented in UnicodeString.
virtual void Replaceable::extractBetween (UTextOffset start, UTextOffset limit, UChar * dst, UTextOffset dstStart = 0) const [pure virtual]
|
Copy characters from this object into the destination character array.
The first character to be copied is at index srcStart
; the last character to be copied is at index srcLimit-1
(thus the total number of characters to be copied is srcLimit-srcStart
). The characters are copied into the subarray of dst
starting at index dstStart
and ending at index dstStart + (srcLimit-srcStart) - 1
.
srcStart |
the beginning index to copy, inclusive; 0 <= srcStart <= srcLimit . |
srcLimit |
the ending index to copy, exclusive; srcStart <= srcLimit <= length() . |
dst | the destination array. |
dstStart | the start offset in the destination array. |
Reimplemented in UnicodeString.
virtual void Replaceable::handleReplaceBetween (UTextOffset start, UTextOffset limit, const UnicodeString & text) [pure virtual]
|
Replace a substring of this object with the given text.
If the characters being replaced have attributes, the new characters that replace them should be given the same attributes.
start |
the beginning index, inclusive; 0 <= start <= limit . |
limit |
the ending index, exclusive; start <= limit <= length() . |
text |
the text to replace characters start to limit - 1 |
Reimplemented in UnicodeString.
Replaceable::Replaceable () [inline, protected]
|
Default constructor.