1 /****************************************************************************
2 ** $Id: qt/qlocale.h   3.3.8   edited Jan 11 14:38 $
3 **
4 ** Declaration of the QLocale class
5 **
6 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
7 **
8 ** This file is part of the tools module of the Qt GUI Toolkit.
9 **
10 ** This file may be distributed under the terms of the Q Public License
11 ** as defined by Trolltech ASA of Norway and appearing in the file
12 ** LICENSE.QPL included in the packaging of this file.
13 **
14 ** This file may be distributed and/or modified under the terms of the
15 ** GNU General Public License version 2 as published by the Free Software
16 ** Foundation and appearing in the file LICENSE.GPL included in the
17 ** packaging of this file.
18 **
19 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20 ** licenses may use this file in accordance with the Qt Commercial License
21 ** Agreement provided with the Software.
22 **
23 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 **
26 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27 **   information about Qt Commercial License Agreements.
28 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
29 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
30 **
31 ** Contact info@trolltech.com if any conditions of this licensing are
32 ** not clear to you.
33 **
34 **********************************************************************/
35 
36 #ifndef QLOCALE_H
37 #define QLOCALE_H
38 
39 #include "qstring.h"
40 
41 struct QLocalePrivate;
42 
43 class Q_EXPORT QLocale
44 {
45     friend class QString;
46 
47 public:
48     enum Language {
49         C = 1,
50         Abkhazian = 2,
51         Afan = 3,
52         Afar = 4,
53         Afrikaans = 5,
54         Albanian = 6,
55         Amharic = 7,
56         Arabic = 8,
57         Armenian = 9,
58         Assamese = 10,
59         Aymara = 11,
60         Azerbaijani = 12,
61         Bashkir = 13,
62         Basque = 14,
63         Bengali = 15,
64         Bhutani = 16,
65         Bihari = 17,
66         Bislama = 18,
67         Breton = 19,
68         Bulgarian = 20,
69         Burmese = 21,
70         Byelorussian = 22,
71         Cambodian = 23,
72         Catalan = 24,
73         Chinese = 25,
74         Corsican = 26,
75         Croatian = 27,
76         Czech = 28,
77         Danish = 29,
78         Dutch = 30,
79         English = 31,
80         Esperanto = 32,
81         Estonian = 33,
82         Faroese = 34,
83         FijiLanguage = 35,
84         Finnish = 36,
85         French = 37,
86         Frisian = 38,
87         Gaelic = 39,
88         Galician = 40,
89         Georgian = 41,
90         German = 42,
91         Greek = 43,
92         Greenlandic = 44,
93         Guarani = 45,
94         Gujarati = 46,
95         Hausa = 47,
96         Hebrew = 48,
97         Hindi = 49,
98         Hungarian = 50,
99         Icelandic = 51,
100         Indonesian = 52,
101         Interlingua = 53,
102         Interlingue = 54,
103         Inuktitut = 55,
104         Inupiak = 56,
105         Irish = 57,
106         Italian = 58,
107         Japanese = 59,
108         Javanese = 60,
109         Kannada = 61,
110         Kashmiri = 62,
111         Kazakh = 63,
112         Kinyarwanda = 64,
113         Kirghiz = 65,
114         Korean = 66,
115         Kurdish = 67,
116         Kurundi = 68,
117         Laothian = 69,
118         Latin = 70,
119         Latvian = 71,
120         Lingala = 72,
121         Lithuanian = 73,
122         Macedonian = 74,
123         Malagasy = 75,
124         Malay = 76,
125         Malayalam = 77,
126         Maltese = 78,
127         Maori = 79,
128         Marathi = 80,
129         Moldavian = 81,
130         Mongolian = 82,
131         NauruLanguage = 83,
132         Nepali = 84,
133         Norwegian = 85,
134         Occitan = 86,
135         Oriya = 87,
136         Pashto = 88,
137         Persian = 89,
138         Polish = 90,
139         Portuguese = 91,
140         Punjabi = 92,
141         Quechua = 93,
142         RhaetoRomance = 94,
143         Romanian = 95,
144         Russian = 96,
145         Samoan = 97,
146         Sangho = 98,
147         Sanskrit = 99,
148         Serbian = 100,
149         SerboCroatian = 101,
150         Sesotho = 102,
151         Setswana = 103,
152         Shona = 104,
153         Sindhi = 105,
154         Singhalese = 106,
155         Siswati = 107,
156         Slovak = 108,
157         Slovenian = 109,
158         Somali = 110,
159         Spanish = 111,
160         Sundanese = 112,
161         Swahili = 113,
162         Swedish = 114,
163         Tagalog = 115,
164         Tajik = 116,
165         Tamil = 117,
166         Tatar = 118,
167         Telugu = 119,
168         Thai = 120,
169         Tibetan = 121,
170         Tigrinya = 122,
171         TongaLanguage = 123,
172         Tsonga = 124,
173         Turkish = 125,
174         Turkmen = 126,
175         Twi = 127,
176         Uigur = 128,
177         Ukrainian = 129,
178         Urdu = 130,
179         Uzbek = 131,
180         Vietnamese = 132,
181         Volapuk = 133,
182         Welsh = 134,
183         Wolof = 135,
184         Xhosa = 136,
185         Yiddish = 137,
186         Yoruba = 138,
187         Zhuang = 139,
188         Zulu = 140,
189         LastLanguage = Zulu
190     };
191 
192     enum Country {
193         AnyCountry = 0,
194         Afghanistan = 1,
195         Albania = 2,
196         Algeria = 3,
197         AmericanSamoa = 4,
198         Andorra = 5,
199         Angola = 6,
200         Anguilla = 7,
201         Antarctica = 8,
202         AntiguaAndBarbuda = 9,
203         Argentina = 10,
204         Armenia = 11,
205         Aruba = 12,
206         Australia = 13,
207         Austria = 14,
208         Azerbaijan = 15,
209         Bahamas = 16,
210         Bahrain = 17,
211         Bangladesh = 18,
212         Barbados = 19,
213         Belarus = 20,
214         Belgium = 21,
215         Belize = 22,
216         Benin = 23,
217         Bermuda = 24,
218         Bhutan = 25,
219         Bolivia = 26,
220         BosniaAndHerzegowina = 27,
221         Botswana = 28,
222         BouvetIsland = 29,
223         Brazil = 30,
224         BritishIndianOceanTerritory = 31,
225         BruneiDarussalam = 32,
226         Bulgaria = 33,
227         BurkinaFaso = 34,
228         Burundi = 35,
229         Cambodia = 36,
230         Cameroon = 37,
231         Canada = 38,
232         CapeVerde = 39,
233         CaymanIslands = 40,
234         CentralAfricanRepublic = 41,
235         Chad = 42,
236         Chile = 43,
237         China = 44,
238         ChristmasIsland = 45,
239         CocosIslands = 46,
240         Colombia = 47,
241         Comoros = 48,
242         DemocraticRepublicOfCongo = 49,
243         PeoplesRepublicOfCongo = 50,
244         CookIslands = 51,
245         CostaRica = 52,
246         IvoryCoast = 53,
247         Croatia = 54,
248         Cuba = 55,
249         Cyprus = 56,
250         CzechRepublic = 57,
251         Denmark = 58,
252         Djibouti = 59,
253         Dominica = 60,
254         DominicanRepublic = 61,
255         EastTimor = 62,
256         Ecuador = 63,
257         Egypt = 64,
258         ElSalvador = 65,
259         EquatorialGuinea = 66,
260         Eritrea = 67,
261         Estonia = 68,
262         Ethiopia = 69,
263         FalklandIslands = 70,
264         FaroeIslands = 71,
265         FijiCountry = 72,
266         Finland = 73,
267         France = 74,
268         MetropolitanFrance = 75,
269         FrenchGuiana = 76,
270         FrenchPolynesia = 77,
271         FrenchSouthernTerritories = 78,
272         Gabon = 79,
273         Gambia = 80,
274         Georgia = 81,
275         Germany = 82,
276         Ghana = 83,
277         Gibraltar = 84,
278         Greece = 85,
279         Greenland = 86,
280         Grenada = 87,
281         Guadeloupe = 88,
282         Guam = 89,
283         Guatemala = 90,
284         Guinea = 91,
285         GuineaBissau = 92,
286         Guyana = 93,
287         Haiti = 94,
288         HeardAndMcDonaldIslands = 95,
289         Honduras = 96,
290         HongKong = 97,
291         Hungary = 98,
292         Iceland = 99,
293         India = 100,
294         Indonesia = 101,
295         Iran = 102,
296         Iraq = 103,
297         Ireland = 104,
298         Israel = 105,
299         Italy = 106,
300         Jamaica = 107,
301         Japan = 108,
302         Jordan = 109,
303         Kazakhstan = 110,
304         Kenya = 111,
305         Kiribati = 112,
306         DemocraticRepublicOfKorea = 113,
307         RepublicOfKorea = 114,
308         Kuwait = 115,
309         Kyrgyzstan = 116,
310         Lao = 117,
311         Latvia = 118,
312         Lebanon = 119,
313         Lesotho = 120,
314         Liberia = 121,
315         LibyanArabJamahiriya = 122,
316         Liechtenstein = 123,
317         Lithuania = 124,
318         Luxembourg = 125,
319         Macau = 126,
320         Macedonia = 127,
321         Madagascar = 128,
322         Malawi = 129,
323         Malaysia = 130,
324         Maldives = 131,
325         Mali = 132,
326         Malta = 133,
327         MarshallIslands = 134,
328         Martinique = 135,
329         Mauritania = 136,
330         Mauritius = 137,
331         Mayotte = 138,
332         Mexico = 139,
333         Micronesia = 140,
334         Moldova = 141,
335         Monaco = 142,
336         Mongolia = 143,
337         Montserrat = 144,
338         Morocco = 145,
339         Mozambique = 146,
340         Myanmar = 147,
341         Namibia = 148,
342         NauruCountry = 149,
343         Nepal = 150,
344         Netherlands = 151,
345         NetherlandsAntilles = 152,
346         NewCaledonia = 153,
347         NewZealand = 154,
348         Nicaragua = 155,
349         Niger = 156,
350         Nigeria = 157,
351         Niue = 158,
352         NorfolkIsland = 159,
353         NorthernMarianaIslands = 160,
354         Norway = 161,
355         Oman = 162,
356         Pakistan = 163,
357         Palau = 164,
358         PalestinianTerritory = 165,
359         Panama = 166,
360         PapuaNewGuinea = 167,
361         Paraguay = 168,
362         Peru = 169,
363         Philippines = 170,
364         Pitcairn = 171,
365         Poland = 172,
366         Portugal = 173,
367         PuertoRico = 174,
368         Qatar = 175,
369         Reunion = 176,
370         Romania = 177,
371         RussianFederation = 178,
372         Rwanda = 179,
373         SaintKittsAndNevis = 180,
374         StLucia = 181,
375         StVincentAndTheGrenadines = 182,
376         Samoa = 183,
377         SanMarino = 184,
378         SaoTomeAndPrincipe = 185,
379         SaudiArabia = 186,
380         Senegal = 187,
381         Seychelles = 188,
382         SierraLeone = 189,
383         Singapore = 190,
384         Slovakia = 191,
385         Slovenia = 192,
386         SolomonIslands = 193,
387         Somalia = 194,
388         SouthAfrica = 195,
389         SouthGeorgiaAndTheSouthSandwichIslands = 196,
390         Spain = 197,
391         SriLanka = 198,
392         StHelena = 199,
393         StPierreAndMiquelon = 200,
394         Sudan = 201,
395         Suriname = 202,
396         SvalbardAndJanMayenIslands = 203,
397         Swaziland = 204,
398         Sweden = 205,
399         Switzerland = 206,
400         SyrianArabRepublic = 207,
401         Taiwan = 208,
402         Tajikistan = 209,
403         Tanzania = 210,
404         Thailand = 211,
405         Togo = 212,
406         Tokelau = 213,
407         TongaCountry = 214,
408         TrinidadAndTobago = 215,
409         Tunisia = 216,
410         Turkey = 217,
411         Turkmenistan = 218,
412         TurksAndCaicosIslands = 219,
413         Tuvalu = 220,
414         Uganda = 221,
415         Ukraine = 222,
416         UnitedArabEmirates = 223,
417         UnitedKingdom = 224,
418         UnitedStates = 225,
419         UnitedStatesMinorOutlyingIslands = 226,
420         Uruguay = 227,
421         Uzbekistan = 228,
422         Vanuatu = 229,
423         VaticanCityState = 230,
424         Venezuela = 231,
425         VietNam = 232,
426         BritishVirginIslands = 233,
427         USVirginIslands = 234,
428         WallisAndFutunaIslands = 235,
429         WesternSahara = 236,
430         Yemen = 237,
431         Yugoslavia = 238,
432         Zambia = 239,
433         Zimbabwe = 240,
434         LastCountry = Zimbabwe
435     };
436 
437     QLocale();
438     QLocale(const QString &name);
439     QLocale(Language language, Country country = AnyCountry);
440     QLocale(const QLocale &other);
441 
442     QLocale &operator=(const QLocale &other);
443 
444     Language language() const;
445     Country country() const;
446     QString name() const;
447 
448     short toShort(const QString &s, bool *ok = 0) const;
449     ushort toUShort(const QString &s, bool *ok = 0) const;
450     int toInt(const QString &s, bool *ok = 0) const;
451     uint toUInt(const QString &s, bool *ok = 0) const;
452     Q_LONG toLong(const QString &s, bool *ok = 0) const;
453     Q_ULONG toULong(const QString &s, bool *ok = 0) const;
454     Q_LLONG toLongLong(const QString &s, bool *ok = 0) const;
455     Q_ULLONG toULongLong(const QString &s, bool *ok = 0) const;
456     float toFloat(const QString &s, bool *ok = 0) const;
457     double toDouble(const QString &s, bool *ok = 0) const;
458 
toString(short i)459     QString toString(short i) const
460     { return toString((Q_LLONG)i); }
toString(ushort i)461     QString toString(ushort i) const
462     { return toString((Q_ULLONG)i); }
toString(int i)463     QString toString(int i) const
464     { return toString((Q_LLONG)i); }
toString(uint i)465     QString toString(uint i) const
466     { return toString((Q_ULLONG)i); }
467 #if !defined(Q_OS_WIN64)
toString(Q_LONG i)468     QString toString(Q_LONG i) const
469     { return toString((Q_LLONG)i); }
toString(Q_ULONG i)470     QString toString(Q_ULONG i) const
471     { return toString((Q_ULLONG)i); }
472 #endif
473     QString toString(Q_LLONG i) const;
474     QString toString(Q_ULLONG i) const;
475     QString toString(float i, char f = 'g', int prec = 6) const
476     { return toString((double) i, f, prec); }
477     QString toString(double i, char f = 'g', int prec = 6) const;
478 
479     static QString languageToString(Language language);
480     static QString countryToString(Country country);
481     static void setDefault(const QLocale &locale);
482 
c()483     static QLocale c() { return QLocale(C); }
484     static QLocale system();
485 
486 private:
487     const QLocalePrivate *d;
488     static const QLocalePrivate *default_d;
489 };
490 
491 #endif
492