libcommonc++  0.7
Locale.h++
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------
2  commonc++ - A C++ Common Class Library
3  Copyright (C) 2005-2014 Mark A Lindner
4 
5  This file is part of commonc++.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public
18  License along with this library; if not, write to the Free
19  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  ---------------------------------------------------------------------------
21 */
22 
23 #ifndef __ccxx_Locale_hxx
24 #define __ccxx_Locale_hxx
25 
26 #include <commonc++/String.h++>
27 
28 #ifndef CCXX_OS_ANDROID
29 
30 namespace ccxx {
31 
38 {
39  public:
40 
45  Locale(String language, String country = String::null,
46  String variant = String::null);
47 
49  ~Locale();
50 
52  bool isValid() const;
53 
55  String getEncoding() const;
56 
58  String getAMAffix() const;
59 
61  String getPMAffix() const;
62 
68  String getWeekDayName(int day) const;
69 
75  String getAbbreviatedWeekDayName(int day) const;
76 
82  String getMonthName(int month) const;
83 
89  String getAbbreviatedMonthName(int month) const;
90 
92  String getRadixCharacter() const;
93 
95  String getThousandsSeparator() const;
96 
98  String getCurrencySymbol() const;
99 
101  inline String getLanguage() const
102  { return(_language); }
103 
105  inline String getCountry() const
106  { return(_country); }
107 
109  inline String getVariant() const
110  { return(_variant); }
111 
113  inline String toString() const
114  { return(_id); }
115 
117  static String getCurrentEncoding();
118 
120  static const Locale getCurrent();
121 
123  static bool setCurrent(const Locale& locale);
124 
126  static const Locale CANADA;
128  static const Locale CANADA_FRENCH;
130  static const Locale CHINA;
132  static const Locale CHINESE;
134  static const Locale ENGLISH;
136  static const Locale FRANCE;
138  static const Locale FRENCH;
140  static const Locale GERMANY;
142  static const Locale GERMAN;
144  static const Locale ITALY;
146  static const Locale ITALIAN;
148  static const Locale JAPAN;
150  static const Locale JAPANESE;
152  static const Locale KOREA;
154  static const Locale KOREAN;
156  static const Locale SPANISH;
162  static const Locale TAIWAN;
164  static const Locale UNITED_KINGDOM;
166  static const Locale UNITED_STATES;
167 
168  private:
169 
170 #ifdef CCXX_OS_WINDOWS
171  Locale(LCID locale);
172 #endif
173 
174  String _language;
175  String _country;
176  String _variant;
177  String _id;
178 #ifdef CCXX_OS_WINDOWS
179  LCID _locale;
180 #else
181  void *_locale;
182 #endif
183 };
184 
185 } // namespace ccxx
186 
187 #endif // CCXX_OS_ANDROID
188 
189 #endif // __ccxx_Locale_hxx
static const Locale FRENCH
The "fr" locale.
Definition: Locale.h++:138
static const Locale GERMANY
The "de_DE" locale.
Definition: Locale.h++:140
static const Locale ENGLISH
The "en" locale.
Definition: Locale.h++:134
static const Locale CANADA_FRENCH
The "fr_CA" locale.
Definition: Locale.h++:128
static const Locale TAIWAN
The "zh_TW" locale.
Definition: Locale.h++:162
A class that encapsulates locale-specific information.
Definition: Locale.h++:37
static const Locale JAPAN
The "ja" locale.
Definition: Locale.h++:148
String toString() const
Get a String representation of this locale.
Definition: Locale.h++:113
String getCountry() const
Get the country component of this locale.
Definition: Locale.h++:105
static const Locale JAPANESE
The "ja" locale.
Definition: Locale.h++:150
String getVariant() const
Get the variant component of this locale.
Definition: Locale.h++:109
static const Locale SIMPLIFIED_CHINESE
The "zh_CN" locale.
Definition: Locale.h++:158
static const Locale CHINESE
The "zh" locale.
Definition: Locale.h++:132
static const Locale KOREAN
The "ko" locale.
Definition: Locale.h++:154
static const Locale UNITED_STATES
The "en_US" locale.
Definition: Locale.h++:166
#define COMMONCPP_API
Definition: Common.h++:126
String getLanguage() const
Get the language component of this locale.
Definition: Locale.h++:101
static const Locale TRADITIONAL_CHINESE
The "zh_TW" locale.
Definition: Locale.h++:160
static const Locale FRANCE
The "fr_FR" locale.
Definition: Locale.h++:136
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
static const Locale KOREA
The "ko" locale.
Definition: Locale.h++:152
static const Locale GERMAN
The "de" locale.
Definition: Locale.h++:142
static const Locale CANADA
The "en_CA" locale.
Definition: Locale.h++:126
static const Locale UNITED_KINGDOM
The "en_GB" locale.
Definition: Locale.h++:164
static const String null
The null string.
Definition: String.h++:1128
static const Locale SPANISH
The "es" locale.
Definition: Locale.h++:156
Definition: AllocationMap.c++:25
static const Locale ITALIAN
The "it" locale.
Definition: Locale.h++:146
static const Locale ITALY
The "it_IT" locale.
Definition: Locale.h++:144
static const Locale CHINA
The "zh_CN" locale.
Definition: Locale.h++:130