rep.h

00001 /*
00002 **************************************************************************
00003 * Copyright (C) 1999-2004, 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/uobject.h"
00018 
00019 U_NAMESPACE_BEGIN
00020 
00021 class UnicodeString;
00022 
00066 class U_COMMON_API Replaceable : public UObject {
00067 
00068 public:
00073     virtual ~Replaceable();
00074 
00080     inline int32_t length() const;
00081 
00089     inline UChar charAt(int32_t offset) const;
00090 
00103     inline UChar32 char32At(int32_t offset) const;
00104 
00115     virtual void extractBetween(int32_t start,
00116                                 int32_t limit,
00117                                 UnicodeString& target) const = 0;
00118 
00139     virtual void handleReplaceBetween(int32_t start,
00140                                       int32_t 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 
00167     virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
00168 
00178     virtual UBool hasMetaData() const;
00179 
00195     virtual Replaceable *clone() const;
00196 
00197 protected:
00198 
00203     Replaceable();
00204 
00205     /*
00206      * Assignment operator not declared. The compiler will provide one
00207      * which does nothing since this class does not contain any data members.
00208      * API/code coverage may show the assignment operator as present and
00209      * untested - ignore.
00210      * Subclasses need this assignment operator if they use compiler-provided
00211      * assignment operators of their own. An alternative to not declaring one
00212      * here would be to declare and empty-implement a protected or public one.
00213     Replaceable &Replaceable::operator=(const Replaceable &);
00214      */
00215 
00220     virtual int32_t getLength() const = 0;
00221 
00226     virtual UChar getCharAt(int32_t offset) const = 0;
00227 
00232     virtual UChar32 getChar32At(int32_t offset) const = 0;
00233 };
00234 
00235 inline int32_t
00236 Replaceable::length() const {
00237     return getLength();
00238 }
00239 
00240 inline UChar
00241 Replaceable::charAt(int32_t offset) const {
00242     return getCharAt(offset);
00243 }
00244 
00245 inline UChar32
00246 Replaceable::char32At(int32_t offset) const {
00247     return getChar32At(offset);
00248 }
00249 
00250 // There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
00251 
00252 U_NAMESPACE_END
00253 
00254 #endif

Generated on Tue Nov 16 10:03:06 2004 for ICU 3.2 by  doxygen 1.3.9.1