1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2011-2012, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: appendable.cpp
10 * tab size: 8 (not used)
13 * created on: 2010dec07
14 * created by: Markus W. Scherer
17 #include "unicode/utypes.h"
18 #include "unicode/appendable.h"
19 #include "unicode/utf16.h"
23 Appendable::~Appendable() {}
26 Appendable::appendCodePoint(UChar32 c) {
28 return appendCodeUnit((UChar)c);
30 return appendCodeUnit(U16_LEAD(c)) && appendCodeUnit(U16_TRAIL(c));
35 Appendable::appendString(const UChar *s, int32_t length) {
39 if(!appendCodeUnit(c)) {
44 const UChar *limit=s+length;
46 if(!appendCodeUnit(*s++)) {
55 Appendable::reserveAppendCapacity(int32_t /*appendCapacity*/) {
60 Appendable::getAppendBuffer(int32_t minCapacity,
61 int32_t /*desiredCapacityHint*/,
62 UChar *scratch, int32_t scratchCapacity,
63 int32_t *resultCapacity) {
64 if(minCapacity<1 || scratchCapacity<minCapacity) {
68 *resultCapacity=scratchCapacity;
72 // UnicodeStringAppendable is implemented in unistr.cpp.