ICU 73.2  73.2
rep.h
Go to the documentation of this file.
00001 // © 2016 and later: Unicode, Inc. and others.
00002 // License & terms of use: http://www.unicode.org/copyright.html
00003 /*
00004 **************************************************************************
00005 * Copyright (C) 1999-2012, International Business Machines Corporation and
00006 * others. All Rights Reserved.
00007 **************************************************************************
00008 *   Date        Name        Description
00009 *   11/17/99    aliu        Creation.  Ported from java.  Modified to
00010 *                           match current UnicodeString API.  Forced
00011 *                           to use name "handleReplaceBetween" because
00012 *                           of existing methods in UnicodeString.
00013 **************************************************************************
00014 */
00015 
00016 #ifndef REP_H
00017 #define REP_H
00018 
00019 #include "unicode/utypes.h"
00020 
00021 #if U_SHOW_CPLUSPLUS_API
00022 
00023 #include "unicode/uobject.h"
00024 
00030 U_NAMESPACE_BEGIN
00031 
00032 class UnicodeString;
00033 
00077 class U_COMMON_API Replaceable : public UObject {
00078 
00079 public:
00084     virtual ~Replaceable();
00085 
00091     inline int32_t length() const;
00092 
00100     inline char16_t charAt(int32_t offset) const;
00101 
00114     inline UChar32 char32At(int32_t offset) const;
00115 
00126     virtual void extractBetween(int32_t start,
00127                                 int32_t limit,
00128                                 UnicodeString& target) const = 0;
00129 
00150     virtual void handleReplaceBetween(int32_t start,
00151                                       int32_t limit,
00152                                       const UnicodeString& text) = 0;
00153     // Note: All other methods in this class take the names of
00154     // existing UnicodeString methods.  This method is the exception.
00155     // It is named differently because all replace methods of
00156     // UnicodeString return a UnicodeString&.  The 'between' is
00157     // required in order to conform to the UnicodeString naming
00158     // convention; API taking start/length are named <operation>, and
00159     // those taking start/limit are named <operationBetween>.  The
00160     // 'handle' is added because 'replaceBetween' and
00161     // 'doReplaceBetween' are already taken.
00162 
00178     virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
00179 
00189     virtual UBool hasMetaData() const;
00190 
00203     virtual Replaceable *clone() const;
00204 
00205 protected:
00206 
00211     inline Replaceable();
00212 
00213     /*
00214      * Assignment operator not declared. The compiler will provide one
00215      * which does nothing since this class does not contain any data members.
00216      * API/code coverage may show the assignment operator as present and
00217      * untested - ignore.
00218      * Subclasses need this assignment operator if they use compiler-provided
00219      * assignment operators of their own. An alternative to not declaring one
00220      * here would be to declare and empty-implement a protected or public one.
00221     Replaceable &Replaceable::operator=(const Replaceable &);
00222      */
00223 
00228     virtual int32_t getLength() const = 0;
00229 
00234     virtual char16_t getCharAt(int32_t offset) const = 0;
00235 
00240     virtual UChar32 getChar32At(int32_t offset) const = 0;
00241 };
00242 
00243 inline Replaceable::Replaceable() {}
00244 
00245 inline int32_t
00246 Replaceable::length() const {
00247     return getLength();
00248 }
00249 
00250 inline char16_t
00251 Replaceable::charAt(int32_t offset) const {
00252     return getCharAt(offset);
00253 }
00254 
00255 inline UChar32
00256 Replaceable::char32At(int32_t offset) const {
00257     return getChar32At(offset);
00258 }
00259 
00260 // There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
00261 
00262 U_NAMESPACE_END
00263 
00264 #endif /* U_SHOW_CPLUSPLUS_API */
00265 
00266 #endif