rep.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**************************************************************************
* Copyright (C) 1999-2012, International Business Machines Corporation and
* others. All Rights Reserved.
**************************************************************************
* Date Name Description
* 11/17/99 aliu Creation. Ported from java. Modified to
* match current UnicodeString API. Forced
* to use name "handleReplaceBetween" because
* of existing methods in UnicodeString.
**************************************************************************
*/
#ifndef REP_H
#define REP_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/uobject.h"
U_NAMESPACE_BEGIN
class UnicodeString;
class U_COMMON_API Replaceable : public UObject {
public:
virtual ~Replaceable();
inline int32_t length() const;
inline char16_t charAt(int32_t offset) const;
inline UChar32 char32At(int32_t offset) const;
virtual void extractBetween(int32_t start,
int32_t limit,
UnicodeString& target) const = 0;
virtual void handleReplaceBetween(int32_t start,
int32_t limit,
const UnicodeString& text) = 0;
// Note: All other methods in this class take the names of
// existing UnicodeString methods. This method is the exception.
// It is named differently because all replace methods of
// UnicodeString return a UnicodeString&. The 'between' is
// required in order to conform to the UnicodeString naming
// convention; API taking start/length are named <operation>, and
// those taking start/limit are named <operationBetween>. The
// 'handle' is added because 'replaceBetween' and
// 'doReplaceBetween' are already taken.
virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
virtual UBool hasMetaData() const;
virtual Replaceable *clone() const;
protected:
inline Replaceable();
/*
* Assignment operator not declared. The compiler will provide one
* which does nothing since this class does not contain any data members.
* API/code coverage may show the assignment operator as present and
* untested - ignore.
* Subclasses need this assignment operator if they use compiler-provided
* assignment operators of their own. An alternative to not declaring one
* here would be to declare and empty-implement a protected or public one.
Replaceable &Replaceable::operator=(const Replaceable &);
*/
virtual int32_t getLength() const = 0;
virtual char16_t getCharAt(int32_t offset) const = 0;
virtual UChar32 getChar32At(int32_t offset) const = 0;
};
inline Replaceable::Replaceable() {}
inline int32_t
Replaceable::length() const {
return getLength();
}
inline char16_t
Replaceable::charAt(int32_t offset) const {
return getCharAt(offset);
}
inline UChar32
Replaceable::char32At(int32_t offset) const {
return getChar32At(offset);
}
// There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::Replaceable
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
Definition: rep.h:77
icu::Replaceable::~Replaceable
virtual ~Replaceable()
Destructor.
icu::Replaceable::extractBetween
virtual void extractBetween(int32_t start, int32_t limit, UnicodeString &target) const =0
Copies characters in the range [start, limit) into the UnicodeString target.
icu::Replaceable::getChar32At
virtual UChar32 getChar32At(int32_t offset) const =0
Virtual version of char32At().
icu::Replaceable::copy
virtual void copy(int32_t start, int32_t limit, int32_t dest)=0
Copies a substring of this object, retaining metadata.
icu::Replaceable::handleReplaceBetween
virtual void handleReplaceBetween(int32_t start, int32_t limit, const UnicodeString &text)=0
Replaces a substring of this object with the given text.
icu::Replaceable::getCharAt
virtual char16_t getCharAt(int32_t offset) const =0
Virtual version of charAt().
icu::Replaceable::getLength
virtual int32_t getLength() const =0
Virtual version of length().
icu::Replaceable::clone
virtual Replaceable * clone() const
Clone this object, an instance of a subclass of Replaceable.
icu::Replaceable::hasMetaData
virtual UBool hasMetaData() const
Returns true if this object contains metadata.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:435
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
uobject.h
C++ API: Common ICU base class UObject.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:300