2010-07-24 03:13:00 +04:00
|
|
|
/*
|
2011-11-23 22:55:34 +04:00
|
|
|
* Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de.
|
2010-07-24 03:13:00 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _ICU_LOCALE_BACKEND_H
|
|
|
|
#define _ICU_LOCALE_BACKEND_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "LocaleBackend.h"
|
|
|
|
|
|
|
|
#include <locale.h>
|
2011-11-22 20:17:18 +04:00
|
|
|
#include <pthread.h>
|
2010-07-24 03:13:00 +04:00
|
|
|
#include <timelocal.h>
|
|
|
|
|
|
|
|
#include "ICUCollateData.h"
|
|
|
|
#include "ICUCtypeData.h"
|
|
|
|
#include "ICUMessagesData.h"
|
|
|
|
#include "ICUMonetaryData.h"
|
|
|
|
#include "ICUNumericData.h"
|
2010-08-17 01:14:23 +04:00
|
|
|
#include "ICUTimeConversion.h"
|
2010-07-24 03:13:00 +04:00
|
|
|
#include "ICUTimeData.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
2010-11-22 16:06:36 +03:00
|
|
|
namespace Libroot {
|
2010-07-24 03:13:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
class ICULocaleBackend : public LocaleBackend {
|
|
|
|
public:
|
|
|
|
ICULocaleBackend();
|
|
|
|
virtual ~ICULocaleBackend();
|
|
|
|
|
|
|
|
virtual void Initialize(LocaleDataBridge* dataBridge);
|
|
|
|
|
|
|
|
virtual const char* SetLocale(int category,
|
|
|
|
const char* posixLocaleName);
|
|
|
|
virtual const struct lconv* LocaleConv();
|
|
|
|
virtual const struct lc_time_t* LCTimeInfo();
|
|
|
|
|
|
|
|
virtual int IsWCType(wint_t wc, wctype_t charClass);
|
|
|
|
virtual status_t ToWCTrans(wint_t wc, wctrans_t transition,
|
|
|
|
wint_t& result);
|
|
|
|
|
2011-11-22 21:17:58 +04:00
|
|
|
virtual status_t MultibyteToWchar(wchar_t* wcOut, const char* mb,
|
|
|
|
size_t mbLength, mbstate_t* mbState,
|
|
|
|
size_t& lengthOut);
|
2011-12-07 21:20:34 +04:00
|
|
|
virtual status_t MultibyteStringToWchar(wchar_t* wcDest,
|
|
|
|
size_t wcDestLength, const char** mbSource,
|
|
|
|
size_t mbSourceLength, mbstate_t* mbState,
|
|
|
|
size_t& lengthOut);
|
2011-11-22 21:17:58 +04:00
|
|
|
virtual status_t WcharToMultibyte(char* mbOut, wchar_t wc,
|
|
|
|
mbstate_t* mbState, size_t& lengthOut);
|
2011-12-12 15:18:16 +04:00
|
|
|
virtual status_t WcharStringToMultibyte(char* mbDest,
|
|
|
|
size_t mbDestLength,
|
|
|
|
const wchar_t** wcSource,
|
|
|
|
size_t wcSourceLength, mbstate_t* mbState,
|
|
|
|
size_t& lengthOut);
|
2011-11-22 21:17:58 +04:00
|
|
|
|
2010-07-24 03:13:00 +04:00
|
|
|
virtual const char* GetLanginfo(int index);
|
|
|
|
|
|
|
|
virtual status_t Strcoll(const char* a, const char* b, int& out);
|
|
|
|
virtual status_t Strxfrm(char* out, const char* in, size_t size,
|
|
|
|
size_t& outSize);
|
2012-01-08 00:47:31 +04:00
|
|
|
virtual status_t Wcscoll(const wchar_t* a, const wchar_t* b,
|
|
|
|
int& out);
|
|
|
|
virtual status_t Wcsxfrm(wchar_t* out, const wchar_t* in,
|
|
|
|
size_t size, size_t& outSize);
|
2010-07-24 03:13:00 +04:00
|
|
|
|
2010-11-13 04:13:38 +03:00
|
|
|
virtual status_t TZSet(const char* timeZoneID, const char* tz);
|
2010-08-17 01:14:23 +04:00
|
|
|
virtual status_t Localtime(const time_t* inTime,
|
|
|
|
struct tm* tmOut);
|
|
|
|
virtual status_t Gmtime(const time_t* inTime, struct tm* tmOut);
|
|
|
|
|
|
|
|
virtual status_t Mktime(struct tm* inOutTm, time_t& timeOut);
|
|
|
|
|
2021-02-21 14:10:47 +03:00
|
|
|
virtual status_t Timegm(struct tm* inOutTm, time_t& timeOut);
|
|
|
|
|
2010-07-24 03:13:00 +04:00
|
|
|
private:
|
|
|
|
const char* _QueryLocale(int category);
|
|
|
|
const char* _SetPosixLocale(int category);
|
|
|
|
|
2011-11-22 20:17:18 +04:00
|
|
|
static pthread_key_t _CreateThreadLocalStorageKey();
|
|
|
|
static void _DestroyThreadLocalStorageValue(void* value);
|
|
|
|
|
2010-07-24 03:13:00 +04:00
|
|
|
// buffer for locale names (up to one per category)
|
2018-05-20 03:44:51 +03:00
|
|
|
char fLocaleDescription[1024];
|
2010-07-24 03:13:00 +04:00
|
|
|
|
|
|
|
// data containers
|
|
|
|
struct lconv fLocaleConv;
|
|
|
|
struct lc_time_t fLCTimeInfo;
|
|
|
|
|
2011-11-22 20:17:18 +04:00
|
|
|
//
|
|
|
|
pthread_key_t fThreadLocalStorageKey;
|
|
|
|
|
2010-07-24 03:13:00 +04:00
|
|
|
// these work on the data containers above
|
|
|
|
ICUCollateData fCollateData;
|
|
|
|
ICUCtypeData fCtypeData;
|
|
|
|
ICUMessagesData fMessagesData;
|
|
|
|
ICUMonetaryData fMonetaryData;
|
|
|
|
ICUNumericData fNumericData;
|
|
|
|
ICUTimeData fTimeData;
|
2010-08-17 01:14:23 +04:00
|
|
|
ICUTimeConversion fTimeConversion;
|
2010-07-24 03:13:00 +04:00
|
|
|
|
|
|
|
// static posix langinfo data
|
|
|
|
const char** fPosixLanginfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-22 16:06:36 +03:00
|
|
|
} // namespace Libroot
|
2010-07-24 03:13:00 +04:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _ICU_LOCALE_BACKEND_H
|