localemgr.h

00001 /******************************************************************************
00002  *  localemgr.h   - definition of class LocaleMgr used to interact with
00003  *                              registered locales for a sword installation
00004  *
00005  * $Id: localemgr.h 1864 2005-11-20 06:06:40Z scribe $
00006  *
00007  * Copyright 1998 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 #ifndef LOCALEMGR_H
00024 #define LOCALEMGR_H
00025 
00026 #include <map>
00027 #include <list>
00028 
00029 #include <defs.h>
00030 #include <swbuf.h>
00031 
00032 SWORD_NAMESPACE_START
00033 
00034 class SWLocale;
00035  
00036 typedef std::list<SWBuf> StringList;
00037 typedef std::map < SWBuf, SWLocale *, std::less < SWBuf > > LocaleMap;
00049 class SWDLLEXPORT LocaleMgr {
00050 private:
00051         void deleteLocales();
00052         char *defaultLocaleName;
00053         LocaleMgr(const LocaleMgr &);
00054         friend class __staticsystemLocaleMgr;
00055 protected:
00056         LocaleMap *locales;
00057         static LocaleMgr *systemLocaleMgr;
00058 
00059 public:
00060 
00064         LocaleMgr(const char *iConfigPath = 0);
00065 
00069         virtual ~LocaleMgr();
00070 
00076         virtual SWLocale *getLocale(const char *name);
00077 
00082         virtual StringList getAvailableLocales();
00083 
00091         virtual const char *translate(const char *text, const char *localeName = 0);
00092 
00097         virtual const char *getDefaultLocaleName();
00098 
00103         virtual void setDefaultLocaleName(const char *name);
00104 
00108         static LocaleMgr *getSystemLocaleMgr();
00109         static void setSystemLocaleMgr(LocaleMgr *newLocaleMgr);
00110 
00113         virtual void loadConfigDir(const char *ipath);
00114 
00115 };
00116 
00117 SWORD_NAMESPACE_END
00118 #endif