1 //========================================================================
7 // Copyright 2005 Albert Astals Cid <aacid@kde.org>
9 //========================================================================
14 #include "CharTypes.h"
22 // Create empty unicode string
25 // Create a unicode string from <str>.
26 UGooString(GooString
&str
);
28 // Copy the unicode string
29 UGooString(const UGooString
&str
);
31 // Create a unicode string from <str>.
32 UGooString(const char *str
, int strLen
= CALC_STRING_LEN
);
34 UGooString
*Set(const char *str
, int strLen
= CALC_STRING_LEN
);
35 UGooString
*Set(const UGooString
&str
);
37 // Set the string to empty string, freeing all dynamically allocated memory
39 UGooString
*clear(void);
43 void resize(int newLength
);
45 int getLength() const { return length
; }
47 // Compare two strings: -1:< 0:= +1:>
48 int cmp(const UGooString
*str
) const;
49 int cmp(const UGooString
&str
) const;
50 int cmp(const char *str
, int strLen
= CALC_STRING_LEN
) const;
53 Unicode
*unicode() const { return s
; }
55 // Return a newly allocated copy of the string converted to
56 // ascii (non-Unicode) format. Caller has to delete [] the result
57 char *getCStringCopy() const;
59 // a special value telling that the length of the string is not given
60 // so it must be calculated from the strings
61 static const int CALC_STRING_LEN
= -1;
64 // you can tweak this number for a different speed/memory usage tradeoffs.
65 // In libc malloc() rounding is 16 so it's best to choose a value that
66 // results in sizeof(UGooString) be a multiple of 16.
67 // 20 makes sizeof(UGooString) to be 48.
68 static const int STR_STATIC_SIZE
= 20;
70 int roundedSize(int len
);
71 void initChar(const char *str
, int strLen
);
73 Unicode sStatic
[STR_STATIC_SIZE
];