ICU 63.1 63.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 #include "unicode/uobject.h"
27
28 U_NAMESPACE_BEGIN
29
30 class UnicodeString;
31
51 class U_COMMON_API Appendable : public UObject {
52 public:
57 ~Appendable();
58
65 virtual UBool appendCodeUnit(char16_t c) = 0;
66
74 virtual UBool appendCodePoint(UChar32 c);
75
84 virtual UBool appendString(const char16_t *s, int32_t length);
85
95 virtual UBool reserveAppendCapacity(int32_t appendCapacity);
96
141 virtual char16_t *getAppendBuffer(int32_t minCapacity,
142 int32_t desiredCapacityHint,
143 char16_t *scratch, int32_t scratchCapacity,
144 int32_t *resultCapacity);
145 };
146
153 class U_COMMON_API UnicodeStringAppendable : public Appendable {
154 public:
160 explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
161
166 ~UnicodeStringAppendable();
167
174 virtual UBool appendCodeUnit(char16_t c);
175
182 virtual UBool appendCodePoint(UChar32 c);
183
191 virtual UBool appendString(const char16_t *s, int32_t length);
192
200 virtual UBool reserveAppendCapacity(int32_t appendCapacity);
201
223 virtual char16_t *getAppendBuffer(int32_t minCapacity,
224 int32_t desiredCapacityHint,
225 char16_t *scratch, int32_t scratchCapacity,
226 int32_t *resultCapacity);
227
228 private:
229 UnicodeString &str;
230 };
231
232 U_NAMESPACE_END
233
234 #endif // __APPENDABLE_H__
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::UnicodeStringAppendable
An Appendable implementation which writes to a UnicodeString.
Definition: appendable.h:153
icu::Appendable::appendString
virtual UBool appendString(const char16_t *s, int32_t length)
Appends a string.
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&#39;s capacity to *resultCapacity.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
icu::Appendable::appendCodePoint
virtual UBool appendCodePoint(UChar32 c)
Appends a code point.
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:389
icu::UnicodeStringAppendable::UnicodeStringAppendable
UnicodeStringAppendable(UnicodeString &s)
Aliases the UnicodeString (keeps its reference) for writing.
Definition: appendable.h:160
uobject.h
C++ API: Common ICU base class UObject.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
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
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:289
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:220
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
icu::Appendable
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:51