The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
stringmgr.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * stringmgr.h - class StringMgr: base of string functions. Can be
4  * subclassed and methods re-implemented your favorite
5  * String library with Unicode support, e.g, ICU,
6  * Qt, Java.
7  *
8  * $Id: stringmgr.h 3786 2020-08-30 11:35:14Z scribe $
9  *
10  * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
11  * CrossWire Bible Society
12  * P. O. Box 2528
13  * Tempe, AZ 85280-2528
14  *
15  * This program is free software; you can redistribute it and/or modify it
16  * under the terms of the GNU General Public License as published by the
17  * Free Software Foundation version 2.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * General Public License for more details.
23  *
24  */
25 
26 
27 #ifndef STRINGMGR_H
28 #define STRINGMGR_H
29 
30 #include <defs.h>
31 #include <swbuf.h>
32 #include <utilstr.h>
33 
35 
40 private:
42 public:
43 
47  static void setSystemStringMgr(StringMgr *newStringMgr);
48 
52  static StringMgr *getSystemStringMgr();
53 
58  static inline bool hasUTF8Support() {
59  return getSystemStringMgr()->supportsUnicode();
60  };
61 
67  virtual char *upperUTF8(char *text, unsigned int max = 0) const;
73  virtual char *lowerUTF8(char *text, unsigned int max = 0) const;
74 
75  virtual bool isUpper(SW_u32 character) const;
76  virtual bool isLower(SW_u32 character) const;
77  virtual bool isDigit(SW_u32 character) const;
78  virtual bool isAlpha(SW_u32 character) const;
79 
85  virtual char *upperLatin1(char *text, unsigned int max = 0) const;
86 
87 
88 protected:
90 
93  StringMgr();
94 
97  StringMgr(const StringMgr &);
98 
101  virtual ~StringMgr();
102 
103  virtual bool supportsUnicode() const;
104 };
105 
106 
107 inline char *toupperstr(char *t, unsigned int max = 0) {
108  return StringMgr::getSystemStringMgr()->upperUTF8(t, max);
109 }
110 
111 inline char *tolowerstr(char *t, unsigned int max = 0) {
112  return StringMgr::getSystemStringMgr()->lowerUTF8(t, max);
113 }
114 
115 /*
116  * @deprecated - SWBuf assumed to be UTF-8 now.
117  */
118 inline char *toupperstr_utf8(char *t, unsigned int max = 0) {
119  return StringMgr::getSystemStringMgr()->upperUTF8(t, max);
120 }
121 
122 
124 
125 
126 #endif //STRINGMGR_H
#define SWORD_NAMESPACE_START
Definition: defs.h:39
#define SWDLLEXPORT
Definition: defs.h:171
static bool hasUTF8Support()
Definition: stringmgr.h:58
static StringMgr * getSystemStringMgr()
Definition: stringmgr.cpp:197
char * toupperstr_utf8(char *t, unsigned int max=0)
Definition: stringmgr.h:118
static StringMgr * systemStringMgr
Definition: stringmgr.h:41
virtual char * upperUTF8(char *text, unsigned int max=0) const
Definition: stringmgr.cpp:223
char * tolowerstr(char *t, unsigned int max=0)
Definition: stringmgr.h:111
unsigned int SW_u32
Definition: sysdata.h:41
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
#define SWORD_NAMESPACE_END
Definition: defs.h:40
virtual char * lowerUTF8(char *text, unsigned int max=0) const
Definition: stringmgr.cpp:284