1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru************************************************************************** 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Copyright (C) 1999-2005, International Business Machines Corporation and 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* others. All Rights Reserved. 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru************************************************************************** 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Date Name Description 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 11/17/99 aliu Creation. Ported from java. Modified to 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* match current UnicodeString API. Forced 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* to use name "handleReplaceBetween" because 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* of existing methods in UnicodeString. 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru************************************************************************** 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef REP_H 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define REP_H 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uobject.h" 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \file 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C++ API: Replaceable String 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass UnicodeString; 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>Replaceable</code> is an abstract base class representing a 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * string of characters that supports the replacement of a range of 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * itself with a new string of characters. It is used by APIs that 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * change a piece of text while retaining metadata. Metadata is data 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * other than the Unicode characters returned by char32At(). One 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * example of metadata is style attributes; another is an edit 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * history, marking each character with an author and revision number. 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>An implicit aspect of the <code>Replaceable</code> API is that 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * during a replace operation, new characters take on the metadata of 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the old characters. For example, if the string "the <b>bold</b> 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * font" has range (4, 8) replaced with "strong", then it becomes "the 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <b>strong</b> font". 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><code>Replaceable</code> specifies ranges using a start 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * offset and a limit offset. The range of characters thus specified 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * includes the characters at offset start..limit-1. That is, the 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * start offset is inclusive, and the limit offset is exclusive. 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><code>Replaceable</code> also includes API to access characters 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in the string: <code>length()</code>, <code>charAt()</code>, 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>char32At()</code>, and <code>extractBetween()</code>. 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>For a subclass to support metadata, typical behavior of 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>replace()</code> is the following: 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul> 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Set the metadata of the new text to the metadata of the first 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character replaced</li> 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If no characters are replaced, use the metadata of the 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * previous character</li> 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If there is no previous character (i.e. start == 0), use the 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * following character</li> 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If there is no following character (i.e. the replaceable was 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * empty), use default metadata.<br> 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If the code point U+FFFF is seen, it should be interpreted as 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a special marker having no metadata<li> 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </li> 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If this is not the behavior, the subclass should document any differences. 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @author Alan Liu 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_COMMON_API Replaceable : public UObject { 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Destructor. 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual ~Replaceable(); 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the number of 16-bit code units in the text. 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return number of 16-bit code units in text 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 1.8 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru inline int32_t length() const; 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the 16-bit code unit at the given offset into the text. 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param offset an integer between 0 and <code>length()</code>-1 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * inclusive 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return 16-bit code unit of text at given offset 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 1.8 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru inline UChar charAt(int32_t offset) const; 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the 32-bit code point at the given 16-bit offset into 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the text. This assumes the text is stored as 16-bit code units 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * with surrogate pairs intermixed. If the offset of a leading or 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * trailing code unit of a surrogate pair is given, return the 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * code point of the surrogate pair. 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param offset an integer between 0 and <code>length()</code>-1 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * inclusive 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return 32-bit code point of text at given offset 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 1.8 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru inline UChar32 char32At(int32_t offset) const; 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Copies characters in the range [<tt>start</tt>, <tt>limit</tt>) 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * into the UnicodeString <tt>target</tt>. 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param start offset of first character which will be copied 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param limit offset immediately following the last character to 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be copied 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param target UnicodeString into which to copy characters. 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to <TT>target</TT> 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.1 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void extractBetween(int32_t start, 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t limit, 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& target) const = 0; 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Replaces a substring of this object with the given text. If the 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters being replaced have metadata, the new characters 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that replace them should be given the same metadata. 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Subclasses must ensure that if the text between start and 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * limit is equal to the replacement text, that replace has no 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * effect. That is, any metadata 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * should be unaffected. In addition, subclasses are encouraged to 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * check for initial and trailing identical characters, and make a 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * smaller replacement if possible. This will preserve as much 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * metadata as possible. 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param start the beginning index, inclusive; <code>0 <= start 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <= limit</code>. 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param limit the ending index, exclusive; <code>start <= limit 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <= length()</code>. 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the text to replace characters <code>start</code> 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to <code>limit - 1</code> 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void handleReplaceBetween(int32_t start, 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t limit, 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& text) = 0; 147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // Note: All other methods in this class take the names of 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // existing UnicodeString methods. This method is the exception. 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // It is named differently because all replace methods of 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // UnicodeString return a UnicodeString&. The 'between' is 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // required in order to conform to the UnicodeString naming 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // convention; API taking start/length are named <operation>, and 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // those taking start/limit are named <operationBetween>. The 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // 'handle' is added because 'replaceBetween' and 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // 'doReplaceBetween' are already taken. 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Copies a substring of this object, retaining metadata. 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This method is used to duplicate or reorder substrings. 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The destination index must not overlap the source range. 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param start the beginning index, inclusive; <code>0 <= start <= 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * limit</code>. 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param limit the ending index, exclusive; <code>start <= limit <= 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * length()</code>. 166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dest the destination index. The characters from 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>start..limit-1</code> will be copied to <code>dest</code>. 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Implementations of this method may assume that <code>dest <= start || 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * dest >= limit</code>. 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0; 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns true if this object contains metadata. If a 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Replaceable object has metadata, calls to the Replaceable API 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * must be made so as to preserve metadata. If it does not, calls 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to the Replaceable API may be optimized to improve performance. 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The default implementation returns true. 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return true if this object contains metadata 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.2 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool hasMetaData() const; 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Clone this object, an instance of a subclass of Replaceable. 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Clones can be used concurrently in multiple threads. 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If a subclass does not implement clone(), or if an error occurs, 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * then NULL is returned. 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The clone functions in all subclasses return a pointer to a Replaceable 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * because some compilers do not support covariant (same-as-this) 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return types; cast to the appropriate subclass if necessary. 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The caller must delete the clone. 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a clone of this object 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see getDynamicClassID 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.6 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual Replaceable *clone() const; 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Default constructor. 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Replaceable(); 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Assignment operator not declared. The compiler will provide one 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * which does nothing since this class does not contain any data members. 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * API/code coverage may show the assignment operator as present and 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * untested - ignore. 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Subclasses need this assignment operator if they use compiler-provided 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * assignment operators of their own. An alternative to not declaring one 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * here would be to declare and empty-implement a protected or public one. 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Replaceable &Replaceable::operator=(const Replaceable &); 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Virtual version of length(). 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t getLength() const = 0; 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Virtual version of charAt(). 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UChar getCharAt(int32_t offset) const = 0; 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Virtual version of char32At(). 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UChar32 getChar32At(int32_t offset) const = 0; 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruReplaceable::length() const { 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return getLength(); 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UChar 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruReplaceable::charAt(int32_t offset) const { 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return getCharAt(offset); 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UChar32 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruReplaceable::char32At(int32_t offset) const { 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return getChar32At(offset); 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// There is no rep.cpp, see unistr.cpp for Replaceable function implementations. 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 260