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 #include "unicode/uobject.h"
00019 
00020 U_NAMESPACE_BEGIN
00021 
00022 class UnicodeString;
00023 
00067 class U_COMMON_API Replaceable : public UObject {
00068 
00069 public:
00074     virtual ~Replaceable();
00075 
00081     inline int32_t length() const;
00082 
00090     inline UChar charAt(int32_t offset) const;
00091 
00104     inline UChar32 char32At(int32_t offset) const;
00105 
00116     virtual void extractBetween(int32_t start,
00117                                 int32_t limit,
00118                                 UnicodeString& target) const = 0;
00119 
00140     virtual void handleReplaceBetween(int32_t start,
00141                                       int32_t limit,
00142                                       const UnicodeString& text) = 0;
00143     // Note: All other methods in this class take the names of
00144     // existing UnicodeString methods.  This method is the exception.
00145     // It is named differently because all replace methods of
00146     // UnicodeString return a UnicodeString&.  The 'between' is
00147     // required in order to conform to the UnicodeString naming
00148     // convention; API taking start/length are named <operation>, and
00149     // those taking start/limit are named <operationBetween>.  The
00150     // 'handle' is added because 'replaceBetween' and
00151     // 'doReplaceBetween' are already taken.
00152 
00168     virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
00169 
00179     virtual UBool hasMetaData() const;
00180 
00181 protected:
00182 
00187     Replaceable();
00188 
00193     virtual int32_t getLength() const = 0;
00194 
00199     virtual UChar getCharAt(int32_t offset) const = 0;
00200 
00205     virtual UChar32 getChar32At(int32_t offset) const = 0;
00206 };
00207 
00208 inline Replaceable::Replaceable() {}
00209 
00210 inline Replaceable::~Replaceable() {}
00211 
00212 inline int32_t
00213 Replaceable::length() const {
00214     return getLength();
00215 }
00216 
00217 inline UChar
00218 Replaceable::charAt(int32_t offset) const {
00219     return getCharAt(offset);
00220 }
00221 
00222 inline UChar32
00223 Replaceable::char32At(int32_t offset) const {
00224     return getChar32At(offset);
00225 }
00226 
00227 // See unistr.cpp for Replaceable::hasMetaData()
00228 
00229 U_NAMESPACE_END
00230 
00231 #endif

Generated on Wed Dec 18 16:49:44 2002 for ICU 2.4 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001