1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/appendable.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2011-2012, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +******************************************************************************* 1.9 +* file name: appendable.cpp 1.10 +* encoding: US-ASCII 1.11 +* tab size: 8 (not used) 1.12 +* indentation:4 1.13 +* 1.14 +* created on: 2010dec07 1.15 +* created by: Markus W. Scherer 1.16 +*/ 1.17 + 1.18 +#include "unicode/utypes.h" 1.19 +#include "unicode/appendable.h" 1.20 +#include "unicode/utf16.h" 1.21 + 1.22 +U_NAMESPACE_BEGIN 1.23 + 1.24 +Appendable::~Appendable() {} 1.25 + 1.26 +UBool 1.27 +Appendable::appendCodePoint(UChar32 c) { 1.28 + if(c<=0xffff) { 1.29 + return appendCodeUnit((UChar)c); 1.30 + } else { 1.31 + return appendCodeUnit(U16_LEAD(c)) && appendCodeUnit(U16_TRAIL(c)); 1.32 + } 1.33 +} 1.34 + 1.35 +UBool 1.36 +Appendable::appendString(const UChar *s, int32_t length) { 1.37 + if(length<0) { 1.38 + UChar c; 1.39 + while((c=*s++)!=0) { 1.40 + if(!appendCodeUnit(c)) { 1.41 + return FALSE; 1.42 + } 1.43 + } 1.44 + } else if(length>0) { 1.45 + const UChar *limit=s+length; 1.46 + do { 1.47 + if(!appendCodeUnit(*s++)) { 1.48 + return FALSE; 1.49 + } 1.50 + } while(s<limit); 1.51 + } 1.52 + return TRUE; 1.53 +} 1.54 + 1.55 +UBool 1.56 +Appendable::reserveAppendCapacity(int32_t /*appendCapacity*/) { 1.57 + return TRUE; 1.58 +} 1.59 + 1.60 +UChar * 1.61 +Appendable::getAppendBuffer(int32_t minCapacity, 1.62 + int32_t /*desiredCapacityHint*/, 1.63 + UChar *scratch, int32_t scratchCapacity, 1.64 + int32_t *resultCapacity) { 1.65 + if(minCapacity<1 || scratchCapacity<minCapacity) { 1.66 + *resultCapacity=0; 1.67 + return NULL; 1.68 + } 1.69 + *resultCapacity=scratchCapacity; 1.70 + return scratch; 1.71 +} 1.72 + 1.73 +// UnicodeStringAppendable is implemented in unistr.cpp. 1.74 + 1.75 +U_NAMESPACE_END