ICU 4.8.1.1  4.8.1.1
rep.h
Go to the documentation of this file.
00001 /*
00002 **************************************************************************
00003 * Copyright (C) 1999-2005, 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 
00024 U_NAMESPACE_BEGIN
00025 
00026 class UnicodeString;
00027 
00071 class U_COMMON_API Replaceable : public UObject {
00072 
00073 public:
00078     virtual ~Replaceable();
00079 
00085     inline int32_t length() const;
00086 
00094     inline UChar charAt(int32_t offset) const;
00095 
00108     inline UChar32 char32At(int32_t offset) const;
00109 
00120     virtual void extractBetween(int32_t start,
00121                                 int32_t limit,
00122                                 UnicodeString& target) const = 0;
00123 
00144     virtual void handleReplaceBetween(int32_t start,
00145                                       int32_t limit,
00146                                       const UnicodeString& text) = 0;
00147     // Note: All other methods in this class take the names of
00148     // existing UnicodeString methods.  This method is the exception.
00149     // It is named differently because all replace methods of
00150     // UnicodeString return a UnicodeString&.  The 'between' is
00151     // required in order to conform to the UnicodeString naming
00152     // convention; API taking start/length are named <operation>, and
00153     // those taking start/limit are named <operationBetween>.  The
00154     // 'handle' is added because 'replaceBetween' and
00155     // 'doReplaceBetween' are already taken.
00156 
00172     virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
00173 
00183     virtual UBool hasMetaData() const;
00184 
00200     virtual Replaceable *clone() const;
00201 
00202 protected:
00203 
00208     Replaceable();
00209 
00210     /*
00211      * Assignment operator not declared. The compiler will provide one
00212      * which does nothing since this class does not contain any data members.
00213      * API/code coverage may show the assignment operator as present and
00214      * untested - ignore.
00215      * Subclasses need this assignment operator if they use compiler-provided
00216      * assignment operators of their own. An alternative to not declaring one
00217      * here would be to declare and empty-implement a protected or public one.
00218     Replaceable &Replaceable::operator=(const Replaceable &);
00219      */
00220 
00225     virtual int32_t getLength() const = 0;
00226 
00231     virtual UChar getCharAt(int32_t offset) const = 0;
00232 
00237     virtual UChar32 getChar32At(int32_t offset) const = 0;
00238 };
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
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines