ICU 72.1 72.1
appendable.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4*******************************************************************************
5* Copyright (C) 2011-2012, International Business Machines
6* Corporation and others. All Rights Reserved.
7*******************************************************************************
8* file name: appendable.h
9* encoding: UTF-8
10* tab size: 8 (not used)
11* indentation:4
12*
13* created on: 2010dec07
14* created by: Markus W. Scherer
15*/
16
17#ifndef __APPENDABLE_H__
18#define __APPENDABLE_H__
19
25#include "unicode/utypes.h"
26
27#if U_SHOW_CPLUSPLUS_API
28
29#include "unicode/uobject.h"
30
31U_NAMESPACE_BEGIN
32
33class UnicodeString;
34
55public:
61
68 virtual UBool appendCodeUnit(char16_t c) = 0;
69
78
87 virtual UBool appendString(const char16_t *s, int32_t length);
88
98 virtual UBool reserveAppendCapacity(int32_t appendCapacity);
99
144 virtual char16_t *getAppendBuffer(int32_t minCapacity,
145 int32_t desiredCapacityHint,
146 char16_t *scratch, int32_t scratchCapacity,
147 int32_t *resultCapacity);
148};
149
157public:
163 explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
164
170
177 virtual UBool appendCodeUnit(char16_t c) override;
178
185 virtual UBool appendCodePoint(UChar32 c) override;
186
194 virtual UBool appendString(const char16_t *s, int32_t length) override;
195
203 virtual UBool reserveAppendCapacity(int32_t appendCapacity) override;
204
226 virtual char16_t *getAppendBuffer(int32_t minCapacity,
227 int32_t desiredCapacityHint,
228 char16_t *scratch, int32_t scratchCapacity,
229 int32_t *resultCapacity) override;
230
231private:
232 UnicodeString &str;
233};
234
235U_NAMESPACE_END
236
237#endif /* U_SHOW_CPLUSPLUS_API */
238
239#endif // __APPENDABLE_H__
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
virtual UBool reserveAppendCapacity(int32_t appendCapacity)
Tells the object that the caller is going to append roughly appendCapacity char16_ts.
virtual UBool appendCodeUnit(char16_t c)=0
Appends a 16-bit code unit.
virtual UBool appendString(const char16_t *s, int32_t length)
Appends a string.
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.
virtual UBool appendCodePoint(UChar32 c)
Appends a code point.
~Appendable()
Destructor.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
An Appendable implementation which writes to a UnicodeString.
Definition: appendable.h:156
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.
virtual UBool reserveAppendCapacity(int32_t appendCapacity) override
Tells the UnicodeString that the caller is going to append roughly appendCapacity char16_ts.
virtual UBool appendCodePoint(UChar32 c) override
Appends a code point to the string.
UnicodeStringAppendable(UnicodeString &s)
Aliases the UnicodeString (keeps its reference) for writing.
Definition: appendable.h:163
virtual UBool appendString(const char16_t *s, int32_t length) override
Appends a string to the UnicodeString.
virtual UBool appendCodeUnit(char16_t c) override
Appends a 16-bit code unit to the string.
~UnicodeStringAppendable()
Destructor.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:461
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
C++ API: Common ICU base class UObject.
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:300