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

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 U_NAMESPACE_BEGIN
00019 
00020 class UnicodeString;
00021 
00057 class U_COMMON_API Replaceable {
00058 
00059 public:
00064     virtual ~Replaceable();
00065 
00071     inline int32_t length() const;
00072 
00080     inline UChar charAt(UTextOffset offset) const;
00081 
00091     inline UChar32 char32At(UTextOffset offset) const;
00092 
00111     /* THIS API IS NOT NEEDED, BUT KEPT HERE AS A COMMENT IN
00112        CASE OF FUTURE NEED.  CURRENTLY INDIVIDUAL CHARACTER
00113        ACCESS SUFFICES. */
00114     /* virtual void extractBetween(UTextOffset srcStart,
00115                                 UTextOffset srcLimit,
00116                                 UChar* dst,
00117                                 UTextOffset dstStart = 0) const = 0; */
00118 
00139     virtual void handleReplaceBetween(UTextOffset start,
00140                                       UTextOffset limit,
00141                                       const UnicodeString& text) = 0;
00142     // Note: All other methods in this class take the names of
00143     // existing UnicodeString methods.  This method is the exception.
00144     // It is named differently because all replace methods of
00145     // UnicodeString return a UnicodeString&.  The 'between' is
00146     // required in order to conform to the UnicodeString naming
00147     // convention; API taking start/length are named <operation>, and
00148     // those taking start/limit are named <operationBetween>.  The
00149     // 'handle' is added because 'replaceBetween' and
00150     // 'doReplaceBetween' are already taken.
00151 
00173     virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
00174 
00175 protected:
00176 
00180     Replaceable();
00181 
00185     virtual int32_t getLength() const = 0;
00186 
00190     virtual UChar getCharAt(UTextOffset offset) const = 0;
00191 
00195     virtual UChar32 getChar32At(UTextOffset offset) const = 0;
00196 };
00197 
00198 inline Replaceable::Replaceable() {}
00199 
00200 inline Replaceable::~Replaceable() {}
00201 
00202 inline int32_t
00203 Replaceable::length() const {
00204     return getLength();
00205 }
00206 
00207 inline UChar
00208 Replaceable::charAt(UTextOffset offset) const {
00209     return getCharAt(offset);
00210 }
00211 
00212 inline UChar32
00213 Replaceable::char32At(UTextOffset offset) const {
00214     return getChar32At(offset);
00215 }
00216 
00217 U_NAMESPACE_END
00218 
00219 #endif

Generated on Mon Dec 3 19:00:23 2001 for ICU 2.0 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001