appendable.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) 2011-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* file name: appendable.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2010dec07
* created by: Markus W. Scherer
*/
#ifndef __APPENDABLE_H__
#define __APPENDABLE_H__
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/uobject.h"
U_NAMESPACE_BEGIN
class UnicodeString;
class U_COMMON_API Appendable : public UObject {
public:
~Appendable();
virtual UBool appendCodeUnit(char16_t c) = 0;
virtual UBool appendCodePoint(UChar32 c);
virtual UBool appendString(const char16_t *s, int32_t length);
virtual UBool reserveAppendCapacity(int32_t appendCapacity);
virtual char16_t *getAppendBuffer(int32_t minCapacity,
int32_t desiredCapacityHint,
char16_t *scratch, int32_t scratchCapacity,
int32_t *resultCapacity);
};
class U_COMMON_API UnicodeStringAppendable : public Appendable {
public:
explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
~UnicodeStringAppendable();
virtual UBool appendCodeUnit(char16_t c) override;
virtual UBool appendCodePoint(UChar32 c) override;
virtual UBool appendString(const char16_t *s, int32_t length) override;
virtual UBool reserveAppendCapacity(int32_t appendCapacity) override;
virtual char16_t *getAppendBuffer(int32_t minCapacity,
int32_t desiredCapacityHint,
char16_t *scratch, int32_t scratchCapacity,
int32_t *resultCapacity) override;
private:
UnicodeString &str;
};
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // __APPENDABLE_H__
icu::Appendable
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
icu::Appendable::reserveAppendCapacity
virtual UBool reserveAppendCapacity(int32_t appendCapacity)
Tells the object that the caller is going to append roughly appendCapacity char16_ts.
icu::Appendable::appendCodeUnit
virtual UBool appendCodeUnit(char16_t c)=0
Appends a 16-bit code unit.
icu::Appendable::appendString
virtual UBool appendString(const char16_t *s, int32_t length)
Appends a string.
icu::Appendable::appendCodePoint
virtual UBool appendCodePoint(UChar32 c)
Appends a code point.
icu::Appendable::getAppendBuffer
virtual char16_t * getAppendBuffer(int32_t minCapacity, int32_t desiredCapacityHint, char16_t *scratch, int32_t scratchCapacity, int32_t *resultCapacity)
Returns a writable buffer for appending and writes the buffer's capacity to *resultCapacity.
icu::Appendable::~Appendable
~Appendable()
Destructor.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeStringAppendable
An Appendable implementation which writes to a UnicodeString.
Definition: appendable.h:156
icu::UnicodeStringAppendable::reserveAppendCapacity
virtual UBool reserveAppendCapacity(int32_t appendCapacity) override
Tells the UnicodeString that the caller is going to append roughly appendCapacity char16_ts.
icu::UnicodeStringAppendable::appendCodePoint
virtual UBool appendCodePoint(UChar32 c) override
Appends a code point to the string.
icu::UnicodeStringAppendable::UnicodeStringAppendable
UnicodeStringAppendable(UnicodeString &s)
Aliases the UnicodeString (keeps its reference) for writing.
Definition: appendable.h:163
icu::UnicodeStringAppendable::getAppendBuffer
virtual char16_t * getAppendBuffer(int32_t minCapacity, int32_t desiredCapacityHint, char16_t *scratch, int32_t scratchCapacity, int32_t *resultCapacity) override
Returns a writable buffer for appending and writes the buffer's capacity to *resultCapacity.
icu::UnicodeStringAppendable::appendString
virtual UBool appendString(const char16_t *s, int32_t length) override
Appends a string to the UnicodeString.
icu::UnicodeStringAppendable::appendCodeUnit
virtual UBool appendCodeUnit(char16_t c) override
Appends a 16-bit code unit to the string.
icu::UnicodeStringAppendable::~UnicodeStringAppendable
~UnicodeStringAppendable()
Destructor.
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