- 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 inline s32 compareTo(const WoopsiString& string) const {
    00264                         return strncmp(_text, string.getCharArray(), getLength());
    00265                 }
    00266
    00267         protected:
    00268                 char* _text;
    00276                 virtual void allocateMemory(s32 chars, bool preserve);
    00277
    00283                 virtual inline bool hasData() const { return _dataLength > 0; };
    00284
    00289                 virtual inline s32 getAllocatedSize() const { return _allocatedSize; };
    00290
    00301                 s32 filterString(char* dest, const char* src, s32 sourceBytes, s32* totalUnicodeChars) const;
    00302
    00307                 virtual inline const char* getCharArray() const { return _text; };
    00308
    00313                 virtual char* getToken(const s32 index) const;
    00314
    00323                 u32 getCodePoint(const char* string, u8* numChars) const;
    00324
    00325         private:
    00326                 friend class StringIterator;
    00327
    00328                 s32 _dataLength;
    00329                 s32 _stringLength;              /*< Number of unicode tokens in the string */
    00330                 s32 _allocatedSize;
    00331                 s32 _growAmount;
    00344                  const char* encodeCodePoint(u32 codePoint, u8* numBytes) const;
    00345         };
    00346 }
    00347
    00348 #endif