Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Replaceable Class Reference

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>

Inheritance diagram for Replaceable:

UnicodeString List of all members.

Public Methods

virtual ~Replaceable ()
 Destructor. More...

int32_t length () const
 Return the number of characters in the text. More...

UChar charAt (UTextOffset offset) const
 Return the Unicode code unit at the given offset into the text. More...

UChar32 char32At (UTextOffset offset) const
 Return the Unicode code point that contains the code unit at the given offset into the text. More...

virtual void handleReplaceBetween (UTextOffset start, UTextOffset limit, const UnicodeString& text) = 0
 Replace a substring of this object with the given text. More...

virtual void copy (int32_t start, int32_t limit, int32_t dest) = 0
 Copy a substring of this object, retaining attribute (out-of-band) information. More...


Protected Methods

 Replaceable ()
 Default constructor. More...

 Replaceable (int32_t initialLength)
 Constructor with initial length. More...

virtual UChar getCharAt (UTextOffset offset) const = 0
 Virtual version of charAt(). More...

virtual UChar32 getChar32At (UTextOffset offset) const = 0
 Virtual version of char32At(). More...


Protected Attributes

int32_t fLength
 This field must always reflect the number of UChars in the text object. More...


Detailed Description

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().

Author(s):
Alan Liu
Draft:

Definition at line 44 of file rep.h.


Constructor & Destructor Documentation

Replaceable::~Replaceable ( ) [inline, virtual]
 

Destructor.

Draft:

Definition at line 191 of file rep.h.

Replaceable::Replaceable ( ) [inline, protected]
 

Default constructor.

Definition at line 187 of file rep.h.

Replaceable::Replaceable ( int32_t initialLength ) [inline, protected]
 

Constructor with initial length.

Definition at line 189 of file rep.h.


Member Function Documentation

UChar32 Replaceable::char32At ( UTextOffset offset ) const [inline]
 

Return the Unicode code point that contains the code unit at the given offset into the text.

Parameters:
offset   an integer between 0 and length()-1 inclusive that indicates the text offset of any of the code units that will be assembled into a code point (21-bit value) and returned
Returns:
code point of text at given offset
Draft:
ICU 1.8

Reimplemented in UnicodeString.

Definition at line 204 of file rep.h.

UChar Replaceable::charAt ( UTextOffset offset ) const [inline]
 

Return the Unicode code unit at the given offset into the text.

Parameters:
offset   an integer between 0 and length()-1 inclusive
Returns:
code unit of text at given offset
Draft:
ICU 1.8

Reimplemented in UnicodeString.

Definition at line 199 of file rep.h.

void Replaceable::copy ( int32_t start,
int32_t limit,
int32_t dest ) [pure virtual]
 

Copy a substring of this object, retaining attribute (out-of-band) information.

This method is used to duplicate or reorder substrings. The destination index must not overlap the source range. Implementations that do not care about maintaining out-of-band information during copying may use the naive implementation:

 char[] text = new char[limit - start];
 getChars(start, limit, text, 0);
 replace(dest, dest, text, 0, limit - start);
Parameters:
start   the beginning index, inclusive; 0 <= start <= limit.
limit   the ending index, exclusive; start <= limit <= length().
dest   the destination index. The characters from start..limit-1 will be copied to dest. Implementations of this method may assume that dest <= start || dest >= limit.

Reimplemented in UnicodeString.

UChar32 Replaceable::getChar32At ( UTextOffset offset ) const [protected, pure virtual]
 

Virtual version of char32At().

This allows UnicodeString::char32At() to be inline again (see jitterbug 709).

Reimplemented in UnicodeString.

Referenced by char32At().

UChar Replaceable::getCharAt ( UTextOffset offset ) const [protected, pure virtual]
 

Virtual version of charAt().

This allows UnicodeString::charAt() to be inline again (see jitterbug 709).

Reimplemented in UnicodeString.

Referenced by charAt().

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.

Parameters:
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
Draft:

Reimplemented in UnicodeString.

int32_t Replaceable::length ( void ) const [inline]
 

Return the number of characters in the text.

Returns:
number of characters in text
Draft:
ICU 1.8

Reimplemented in UnicodeString.

Definition at line 194 of file rep.h.


Member Data Documentation

int32_t Replaceable::fLength [protected]
 

This field must always reflect the number of UChars in the text object.

A subclass must keep this up to date. Moved here from UnicodeString so that length() can be inline (see jitterbug 709).

Definition at line 184 of file rep.h.


The documentation for this class was generated from the following file:
Generated at Thu Mar 22 16:13:17 2001 for ICU 1.8 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000