Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

rep.h

00001 /*
00002 **************************************************************************
00003 * Copyright (C) 1999-2003, 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 
00196     virtual Replaceable *clone() const;
00197 
00198 protected:
00199 
00204     Replaceable();
00205 
00206     /*
00207      * Assignment operator not declared. The compiler will provide one
00208      * which does nothing since this class does not contain any data members.
00209      * API/code coverage may show the assignment operator as present and
00210      * untested - ignore.
00211      * Subclasses need this assignment operator if they use compiler-provided
00212      * assignment operators of their own. An alternative to not declaring one
00213      * here would be to declare and empty-implement a protected or public one.
00214     Replaceable &Replaceable::operator=(const Replaceable &);
00215      */
00216 
00221     virtual int32_t getLength() const = 0;
00222 
00227     virtual UChar getCharAt(int32_t offset) const = 0;
00228 
00233     virtual UChar32 getChar32At(int32_t offset) const = 0;
00234 };
00235 
00236 inline Replaceable::Replaceable() {}
00237 
00238 inline Replaceable::~Replaceable() {}
00239 
00240 inline int32_t
00241 Replaceable::length() const {
00242     return getLength();
00243 }
00244 
00245 inline UChar
00246 Replaceable::charAt(int32_t offset) const {
00247     return getCharAt(offset);
00248 }
00249 
00250 inline UChar32
00251 Replaceable::char32At(int32_t offset) const {
00252     return getChar32At(offset);
00253 }
00254 
00255 // There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
00256 
00257 U_NAMESPACE_END
00258 
00259 #endif

Generated on Wed Sep 3 17:47:09 2003 for ICU 2.6 by doxygen 1.3.2