1 /* 2 * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LOCALE_BACKEND_H 6 #define _LOCALE_BACKEND_H 7 8 9 #include <SupportDefs.h> 10 11 #include <wctype.h> 12 13 14 struct lconv; 15 struct lc_time_t; 16 17 18 namespace BPrivate { 19 20 21 struct LocaleCtypeDataBridge { 22 const unsigned short** addrOfClassInfoTable; 23 const int** addrOfToLowerTable; 24 const int** addrOfToUpperTable; 25 26 const unsigned short* posixClassInfo; 27 const int* posixToLowerMap; 28 const int* posixToUpperMap; 29 30 LocaleCtypeDataBridge(); 31 }; 32 33 34 struct LocaleMessagesDataBridge { 35 const char** posixLanginfo; 36 37 LocaleMessagesDataBridge(); 38 }; 39 40 41 struct LocaleMonetaryDataBridge { 42 const struct lconv* posixLocaleConv; 43 44 LocaleMonetaryDataBridge(); 45 }; 46 47 48 struct LocaleNumericDataBridge { 49 const char** addrOfGlibcDecimalPoint; 50 const char** addrOfGlibcThousandsSep; 51 const char** addrOfGlibcGrouping; 52 uint32_t* addrOfGlibcWCDecimalPoint; 53 uint32_t* addrOfGlibcWCThousandsSep; 54 const struct lconv* posixLocaleConv; 55 56 LocaleNumericDataBridge(); 57 }; 58 59 60 struct LocaleTimeDataBridge { 61 const struct lc_time_t* posixLCTimeInfo; 62 63 LocaleTimeDataBridge(); 64 }; 65 66 67 struct LocaleDataBridge { 68 LocaleCtypeDataBridge ctypeDataBridge; 69 LocaleMessagesDataBridge messagesDataBridge; 70 LocaleMonetaryDataBridge monetaryDataBridge; 71 LocaleNumericDataBridge numericDataBridge; 72 LocaleTimeDataBridge timeDataBridge; 73 const char** posixLanginfo; 74 75 LocaleDataBridge(); 76 }; 77 78 79 class LocaleBackend { 80 public: 81 LocaleBackend(); 82 virtual ~LocaleBackend(); 83 84 virtual const char* SetLocale(int category, const char* locale) = 0; 85 virtual const struct lconv* LocaleConv() = 0; 86 virtual const struct lc_time_t* LCTimeInfo() = 0; 87 88 virtual int IsWCType(wint_t wc, wctype_t charClass) = 0; 89 virtual status_t ToWCTrans(wint_t wc, wctrans_t transition, 90 wint_t& result) = 0; 91 92 virtual const char* GetLanginfo(int index) = 0; 93 94 virtual status_t Strcoll(const char* a, const char* b, 95 int& out) = 0; 96 virtual status_t Strxfrm(char* out, const char* in, size_t size, 97 size_t& outSize) = 0; 98 99 virtual void Initialize(LocaleDataBridge* dataBridge) = 0; 100 101 static status_t LoadBackend(); 102 }; 103 104 105 extern LocaleBackend* gLocaleBackend; 106 107 108 } // namespace BPrivate 109 110 111 #endif // _LOCALE_BACKEND_H 112