appendable.h

Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 *   Copyright (C) 2011-2012, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 *******************************************************************************
00006 *   file name:  appendable.h
00007 *   encoding:   US-ASCII
00008 *   tab size:   8 (not used)
00009 *   indentation:4
00010 *
00011 *   created on: 2010dec07
00012 *   created by: Markus W. Scherer
00013 */
00014 
00015 #ifndef __APPENDABLE_H__
00016 #define __APPENDABLE_H__
00017 
00023 #include "unicode/utypes.h"
00024 #include "unicode/uobject.h"
00025 
00026 U_NAMESPACE_BEGIN
00027 
00028 class UnicodeString;
00029 
00049 class U_COMMON_API Appendable : public UObject {
00050 public:
00055     ~Appendable();
00056 
00063     virtual UBool appendCodeUnit(UChar c) = 0;
00064 
00072     virtual UBool appendCodePoint(UChar32 c);
00073 
00082     virtual UBool appendString(const UChar *s, int32_t length);
00083 
00093     virtual UBool reserveAppendCapacity(int32_t appendCapacity);
00094 
00139     virtual UChar *getAppendBuffer(int32_t minCapacity,
00140                                    int32_t desiredCapacityHint,
00141                                    UChar *scratch, int32_t scratchCapacity,
00142                                    int32_t *resultCapacity);
00143 
00144 private:
00145     // No ICU "poor man's RTTI" for this class nor its subclasses.
00146     virtual UClassID getDynamicClassID() const;
00147 };
00148 
00155 class U_COMMON_API UnicodeStringAppendable : public Appendable {
00156 public:
00162     explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
00163 
00168     ~UnicodeStringAppendable();
00169 
00176     virtual UBool appendCodeUnit(UChar c);
00177 
00184     virtual UBool appendCodePoint(UChar32 c);
00185 
00193     virtual UBool appendString(const UChar *s, int32_t length);
00194 
00202     virtual UBool reserveAppendCapacity(int32_t appendCapacity);
00203 
00225     virtual UChar *getAppendBuffer(int32_t minCapacity,
00226                                    int32_t desiredCapacityHint,
00227                                    UChar *scratch, int32_t scratchCapacity,
00228                                    int32_t *resultCapacity);
00229 
00230 private:
00231     UnicodeString &str;
00232 };
00233 
00234 U_NAMESPACE_END
00235 
00236 #endif  // __APPENDABLE_H__

Generated on 27 Oct 2013 for ICU 50.1.2 by  doxygen 1.4.7