stringmgr.h

00001 /******************************************************************************
00002  *      stringmgr.h - A class which provides string handling functions which can 
00003  *                      be reimplemented by frontends
00004  *
00005  * $Id: stringmgr.h 2057 2007-07-03 20:51:33Z scribe $
00006  *
00007  * Copyright 2005 CrossWire Bible Society (http://www.crosswire.org)
00008  *      CrossWire Bible Society
00009  *      P. O. Box 2528
00010  *      Tempe, AZ       85280-2528
00011  *
00012  * This program is free software; you can redistribute it and/or modify it
00013  * under the terms of the GNU General Public License as published by the
00014  * Free Software Foundation version 2.
00015  *
00016  * This program is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00019  * General Public License for more details.
00020  *
00021  */
00022 
00023 
00024 #ifndef STRINGMGR_H
00025 #define STRINGMGR_H
00026 
00027 #include <defs.h>
00028 #include <swbuf.h>
00029 #include <utilstr.h>
00030 
00031 SWORD_NAMESPACE_START
00032 
00036 class SWDLLEXPORT StringMgr {
00037 public:
00038 
00042         static void setSystemStringMgr(StringMgr *newStringMgr);
00043    
00047         static StringMgr *getSystemStringMgr();
00048 
00053         static inline bool hasUTF8Support() {
00054                 return getSystemStringMgr()->supportsUnicode();
00055         };
00056         
00061         virtual char *upperUTF8(char *text, unsigned int max = 0) const;
00062    
00066         virtual char *upperLatin1(char *text, unsigned int max = 0) const;
00067         
00068 
00069 protected:
00070         friend class __staticsystemStringMgr;
00071         
00074         StringMgr();
00075    
00078         StringMgr(const StringMgr &);
00079    
00082         virtual ~StringMgr();
00083         
00084         virtual bool supportsUnicode() const;
00085 
00086 private:
00087         static StringMgr *systemStringMgr;
00088 };
00089 
00090 inline char *toupperstr(char *t, unsigned int max = 0) {
00091         return StringMgr::getSystemStringMgr()->upperUTF8(t, max);
00092 }
00093         
00094 inline char *toupperstr_utf8(char *t, unsigned int max = 0) {
00095         return StringMgr::getSystemStringMgr()->upperUTF8(t, max);
00096 }
00097         
00098 inline SWBuf &toupperstr(SWBuf &b) {
00099         char *utf8 = 0;
00100         stdstr(&utf8, b.c_str(), 2);
00101         toupperstr(utf8, strlen(utf8)*2);
00102         b = utf8;
00103         delete [] utf8;
00104         return b;
00105 }
00106 
00107 SWORD_NAMESPACE_END
00108 
00109 
00110 #endif //STRINGMGR_H