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/uobject.h" 00020 00026 U_NAMESPACE_BEGIN 00027 00028 class UnicodeString; 00029 00073 class U_COMMON_API Replaceable : public UObject { 00074 00075 public: 00080 virtual ~Replaceable(); 00081 00087 inline int32_t length() const; 00088 00096 inline char16_t charAt(int32_t offset) const; 00097 00110 inline UChar32 char32At(int32_t offset) const; 00111 00122 virtual void extractBetween(int32_t start, 00123 int32_t limit, 00124 UnicodeString& target) const = 0; 00125 00146 virtual void handleReplaceBetween(int32_t start, 00147 int32_t limit, 00148 const UnicodeString& text) = 0; 00149 // Note: All other methods in this class take the names of 00150 // existing UnicodeString methods. This method is the exception. 00151 // It is named differently because all replace methods of 00152 // UnicodeString return a UnicodeString&. The 'between' is 00153 // required in order to conform to the UnicodeString naming 00154 // convention; API taking start/length are named <operation>, and 00155 // those taking start/limit are named <operationBetween>. The 00156 // 'handle' is added because 'replaceBetween' and 00157 // 'doReplaceBetween' are already taken. 00158 00174 virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0; 00175 00185 virtual UBool hasMetaData() const; 00186 00202 virtual Replaceable *clone() const; 00203 00204 protected: 00205 00210 inline Replaceable(); 00211 00212 /* 00213 * Assignment operator not declared. The compiler will provide one 00214 * which does nothing since this class does not contain any data members. 00215 * API/code coverage may show the assignment operator as present and 00216 * untested - ignore. 00217 * Subclasses need this assignment operator if they use compiler-provided 00218 * assignment operators of their own. An alternative to not declaring one 00219 * here would be to declare and empty-implement a protected or public one. 00220 Replaceable &Replaceable::operator=(const Replaceable &); 00221 */ 00222 00227 virtual int32_t getLength() const = 0; 00228 00233 virtual char16_t getCharAt(int32_t offset) const = 0; 00234 00239 virtual UChar32 getChar32At(int32_t offset) const = 0; 00240 }; 00241 00242 inline Replaceable::Replaceable() {} 00243 00244 inline int32_t 00245 Replaceable::length() const { 00246 return getLength(); 00247 } 00248 00249 inline char16_t 00250 Replaceable::charAt(int32_t offset) const { 00251 return getCharAt(offset); 00252 } 00253 00254 inline UChar32 00255 Replaceable::char32At(int32_t offset) const { 00256 return getChar32At(offset); 00257 } 00258 00259 // There is no rep.cpp, see unistr.cpp for Replaceable function implementations. 00260 00261 U_NAMESPACE_END 00262 00263 #endif
1.6.1