00001 /* 00002 * TUnicodeTextStorage.h 00003 * Ritmo 00004 * 00005 * Created by Chris Reed on Sun Mar 02 2003. 00006 * Copyright (c) 2003 Chris Reed. All rights reserved. 00007 * 00008 */ 00009 #if !defined(_TUnicodeTextStorage_h_) 00010 #define _TUnicodeTextStorage_h_ 00011 00012 #include <Carbon/Carbon.h> 00013 00017 class TUnicodeTextStorage 00018 { 00019 public: 00021 TUnicodeTextStorage(); 00022 virtual ~TUnicodeTextStorage(); 00023 00024 bool ReserveSpace(uint32_t totalCount); 00025 00027 unsigned Count() const { return mCount; } 00028 00030 00031 void SetString(CFStringRef text); 00032 void SetText(const UniChar* text, uint32_t count); 00034 00036 00037 CFStringRef GetString(); 00038 // UniChar* GetText() { return mStorage; } 00039 const UniChar* GetText() { return mStorage; } 00041 00043 00044 TUnicodeTextStorage& operator = (CFStringRef text) { SetString(text); return *this; } 00045 operator CFStringRef () { return GetString(); } 00046 00047 operator UniChar* () { return mStorage; } 00048 operator const UniChar* () { return mStorage; } 00049 UniChar& operator [] (int index) { return mStorage[index]; } 00051 00053 00054 void Delete(uint32_t start, uint32_t count=1); 00055 00056 void InsertString(uint32_t position, CFStringRef text); 00057 void InsertText(uint32_t position, const UniChar* text, uint32_t count); 00058 00059 void AppendString(CFStringRef text) { InsertString(mCount, text); } 00060 void AppendText(const UniChar* text, uint32_t count) { InsertText(mCount, text, count); } 00062 00063 protected: 00064 UniChar* mStorage; 00065 uint32_t mCount; 00066 uint32_t mSize; 00067 00068 void Allocate(uint32_t characters); 00069 }; 00070 00071 #endif // _TUnicodeTextStorage_h_