Locale.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/common/Locale.h#11 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2004-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef Fennel_Locale_Included
00024 #define Fennel_Locale_Included
00025 
00026 #include <string>
00027 #include <iostream>
00028 
00029 FENNEL_BEGIN_NAMESPACE
00030 
00031 // Locale represents a user's locale, providing a simplistic mechanism
00032 // for representing language, country and variant.  Locale can compute
00033 // its parent locale.  The parent of a variant locale
00034 // (e.g. "en_US_Southern" or "en_DoubleSpeak") is the same locale sans
00035 // variant ("en_US" and "en" in our example).  The parent of a
00036 // language/country locle (e.g. "en_US" or "fr_CA") is simply the
00037 // language ("en" or "fr" in our example.  Language-only locales have
00038 // no parent.  Language and country codes are always two letters.
00039 // Also, the language should be lowercase and the country uppercase.
00040 class FENNEL_COMMON_EXPORT Locale
00041 {
00042 public:
00043     explicit Locale(const std::string &language);
00044     explicit Locale(const std::string &language, const std::string &country);
00045     explicit Locale(
00046         const std::string &language,const std::string &country,
00047         const std::string &variant);
00048     virtual ~Locale();
00049 
00050     bool operator==(const Locale &rhs) const;
00051     bool operator!=(const Locale &rhs) const;
00052     bool operator<(const Locale &rhs) const;
00053 
00054     const std::string &getLanguage() const;
00055     const std::string &getCountry() const;
00056     const std::string &getVariant() const;
00057 
00058     // Returns lang, lang_country, lang_variant or lang_country_variant,
00059     // depending on which fields were specified.
00060     std::string getDisplayName() const;
00061 
00062     bool hasParentLocale() const;
00063     Locale getParentLocale() const;
00064 
00065     static const Locale &getDefault();
00066     static void setDefault(const Locale &locale);
00067 
00068 //  static const vector<const Locale> getAvailableLocales();
00069 
00070 private:
00071     std::string _lang;
00072     std::string _country;
00073     std::string _variant;
00074 
00075     static Locale DEFAULT;
00076 };
00077 
00078 // make it easy to print Locales
00079 std::ostream &operator<<(std::ostream &str, const Locale &loc);
00080 
00081 FENNEL_END_NAMESPACE
00082 
00083 #endif // not Fennel_Locale_Included
00084 
00085 // End Locale.h

Generated on Mon Jun 22 04:00:18 2009 for Fennel by  doxygen 1.5.1