haiku/headers/private/libroot/locale/LocaleBackend.h
Oliver Tappe 560b10ff88 Implement tzset(), gmtime(), localtime() and mktime() on top of ICU
* no longer keep a separate time-backend, since the implementation needs to
  access (data of) the locale backend anyway
* moved more stuff from localtime_fading_out.c to localtime.cpp
* added respective tests to locale_test
* added two more tests copied from glibc, test_time.c and tst-mktime.c


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38162 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-16 21:14:23 +00:00

130 lines
2.8 KiB
C++

/*
* Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _LOCALE_BACKEND_H
#define _LOCALE_BACKEND_H
#include <SupportDefs.h>
#include <time.h>
#include <wctype.h>
struct lconv;
struct lc_time_t;
namespace BPrivate {
struct LocaleCtypeDataBridge {
const unsigned short** addrOfClassInfoTable;
const int** addrOfToLowerTable;
const int** addrOfToUpperTable;
const unsigned short* posixClassInfo;
const int* posixToLowerMap;
const int* posixToUpperMap;
LocaleCtypeDataBridge();
};
struct LocaleMessagesDataBridge {
const char** posixLanginfo;
LocaleMessagesDataBridge();
};
struct LocaleMonetaryDataBridge {
const struct lconv* posixLocaleConv;
LocaleMonetaryDataBridge();
};
struct LocaleNumericDataBridge {
const char** addrOfGlibcDecimalPoint;
const char** addrOfGlibcThousandsSep;
const char** addrOfGlibcGrouping;
uint32_t* addrOfGlibcWCDecimalPoint;
uint32_t* addrOfGlibcWCThousandsSep;
const struct lconv* posixLocaleConv;
LocaleNumericDataBridge();
};
struct LocaleTimeDataBridge {
const struct lc_time_t* posixLCTimeInfo;
LocaleTimeDataBridge();
};
struct TimeConversionDataBridge {
int* addrOfDaylight;
long* addrOfTimezone;
char** addrOfTZName;
TimeConversionDataBridge();
};
struct LocaleDataBridge {
LocaleCtypeDataBridge ctypeDataBridge;
LocaleMessagesDataBridge messagesDataBridge;
LocaleMonetaryDataBridge monetaryDataBridge;
LocaleNumericDataBridge numericDataBridge;
LocaleTimeDataBridge timeDataBridge;
TimeConversionDataBridge timeConversionDataBridge;
const char** posixLanginfo;
LocaleDataBridge();
};
class LocaleBackend {
public:
LocaleBackend();
virtual ~LocaleBackend();
virtual const char* SetLocale(int category, const char* locale) = 0;
virtual const struct lconv* LocaleConv() = 0;
virtual const struct lc_time_t* LCTimeInfo() = 0;
virtual int IsWCType(wint_t wc, wctype_t charClass) = 0;
virtual status_t ToWCTrans(wint_t wc, wctrans_t transition,
wint_t& result) = 0;
virtual const char* GetLanginfo(int index) = 0;
virtual status_t Strcoll(const char* a, const char* b,
int& out) = 0;
virtual status_t Strxfrm(char* out, const char* in, size_t size,
size_t& outSize) = 0;
virtual status_t TZSet(const char* timeZoneID) = 0;
virtual status_t Localtime(const time_t* inTime,
struct tm* tmOut) = 0;
virtual status_t Gmtime(const time_t* inTime,
struct tm* tmOut) = 0;
virtual status_t Mktime(struct tm* inOutTm, time_t& timeOut) = 0;
virtual void Initialize(LocaleDataBridge* dataBridge) = 0;
static status_t LoadBackend();
};
extern LocaleBackend* gLocaleBackend;
} // namespace BPrivate
#endif // _LOCALE_BACKEND_H