ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
appendable.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2011, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 * file name: appendable.h
7 * encoding: US-ASCII
8 * tab size: 8 (not used)
9 * indentation:4
10 *
11 * created on: 2010dec07
12 * created by: Markus W. Scherer
13 */
14 
15 #ifndef __APPENDABLE_H__
16 #define __APPENDABLE_H__
17 
23 #include "unicode/utypes.h"
24 #include "unicode/uobject.h"
25 
27 
28 class UnicodeString;
29 
50 public:
57  virtual UBool appendCodeUnit(UChar c) = 0;
58 
66  virtual UBool appendCodePoint(UChar32 c);
67 
76  virtual UBool appendString(const UChar *s, int32_t length);
77 
87  virtual UBool reserveAppendCapacity(int32_t appendCapacity);
88 
133  virtual UChar *getAppendBuffer(int32_t minCapacity,
134  int32_t desiredCapacityHint,
135  UChar *scratch, int32_t scratchCapacity,
136  int32_t *resultCapacity);
137 
138 private:
139  // No ICU "poor man's RTTI" for this class nor its subclasses.
140  virtual UClassID getDynamicClassID() const;
141 };
142 
150 public:
156  explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
157 
164  virtual UBool appendCodeUnit(UChar c);
165 
172  virtual UBool appendCodePoint(UChar32 c);
173 
181  virtual UBool appendString(const UChar *s, int32_t length);
182 
190  virtual UBool reserveAppendCapacity(int32_t appendCapacity);
191 
213  virtual UChar *getAppendBuffer(int32_t minCapacity,
214  int32_t desiredCapacityHint,
215  UChar *scratch, int32_t scratchCapacity,
216  int32_t *resultCapacity);
217 
218 private:
219  UnicodeString &str;
220 };
221 
223 
224 #endif // __APPENDABLE_H__
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:49
virtual UBool appendCodeUnit(UChar c)=0
Appends a 16-bit code unit.
UnicodeStringAppendable(UnicodeString &s)
Aliases the UnicodeString (keeps its reference) for writing.
Definition: appendable.h:156
An Appendable implementation which writes to a UnicodeString.
Definition: appendable.h:149
virtual UBool appendString(const UChar *s, int32_t length)
Appends a string.
virtual UBool appendCodePoint(UChar32 c)
Appends a code point.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:345
virtual UBool reserveAppendCapacity(int32_t appendCapacity)
Tells the object that the caller is going to append roughly appendCapacity UChars.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:188
C++ API: Common ICU base class UObject.
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:325
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:215
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:385
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:520
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228
virtual UChar * getAppendBuffer(int32_t minCapacity, int32_t desiredCapacityHint, UChar *scratch, int32_t scratchCapacity, int32_t *resultCapacity)
Returns a writable buffer for appending and writes the buffer's capacity to *resultCapacity.