* reintegrated posix-locale
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37725 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LANGINFO_H_
|
||||
#define _LANGINFO_H_
|
||||
|
||||
|
||||
#include <locale.h>
|
||||
#include <nl_types.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
|
||||
enum {
|
||||
CODESET, /* codeset name */
|
||||
D_T_FMT, /* string for formatting date and time */
|
||||
D_FMT, /* date format string */
|
||||
T_FMT, /* time format string */
|
||||
T_FMT_AMPM, /* a.m. or p.m. time formatting string */
|
||||
AM_STR, /* Ante Meridian affix */
|
||||
PM_STR, /* Post Meridian affix */
|
||||
|
||||
/* week day names */
|
||||
DAY_1,
|
||||
DAY_2,
|
||||
DAY_3,
|
||||
DAY_4,
|
||||
DAY_5,
|
||||
DAY_6,
|
||||
DAY_7,
|
||||
|
||||
/* abbreviated week day names */
|
||||
ABDAY_1,
|
||||
ABDAY_2,
|
||||
ABDAY_3,
|
||||
ABDAY_4,
|
||||
ABDAY_5,
|
||||
ABDAY_6,
|
||||
ABDAY_7,
|
||||
|
||||
/* month names */
|
||||
MON_1,
|
||||
MON_2,
|
||||
MON_3,
|
||||
MON_4,
|
||||
MON_5,
|
||||
MON_6,
|
||||
MON_7,
|
||||
MON_8,
|
||||
MON_9,
|
||||
MON_10,
|
||||
MON_11,
|
||||
MON_12,
|
||||
|
||||
/* abbreviated month names */
|
||||
ABMON_1,
|
||||
ABMON_2,
|
||||
ABMON_3,
|
||||
ABMON_4,
|
||||
ABMON_5,
|
||||
ABMON_6,
|
||||
ABMON_7,
|
||||
ABMON_8,
|
||||
ABMON_9,
|
||||
ABMON_10,
|
||||
ABMON_11,
|
||||
ABMON_12,
|
||||
|
||||
ERA, /* era description segments */
|
||||
ERA_D_FMT, /* era date format string */
|
||||
ERA_D_T_FMT, /* era date and time format string */
|
||||
ERA_T_FMT, /* era time format string */
|
||||
ALT_DIGITS, /* alternative symbols for digits */
|
||||
|
||||
RADIXCHAR, /* radix char */
|
||||
THOUSEP, /* separator for thousands */
|
||||
|
||||
YESEXPR, /* affirmative response expression */
|
||||
NOEXPR, /* negative response expression */
|
||||
|
||||
CRNCYSTR, /* currency symbol */
|
||||
|
||||
_NL_LANGINFO_LAST
|
||||
};
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern char* nl_langinfo(nl_item item);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
#endif /* _LANGINFO_H_ */
|
||||
+12
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef _LOCALE_H_
|
||||
#define _LOCALE_H_
|
||||
/*
|
||||
/*
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,12 @@ struct lconv {
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char int_p_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_n_cs_precedes;
|
||||
char int_n_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
};
|
||||
|
||||
#define LC_ALL 0
|
||||
@@ -34,6 +40,11 @@ struct lconv {
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
#define LC_MESSAGES 6
|
||||
/*
|
||||
* the values above must be kept in loopable order (i.e. strictly increasing
|
||||
* with no holes) and in sync with the value below
|
||||
*/
|
||||
#define LC_LAST LC_MESSAGES
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _MONETARY_H_
|
||||
#define _MONETARY_H_
|
||||
|
||||
|
||||
#include <locale.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern ssize_t strfmon(char* s, size_t maxsize, const char* format, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
#endif /* _MONETARY_H_ */
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NL_TYPES_H_
|
||||
#define _NL_TYPES_H_
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
|
||||
#define NL_SETD 0
|
||||
#define NL_CAT_LOCALE 1
|
||||
|
||||
typedef int nl_item;
|
||||
typedef void* nl_catd;
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern nl_catd catopen(const char *name, int oflag);
|
||||
extern char* catgets(nl_catd cat, int setID, int msgID,
|
||||
const char *defaultMessage);
|
||||
extern int catclose(nl_catd cat);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
#endif /* _NL_TYPES_H_ */
|
||||
@@ -36,6 +36,12 @@ typedef struct {
|
||||
#define WCHAR_MIN 0x00000000UL
|
||||
#define WCHAR_MAX 0x7FFFFFFFUL
|
||||
|
||||
/*
|
||||
* Haiku is always using UTF32 in wchars, other encodings can be handled
|
||||
* by converting to/from wchar by means of mbsrtowcs() or wcsrtombs().
|
||||
* TODO: define __STDC_ISO_10646__ accordingly in our compilers.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
typedef const int *wctrans_t;
|
||||
typedef int wctrans_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -28,7 +28,7 @@ extern int iswupper(wint_t wc);
|
||||
extern int iswxdigit(wint_t wc);
|
||||
|
||||
extern int iswctype(wint_t wc, wctype_t charClass);
|
||||
extern wint_t towctrans(wint_t wc, wctrans_t charClass);
|
||||
extern wint_t towctrans(wint_t wc, wctrans_t transition);
|
||||
extern wint_t towlower(wint_t wc);
|
||||
extern wint_t towupper(wint_t wc);
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_CATEGORY_DATA_H
|
||||
#define _ICU_CATEGORY_DATA_H
|
||||
|
||||
|
||||
#include <unicode/locid.h>
|
||||
#include <unicode/ucnv.h>
|
||||
#include <unicode/unistr.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class ICUCategoryData {
|
||||
public:
|
||||
ICUCategoryData();
|
||||
virtual ~ICUCategoryData();
|
||||
|
||||
virtual status_t SetTo(const Locale& locale,
|
||||
const char* posixLocaleName);
|
||||
virtual status_t SetToPosix();
|
||||
|
||||
const char * PosixLocaleName()
|
||||
{ return fPosixLocaleName; }
|
||||
|
||||
protected:
|
||||
status_t _ConvertUnicodeStringToLocaleconvEntry(
|
||||
const UnicodeString& string,
|
||||
char* destination, int destinationSize,
|
||||
const char* defaultValue = "");
|
||||
|
||||
static const uint16 skMaxPosixLocaleNameLen = 128;
|
||||
static const size_t skLCBufSize = 16;
|
||||
|
||||
Locale fLocale;
|
||||
UConverter* fConverter;
|
||||
char fPosixLocaleName[skMaxPosixLocaleNameLen];
|
||||
char fGivenCharset[UCNV_MAX_CONVERTER_NAME_LENGTH];
|
||||
|
||||
private:
|
||||
status_t _SetupConverter();
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_CATEGORY_DATA_H
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_COLLATE_DATA_H
|
||||
#define _ICU_COLLATE_DATA_H
|
||||
|
||||
|
||||
#include "ICUCategoryData.h"
|
||||
|
||||
#include <unicode/coll.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class ICUCollateData : public ICUCategoryData {
|
||||
typedef ICUCategoryData inherited;
|
||||
|
||||
public:
|
||||
ICUCollateData();
|
||||
virtual ~ICUCollateData();
|
||||
|
||||
virtual status_t SetTo(const Locale& locale,
|
||||
const char* posixLocaleName);
|
||||
virtual status_t SetToPosix();
|
||||
|
||||
status_t Strcoll(const char* a, const char* b, int& out);
|
||||
status_t Strxfrm(char* out, const char* in, size_t size,
|
||||
size_t& outSize);
|
||||
|
||||
private:
|
||||
status_t _ToUnicodeString(const char* in,
|
||||
UnicodeString& out);
|
||||
|
||||
Collator* fCollator;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_COLLATE_DATA_H
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_CTYPE_DATA_H
|
||||
#define _ICU_CTYPE_DATA_H
|
||||
|
||||
|
||||
#include "ICUCategoryData.h"
|
||||
#include "LocaleBackend.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class ICUCtypeData : public ICUCategoryData {
|
||||
typedef ICUCategoryData inherited;
|
||||
public:
|
||||
ICUCtypeData();
|
||||
virtual ~ICUCtypeData();
|
||||
|
||||
void Initialize(LocaleCtypeDataBridge* dataBridge);
|
||||
|
||||
virtual status_t SetTo(const Locale& locale,
|
||||
const char* posixLocaleName);
|
||||
virtual status_t SetToPosix();
|
||||
|
||||
int IsWCType(wint_t wc, wctype_t charClass);
|
||||
status_t ToWCTrans(wint_t wc, wctrans_t transition,
|
||||
wint_t& result);
|
||||
|
||||
const char* GetLanginfo(int index);
|
||||
|
||||
private:
|
||||
unsigned short fClassInfo[256];
|
||||
int fToLowerMap[256];
|
||||
int fToUpperMap[256];
|
||||
|
||||
LocaleCtypeDataBridge* fDataBridge;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_CTYPE_DATA_H
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_LOCALE_BACKEND_H
|
||||
#define _ICU_LOCALE_BACKEND_H
|
||||
|
||||
|
||||
#include "LocaleBackend.h"
|
||||
|
||||
#include <locale.h>
|
||||
#include <timelocal.h>
|
||||
|
||||
#include "ICUCollateData.h"
|
||||
#include "ICUCtypeData.h"
|
||||
#include "ICUMessagesData.h"
|
||||
#include "ICUMonetaryData.h"
|
||||
#include "ICUNumericData.h"
|
||||
#include "ICUTimeData.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
const char* _QueryLocale(int category);
|
||||
const char* _SetPosixLocale(int category);
|
||||
|
||||
// buffer for locale names (up to one per category)
|
||||
char fLocaleDescription[512];
|
||||
|
||||
// data containers
|
||||
struct lconv fLocaleConv;
|
||||
struct lc_time_t fLCTimeInfo;
|
||||
|
||||
// these work on the data containers above
|
||||
ICUCollateData fCollateData;
|
||||
ICUCtypeData fCtypeData;
|
||||
ICUMessagesData fMessagesData;
|
||||
ICUMonetaryData fMonetaryData;
|
||||
ICUNumericData fNumericData;
|
||||
ICUTimeData fTimeData;
|
||||
|
||||
// static posix langinfo data
|
||||
const char** fPosixLanginfo;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_LOCALE_BACKEND_H
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_LOCALECONV_DATA_H
|
||||
#define _ICU_LOCALECONV_DATA_H
|
||||
|
||||
|
||||
#include "ICUCategoryData.h"
|
||||
|
||||
#include <unicode/decimfmt.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
typedef DecimalFormatSymbols::ENumberFormatSymbol FormatSymbol;
|
||||
|
||||
class ICULocaleconvData : public ICUCategoryData {
|
||||
typedef ICUCategoryData inherited;
|
||||
|
||||
protected:
|
||||
status_t _SetLocaleconvEntry(
|
||||
const DecimalFormatSymbols* formatSymbols,
|
||||
char* destination, FormatSymbol symbol,
|
||||
const char* defaultValue = "");
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_LOCALECONV_DATA_H
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_MESSAGES_DATA_H
|
||||
#define _ICU_MESSAGES_DATA_H
|
||||
|
||||
|
||||
#include "ICUCategoryData.h"
|
||||
#include "LocaleBackend.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class ICUMessagesData : public ICUCategoryData {
|
||||
typedef ICUCategoryData inherited;
|
||||
public:
|
||||
virtual status_t SetTo(const Locale& locale,
|
||||
const char* posixLocaleName);
|
||||
virtual status_t SetToPosix();
|
||||
|
||||
void Initialize(
|
||||
LocaleMessagesDataBridge* dataBridge);
|
||||
|
||||
const char* GetLanginfo(int index);
|
||||
|
||||
private:
|
||||
char fYesExpression[80];
|
||||
char fNoExpression[80];
|
||||
|
||||
const char** fPosixLanginfo;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_MESSAGES_DATA_H
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_MONETARY_DATA_H
|
||||
#define _ICU_MONETARY_DATA_H
|
||||
|
||||
|
||||
#include "ICULocaleconvData.h"
|
||||
#include "LocaleBackend.h"
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class ICUMonetaryData : public ICULocaleconvData {
|
||||
typedef ICULocaleconvData inherited;
|
||||
public:
|
||||
static const int32 kParenthesesAroundCurrencyAndValue = 0;
|
||||
static const int32 kSignPrecedesCurrencyAndValue = 1;
|
||||
static const int32 kSignSucceedsCurrencyAndValue = 2;
|
||||
static const int32 kSignImmediatelyPrecedesCurrency = 3;
|
||||
static const int32 kSignImmediatelySucceedsCurrency = 4;
|
||||
|
||||
ICUMonetaryData(struct lconv& localeConv);
|
||||
|
||||
void Initialize(
|
||||
LocaleMonetaryDataBridge* dataBridge);
|
||||
|
||||
virtual status_t SetTo(const Locale& locale,
|
||||
const char* posixLocaleName);
|
||||
virtual status_t SetToPosix();
|
||||
|
||||
const char* GetLanginfo(int index);
|
||||
|
||||
private:
|
||||
static const int32 kCsPrecedesFlag = 1 << 0;
|
||||
static const int32 kSepBySpaceFlag = 1 << 1;
|
||||
|
||||
int32 _DetermineCurrencyPosAndSeparator(
|
||||
const UnicodeString& prefix,
|
||||
const UnicodeString& suffix,
|
||||
const UnicodeString& signSymbol,
|
||||
const UnicodeString& currencySymbol,
|
||||
UChar& currencySeparatorChar);
|
||||
int32 _DetermineSignPos(const UnicodeString& prefix,
|
||||
const UnicodeString& suffix,
|
||||
const UnicodeString& signSymbol,
|
||||
const UnicodeString& currencySymbol);
|
||||
|
||||
char fDecimalPoint[skLCBufSize];
|
||||
char fThousandsSep[skLCBufSize];
|
||||
char fGrouping[skLCBufSize];
|
||||
char fIntCurrSymbol[skLCBufSize];
|
||||
char fCurrencySymbol[skLCBufSize];
|
||||
char fPositiveSign[skLCBufSize];
|
||||
char fNegativeSign[skLCBufSize];
|
||||
|
||||
struct lconv& fLocaleConv;
|
||||
const struct lconv* fPosixLocaleConv;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_MONETARY_DATA_H
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_NUMERIC_DATA_H
|
||||
#define _ICU_NUMERIC_DATA_H
|
||||
|
||||
|
||||
#include "ICULocaleconvData.h"
|
||||
#include "LocaleBackend.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class ICUNumericData : public ICULocaleconvData {
|
||||
typedef ICULocaleconvData inherited;
|
||||
|
||||
public:
|
||||
ICUNumericData(struct lconv& localeConv);
|
||||
|
||||
void Initialize(LocaleNumericDataBridge* dataBridge);
|
||||
|
||||
virtual status_t SetTo(const Locale& locale,
|
||||
const char* posixLocaleName);
|
||||
virtual status_t SetToPosix();
|
||||
|
||||
virtual const char* GetLanginfo(int index);
|
||||
|
||||
private:
|
||||
char fDecimalPoint[skLCBufSize];
|
||||
char fThousandsSep[skLCBufSize];
|
||||
char fGrouping[skLCBufSize];
|
||||
|
||||
struct lconv& fLocaleConv;
|
||||
LocaleNumericDataBridge* fDataBridge;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_NUMERIC_DATA_H
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ICU_TIME_DATA_H
|
||||
#define _ICU_TIME_DATA_H
|
||||
|
||||
|
||||
#include "ICUCategoryData.h"
|
||||
#include "LocaleBackend.h"
|
||||
|
||||
#include <unicode/datefmt.h>
|
||||
|
||||
#include <timelocal.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class ICUTimeData : public ICUCategoryData {
|
||||
typedef ICUCategoryData inherited;
|
||||
public:
|
||||
ICUTimeData(struct lc_time_t& lcTimeInfo);
|
||||
|
||||
void Initialize(LocaleTimeDataBridge* dataBridge);
|
||||
|
||||
virtual status_t SetTo(const Locale& locale,
|
||||
const char* posixLocaleName);
|
||||
virtual status_t SetToPosix();
|
||||
|
||||
const char* GetLanginfo(int index);
|
||||
|
||||
private:
|
||||
status_t _SetLCTimeEntries(const UnicodeString* strings,
|
||||
char* destination, int entrySize,
|
||||
int count, int maxCount);
|
||||
status_t _SetLCTimePattern(DateFormat* format,
|
||||
char* destination, int destinationSize);
|
||||
|
||||
char fMon[12][24];
|
||||
char fMonth[12][64];
|
||||
char fWday[7][24];
|
||||
char fWeekday[7][64];
|
||||
char fTimeFormat[24];
|
||||
char fDateFormat[24];
|
||||
char fDateTimeFormat[32];
|
||||
char fAm[24];
|
||||
char fPm[24];
|
||||
char fDateTimeZoneFormat[32];
|
||||
char fAltMonth[12][64];
|
||||
char fMonthDayOrder[4];
|
||||
char fAmPmFormat[32];
|
||||
|
||||
struct lc_time_t& fLCTimeInfo;
|
||||
const struct lc_time_t* fPosixLCTimeInfo;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _ICU_TIME_DATA_H
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LOCALE_BACKEND_H
|
||||
#define _LOCALE_BACKEND_H
|
||||
|
||||
|
||||
#include <SupportDefs.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 LocaleDataBridge {
|
||||
LocaleCtypeDataBridge ctypeDataBridge;
|
||||
LocaleMessagesDataBridge messagesDataBridge;
|
||||
LocaleMonetaryDataBridge monetaryDataBridge;
|
||||
LocaleNumericDataBridge numericDataBridge;
|
||||
LocaleTimeDataBridge timeDataBridge;
|
||||
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 void Initialize(LocaleDataBridge* dataBridge) = 0;
|
||||
|
||||
static status_t LoadBackend();
|
||||
};
|
||||
|
||||
|
||||
extern LocaleBackend* gLocaleBackend;
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _LOCALE_BACKEND_H
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _POSIX_CTYPE_H
|
||||
#define _POSIX_CTYPE_H
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
extern const unsigned short gPosixClassInfo[256];
|
||||
extern const int gPosixToLowerMap[256];
|
||||
extern const int gPosixToUpperMap[256];
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _POSIX_CTYPE_H
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _POSIX_LANGINFO_H
|
||||
#define _POSIX_LANGINFO_H
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
extern const char* gPosixLanginfo[];
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _POSIX_LANGINFO_H
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _POSIX_LOCALE_CONV_H
|
||||
#define _POSIX_LOCALE_CONV_H
|
||||
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
extern struct lconv gPosixLocaleConv;
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _POSIX_LOCALE_CONV_H
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _POSIX_LC_TIME_INFO_H
|
||||
#define _POSIX_LC_TIME_INFO_H
|
||||
|
||||
|
||||
#include <timelocal.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
extern const struct lc_time_t gPosixLCTimeInfo;
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _POSIX_LC_TIME_INFO_H
|
||||
@@ -0,0 +1,60 @@
|
||||
/*-
|
||||
* Copyright (c) 1997-2002 FreeBSD Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: /repoman/r/ncvs/src/lib/libc/stdtime/timelocal.h,v 1.11 2002/01/24 15:07:44 phantom Exp $
|
||||
*/
|
||||
#ifndef _TIMELOCAL_H_
|
||||
#define _TIMELOCAL_H_
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
|
||||
/*
|
||||
* Private header file for the strftime and strptime localization
|
||||
* stuff.
|
||||
*/
|
||||
struct lc_time_t {
|
||||
const char* mon[12];
|
||||
const char* month[12];
|
||||
const char* wday[7];
|
||||
const char* weekday[7];
|
||||
const char* X_fmt;
|
||||
const char* x_fmt;
|
||||
const char* c_fmt;
|
||||
const char* am;
|
||||
const char* pm;
|
||||
const char* date_fmt;
|
||||
const char* alt_month[12];
|
||||
const char* md_order;
|
||||
const char* ampm_fmt;
|
||||
};
|
||||
|
||||
__BEGIN_DECLS
|
||||
const struct lc_time_t* __get_current_time_locale(void);
|
||||
__END_DECLS
|
||||
|
||||
|
||||
#endif /* !_TIMELOCAL_H_ */
|
||||
@@ -1,84 +0,0 @@
|
||||
#ifndef _LANGINFO_H_
|
||||
#define _LANGINFO_H_
|
||||
|
||||
#include <LocaleStrings.h>
|
||||
#include <nl_types.h>
|
||||
|
||||
#define CODESET B_CODESET /* codeset name */
|
||||
#define D_T_FMT B_DATE_TIME_FORMAT /* string for formatting date and time */
|
||||
#define D_FMT B_DATE_FORMAT /* date format string */
|
||||
#define T_FMT B_TIME_FORMAT /* time format string */
|
||||
#define T_FMT_AMPM B_AM_PM_TIME_FORMAT /* a.m. or p.m. time formatting string */
|
||||
#define AM_STR B_AM_STRING /* Ante Meridian affix */
|
||||
#define PM_STR B_PM_STRING /* Post Meridian affix */
|
||||
|
||||
/* week day names */
|
||||
#define DAY_1 B_DAY_1
|
||||
#define DAY_2 B_DAY_2
|
||||
#define DAY_3 B_DAY_3
|
||||
#define DAY_4 B_DAY_4
|
||||
#define DAY_5 B_DAY_5
|
||||
#define DAY_6 B_DAY_6
|
||||
#define DAY_7 B_DAY_7
|
||||
|
||||
/* abbreviated week day names */
|
||||
#define ABDAY_1 B_AB_DAY_1
|
||||
#define ABDAY_2 B_AB_DAY_2
|
||||
#define ABDAY_3 B_AB_DAY_3
|
||||
#define ABDAY_4 B_AB_DAY_4
|
||||
#define ABDAY_5 B_AB_DAY_5
|
||||
#define ABDAY_6 B_AB_DAY_6
|
||||
#define ABDAY_7 B_AB_DAY_7
|
||||
|
||||
/* month names */
|
||||
#define MON_1 B_MON_1
|
||||
#define MON_2 B_MON_2
|
||||
#define MON_3 B_MON_3
|
||||
#define MON_4 B_MON_4
|
||||
#define MON_5 B_MON_5
|
||||
#define MON_6 B_MON_6
|
||||
#define MON_7 B_MON_7
|
||||
#define MON_8 B_MON_8
|
||||
#define MON_9 B_MON_9
|
||||
#define MON_10 B_MON_10
|
||||
#define MON_11 B_MON_11
|
||||
#define MON_12 B_MON_12
|
||||
|
||||
/* abbreviated month names */
|
||||
#define ABMON_1 B_AB_MON_1
|
||||
#define ABMON_2 B_AB_MON_2
|
||||
#define ABMON_3 B_AB_MON_3
|
||||
#define ABMON_4 B_AB_MON_4
|
||||
#define ABMON_5 B_AB_MON_5
|
||||
#define ABMON_6 B_AB_MON_6
|
||||
#define ABMON_7 B_AB_MON_7
|
||||
#define ABMON_8 B_AB_MON_8
|
||||
#define ABMON_9 B_AB_MON_9
|
||||
#define ABMON_10 B_AB_MON_10
|
||||
#define ABMON_11 B_AB_MON_11
|
||||
#define ABMON_12 B_AB_MON_12
|
||||
|
||||
#define ERA B_ERA /* era description segments */
|
||||
#define ERA_D_FMT B_ERA_DATE_FORMAT /* era date format string */
|
||||
#define ERA_D_T_FMT B_ERA_DATE_TIME_FORMAT /* era date and time format string */
|
||||
#define ERA_T_FMT B_TIME_FORMAT /* era time format string */
|
||||
#define ALT_DIGITS B_ALT_DIGITS /* alternative symbols for digits */
|
||||
|
||||
#define RADIXCHAR B_DECIMAL_POINT /* radix char */
|
||||
#define THOUSEP B_THOUSANDS_SEPARATOR /* separator for thousands */
|
||||
|
||||
#define YESEXPR B_YES_EXPRESSION /* affirmative response expression */
|
||||
#define NOEXPR B_NO_EXPRESSION /* negative response expression */
|
||||
#define YESSTR B_YES_STRING /* affirmative response for yes/no queries */
|
||||
#define NOSTR B_NO_STRING /* negative response for yes/no queries */
|
||||
|
||||
#define CRNCYSTR B_CURRENCY_SYMBOL /* currency symbol */
|
||||
|
||||
//#define D_MD_ORDER 57 /* month/day order (local extension) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char *nl_langinfo(nl_item);
|
||||
|
||||
#endif /* _LANGINFO_H_ */
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef _MONETARY_H_
|
||||
#define _MONETARY_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ssize_t strfmon(char *string, size_t maxSize, const char *format, ...);
|
||||
ssize_t vstrfmon(char *string, size_t maxSize, const char *format, va_list args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MONETARY_H_ */
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NL_TYPES_H_
|
||||
#define _NL_TYPES_H_
|
||||
|
||||
|
||||
#define NL_SETD 0
|
||||
#define NL_CAT_LOCALE 1
|
||||
|
||||
typedef int nl_item;
|
||||
typedef void *nl_catd;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern nl_catd catopen(const char *name, int oflag);
|
||||
extern char *catgets(nl_catd cat, int setID, int msgID, const char *defaultMessage);
|
||||
extern int catclose(nl_catd cat);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NL_TYPES_H_ */
|
||||
Reference in New Issue
Block a user