#include <stringmgr.h>

Public Member Functions | |
| virtual char * | upperLatin1 (char *text, unsigned int max=0) const |
| virtual char * | upperUTF8 (char *text, unsigned int max=0) const |
Static Public Member Functions | |
| static StringMgr * | getSystemStringMgr () |
| static bool | hasUTF8Support () |
| static void | setSystemStringMgr (StringMgr *newStringMgr) |
Protected Member Functions | |
| StringMgr (const StringMgr &) | |
| StringMgr () | |
| virtual bool | supportsUnicode () const |
| virtual | ~StringMgr () |
Static Private Attributes | |
| static StringMgr * | systemStringMgr = 0 |
Friends | |
| class | __staticsystemStringMgr |
StringMgr is a way to provide UTf8 handling by the Sword frontend Each platform, if it's up-to-date, should provide functions to handle unicode and utf8. This class makes it possible to implement Unicode support on the user-side and not in Sword itself.
Definition at line 36 of file stringmgr.h.
| StringMgr::StringMgr | ( | ) | [protected] |
Default constructor. Protected to make instances on user side impossible, because this is a Singleton
Default constructor
Definition at line 134 of file stringmgr.cpp.
| StringMgr::StringMgr | ( | const StringMgr & | m | ) | [protected] |
| StringMgr::~StringMgr | ( | ) | [protected, virtual] |
| StringMgr * StringMgr::getSystemStringMgr | ( | ) | [static] |
Returns the global StringMgr handle
Definition at line 165 of file stringmgr.cpp.
00165 { 00166 if (!systemStringMgr) { 00167 #ifdef _ICU_ 00168 systemStringMgr = new ICUStringMgr(); 00169 // SWLog::getSystemLog()->logInformation("created default ICUStringMgr"); 00170 #else 00171 systemStringMgr = new StringMgr(); 00172 // SWLog::getSystemLog()->logInformation("created default StringMgr"); 00173 #endif 00174 } 00175 00176 return systemStringMgr; 00177 }
| static bool StringMgr::hasUTF8Support | ( | ) | [inline, static] |
Checks whether Utf8 support is available. Override the function supportsUnicode() to tell whether your implementation has utf8 support.
Definition at line 53 of file stringmgr.h.
00053 { 00054 return getSystemStringMgr()->supportsUnicode(); 00055 };
| void StringMgr::setSystemStringMgr | ( | StringMgr * | newStringMgr | ) | [static] |
Sets the global StringMgr handle
Definition at line 150 of file stringmgr.cpp.
00150 { 00151 if (systemStringMgr) 00152 delete systemStringMgr; 00153 00154 systemStringMgr = newStringMgr; 00155 00156 // TODO: this is magic. apparently we have to reset the system localemgr upon changing stringmgr. 00157 // setting system stringmgr should be set before localemgr and not possible to change. 00158 // rework this design. 00159 LocaleMgr::getSystemLocaleMgr()->setSystemLocaleMgr(new LocaleMgr()); 00160 }
| bool StringMgr::supportsUnicode | ( | ) | const [protected, virtual] |
Definition at line 235 of file stringmgr.cpp.
| char * StringMgr::upperLatin1 | ( | char * | buf, | |
| unsigned int | maxlen = 0 | |||
| ) | const [virtual] |
Converts the param to an uppercase latin1 string
| text | The text encoded in latin1 which should be turned into an upper case string | |
| max | Max buffer size |
Converts the param to an uppercase latin1 string
| The | text encoded in latin1 which should be turned into an upper case string |
Definition at line 220 of file stringmgr.cpp.
| char * StringMgr::upperUTF8 | ( | char * | t, | |
| unsigned int | maxlen = 0 | |||
| ) | const [virtual] |
Converts the param to an upper case Utf8 string
| text | The text encoded in utf8 which should be turned into an upper case string | |
| max | Max buffer size |
This is a fallback method. It should never be called. If UTF8 support is desired, then a UTF8 StringMgr needs to be used.
Here we just do our best.
Converts the param to an upper case UTF8 string
| t | - The text encoded in utf8 which should be turned into an upper case string |
Definition at line 191 of file stringmgr.cpp.
00191 { 00192 // try to decide if it's worth trying to toupper. Do we have more 00193 // characters which are probably lower latin than not? 00194 // we still don't use isValidUTF8 optimally. what if we have 1 unicode 00195 // character in the string? should we not try to upper any of the string? 00196 // dunno. Best solution is to upper all other characters. Don't have 00197 // time to write that before release. 00198 long performOp = 0; 00199 if (!isValidUTF8((unsigned char *)t)) { 00200 performOp = 1; 00201 } 00202 else { 00203 for (const char *ch = t; *ch; ch++) { 00204 performOp += (*ch > 0) ? 1 : -1; 00205 } 00206 } 00207 00208 if (performOp > 0) { 00209 return upperLatin1(t); 00210 } 00211 00212 return t; 00213 }
friend class __staticsystemStringMgr [friend] |
Definition at line 73 of file stringmgr.h.
SWORD_NAMESPACE_START StringMgr * StringMgr::systemStringMgr = 0 [static, private] |
Definition at line 90 of file stringmgr.h.
1.6.1