2 * Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef _ICU_LOCALE_BACKEND_H
6 #define _ICU_LOCALE_BACKEND_H
9 #include "LocaleBackend.h"
13 #include <timelocal.h>
15 #include "ICUCollateData.h"
16 #include "ICUCtypeData.h"
17 #include "ICUMessagesData.h"
18 #include "ICUMonetaryData.h"
19 #include "ICUNumericData.h"
20 #include "ICUTimeConversion.h"
21 #include "ICUTimeData.h"
28 class ICULocaleBackend
: public LocaleBackend
{
31 virtual ~ICULocaleBackend();
33 virtual void Initialize(LocaleDataBridge
* dataBridge
);
35 virtual const char* SetLocale(int category
,
36 const char* posixLocaleName
);
37 virtual const struct lconv
* LocaleConv();
38 virtual const struct lc_time_t
* LCTimeInfo();
40 virtual int IsWCType(wint_t wc
, wctype_t charClass
);
41 virtual status_t
ToWCTrans(wint_t wc
, wctrans_t transition
,
44 virtual status_t
MultibyteToWchar(wchar_t* wcOut
, const char* mb
,
45 size_t mbLength
, mbstate_t* mbState
,
47 virtual status_t
MultibyteStringToWchar(wchar_t* wcDest
,
48 size_t wcDestLength
, const char** mbSource
,
49 size_t mbSourceLength
, mbstate_t* mbState
,
51 virtual status_t
WcharToMultibyte(char* mbOut
, wchar_t wc
,
52 mbstate_t* mbState
, size_t& lengthOut
);
53 virtual status_t
WcharStringToMultibyte(char* mbDest
,
55 const wchar_t** wcSource
,
56 size_t wcSourceLength
, mbstate_t* mbState
,
59 virtual const char* GetLanginfo(int index
);
61 virtual status_t
Strcoll(const char* a
, const char* b
, int& out
);
62 virtual status_t
Strxfrm(char* out
, const char* in
, size_t size
,
64 virtual status_t
Wcscoll(const wchar_t* a
, const wchar_t* b
,
66 virtual status_t
Wcsxfrm(wchar_t* out
, const wchar_t* in
,
67 size_t size
, size_t& outSize
);
69 virtual status_t
TZSet(const char* timeZoneID
, const char* tz
);
70 virtual status_t
Localtime(const time_t* inTime
,
72 virtual status_t
Gmtime(const time_t* inTime
, struct tm
* tmOut
);
74 virtual status_t
Mktime(struct tm
* inOutTm
, time_t& timeOut
);
77 const char* _QueryLocale(int category
);
78 const char* _SetPosixLocale(int category
);
80 static pthread_key_t
_CreateThreadLocalStorageKey();
81 static void _DestroyThreadLocalStorageValue(void* value
);
83 // buffer for locale names (up to one per category)
84 char fLocaleDescription
[512];
87 struct lconv fLocaleConv
;
88 struct lc_time_t fLCTimeInfo
;
91 pthread_key_t fThreadLocalStorageKey
;
93 // these work on the data containers above
94 ICUCollateData fCollateData
;
95 ICUCtypeData fCtypeData
;
96 ICUMessagesData fMessagesData
;
97 ICUMonetaryData fMonetaryData
;
98 ICUNumericData fNumericData
;
99 ICUTimeData fTimeData
;
100 ICUTimeConversion fTimeConversion
;
102 // static posix langinfo data
103 const char** fPosixLanginfo
;
107 } // namespace Libroot
108 } // namespace BPrivate
111 #endif // _ICU_LOCALE_BACKEND_H