ICU 73.2  73.2
appendable.h
Go to the documentation of this file.
00001 // © 2016 and later: Unicode, Inc. and others.
00002 // License & terms of use: http://www.unicode.org/copyright.html
00003 /*
00004 *******************************************************************************
00005 *   Copyright (C) 2011-2012, International Business Machines
00006 *   Corporation and others.  All Rights Reserved.
00007 *******************************************************************************
00008 *   file name:  appendable.h
00009 *   encoding:   UTF-8
00010 *   tab size:   8 (not used)
00011 *   indentation:4
00012 *
00013 *   created on: 2010dec07
00014 *   created by: Markus W. Scherer
00015 */
00016 
00017 #ifndef __APPENDABLE_H__
00018 #define __APPENDABLE_H__
00019 
00025 #include "unicode/utypes.h"
00026 
00027 #if U_SHOW_CPLUSPLUS_API
00028 
00029 #include "unicode/uobject.h"
00030 
00031 U_NAMESPACE_BEGIN
00032 
00033 class UnicodeString;
00034 
00054 class U_COMMON_API Appendable : public UObject {
00055 public:
00060     ~Appendable();
00061 
00068     virtual UBool appendCodeUnit(char16_t c) = 0;
00069 
00077     virtual UBool appendCodePoint(UChar32 c);
00078 
00087     virtual UBool appendString(const char16_t *s, int32_t length);
00088 
00098     virtual UBool reserveAppendCapacity(int32_t appendCapacity);
00099 
00144     virtual char16_t *getAppendBuffer(int32_t minCapacity,
00145                                    int32_t desiredCapacityHint,
00146                                    char16_t *scratch, int32_t scratchCapacity,
00147                                    int32_t *resultCapacity);
00148 };
00149 
00156 class U_COMMON_API UnicodeStringAppendable : public Appendable {
00157 public:
00163     explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
00164 
00169     ~UnicodeStringAppendable();
00170 
00177     virtual UBool appendCodeUnit(char16_t c) override;
00178 
00185     virtual UBool appendCodePoint(UChar32 c) override;
00186 
00194     virtual UBool appendString(const char16_t *s, int32_t length) override;
00195 
00203     virtual UBool reserveAppendCapacity(int32_t appendCapacity) override;
00204 
00226     virtual char16_t *getAppendBuffer(int32_t minCapacity,
00227                                    int32_t desiredCapacityHint,
00228                                    char16_t *scratch, int32_t scratchCapacity,
00229                                    int32_t *resultCapacity) override;
00230 
00231 private:
00232     UnicodeString &str;
00233 };
00234 
00235 U_NAMESPACE_END
00236 
00237 #endif /* U_SHOW_CPLUSPLUS_API */
00238 
00239 #endif  // __APPENDABLE_H__