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

rep.h

Go to the documentation of this file.
00001 /*
00002 **************************************************************************
00003 * Copyright (C) 1999-2001, International Business Machines Corporation and
00004 * others. All Rights Reserved.
00005 **************************************************************************
00006 *   Date        Name        Description
00007 *   11/17/99    aliu        Creation.  Ported from java.  Modified to
00008 *                           match current UnicodeString API.  Forced
00009 *                           to use name "handleReplaceBetween" because
00010 *                           of existing methods in UnicodeString.
00011 **************************************************************************
00012 */
00013 
00014 #ifndef REP_H
00015 #define REP_H
00016 
00017 #include "unicode/utypes.h"
00018 
00019 class UnicodeString;
00020 
00044 class U_COMMON_API Replaceable {
00045 
00046 public:
00047 
00052     virtual ~Replaceable();
00053 
00059     inline int32_t length() const;
00060 
00068     inline UChar charAt(UTextOffset offset) const;
00069 
00079     inline UChar32 char32At(UTextOffset offset) const;
00080 
00099     /* THIS API IS NOT NEEDED, BUT KEPT HERE AS A COMMENT IN
00100        CASE OF FUTURE NEED.  CURRENTLY INDIVIDUAL CHARACTER
00101        ACCESS SUFFICES. */
00102     /* virtual void extractBetween(UTextOffset srcStart,
00103                                 UTextOffset srcLimit,
00104                                 UChar* dst,
00105                                 UTextOffset dstStart = 0) const = 0; */
00106 
00120     virtual void handleReplaceBetween(UTextOffset start,
00121                                       UTextOffset limit,
00122                                       const UnicodeString& text) = 0;
00123     // Note: All other methods in this class take the names of
00124     // existing UnicodeString methods.  This method is the exception.
00125     // It is named differently because all replace methods of
00126     // UnicodeString return a UnicodeString&.  The 'between' is
00127     // required in order to conform to the UnicodeString naming
00128     // convention; API taking start/length are named <operation>, and
00129     // those taking start/limit are named <operationBetween>.  The
00130     // 'handle' is added because 'replaceBetween' and
00131     // 'doReplaceBetween' are already taken.
00132 
00153     virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
00154 
00155 protected:
00156 
00160     Replaceable();
00161 
00165     Replaceable(int32_t initialLength);
00166 
00171     virtual UChar getCharAt(UTextOffset offset) const = 0;
00172 
00177     virtual UChar32 getChar32At(UTextOffset offset) const = 0;
00178 
00184     int32_t   fLength;        // number characters in fArray
00185 };
00186 
00187 inline Replaceable::Replaceable() : fLength(0) {}
00188 
00189 inline Replaceable::Replaceable(int32_t initialLength) : fLength(initialLength) {}
00190 
00191 inline Replaceable::~Replaceable() {}
00192 
00193 inline int32_t
00194 Replaceable::length() const {
00195     return fLength;
00196 }
00197 
00198 inline UChar
00199 Replaceable::charAt(UTextOffset offset) const {
00200     return getCharAt(offset);
00201 }
00202 
00203 inline UChar32
00204 Replaceable::char32At(UTextOffset offset) const {
00205     return getChar32At(offset);
00206 }
00207 
00208 #endif

Generated at Thu Mar 22 16:12:37 2001 for ICU 1.8 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000