Woopsi 1.0 GUI Framework for Nintendo DS Homebrew

- Main Page
- Classes
- Files

- File List

# woopsistring.h

    00001 #ifndef _WOOPSI_STRING_H_
    00002 #define _WOOPSI_STRING_H_
    00003
    00004 #include <nds.h>
    00005
    00006 namespace WoopsiUI {
    00007
    00008         class StringIterator;
    00009
    00029         class WoopsiString {
    00030         public:
    00031
    00035                 WoopsiString();
    00036
    00042                 WoopsiString(const char* text);
    00043
    00048                 WoopsiString(const u32 letter);
    00049
    00054                 WoopsiString(const WoopsiString& string);
    00055
    00059                 virtual inline ~WoopsiString() {
    00060                         delete[] _text;
    00061                         _text = NULL;
    00062                 };
    00063
    00070                 StringIterator* newStringIterator() const;
    00071
    00081                 virtual void copyToCharArray(char* buffer) const;
    00082
    00087                 virtual void setText(const WoopsiString& text);
    00088
    00093                 virtual void setText(const char* text);
    00094
    00099                 virtual void setText(const u32 text);
    00100
    00105                 virtual void append(const WoopsiString& text);
    00106
    00112                 virtual void insert(const WoopsiString& text, const s32 index);
    00113
    00118                 virtual void remove(const s32 startIndex);
    00119
    00126                 virtual void remove(const s32 startIndex, const s32 count);
    00127
    00132                 virtual const s32 getLength() const { return _stringLength; };
    00133
    00138                 virtual const s32 getByteCount() const { return _dataLength; };
    00139
    00149                 virtual const u32 getCharAt(s32 index) const;
    00150
    00157                 const s32 indexOf(u32 letter) const;
    00158
    00167                 const s32 indexOf(u32 letter, s32 startIndex) const;
    00168
    00179                 virtual const s32 indexOf(u32 letter, s32 startIndex, s32 count) const;
    00180
    00187                 const s32 lastIndexOf(u32 letter) const;
    00188
    00198                 const s32 lastIndexOf(u32 letter, s32 startIndex) const;
    00199
    00210                 virtual const s32 lastIndexOf(u32 letter, s32 startIndex, s32 count) const;
    00211
    00219                 WoopsiString* subString(s32 startIndex) const;
    00220
    00229                 WoopsiString* subString(s32 startIndex, s32 length) const;
    00230
    00237                 WoopsiString& operator=(const WoopsiString& string);
    00238
    00245                 WoopsiString& operator=(const char* string);
    00246
    00253                 WoopsiString& operator=(u32 letter);
    00254
    00263                 virtual s32 compareTo(const WoopsiString& string) const;
    00264
    00265         protected:
    00266                 char* _text;
    00274                 virtual void allocateMemory(s32 chars, bool preserve);
    00275
    00281                 virtual inline bool hasData() const { return _dataLength > 0; };
    00282
    00287                 virtual inline s32 getAllocatedSize() const { return _allocatedSize; };
    00288
    00299                 s32 filterString(char* dest, const char* src, s32 sourceBytes, s32* totalUnicodeChars) const;
    00300
    00305                 virtual inline const char* getCharArray() const { return _text; };
    00306
    00311                 virtual char* getToken(const s32 index) const;
    00312
    00321                 u32 getCodePoint(const char* string, u8* numChars = NULL) const;
    00322
    00323         private:
    00324                 friend class StringIterator;
    00325
    00326                 s32 _dataLength;
    00327                 s32 _stringLength;              /*< Number of unicode tokens in the string */
    00328                 s32 _allocatedSize;
    00329                 s32 _growAmount;
    00342                  const char* encodeCodePoint(u32 codePoint, u8* numBytes = NULL) const;
    00343         };
    00344 }
    00345
    00346 #endif