1 /* 2 * Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _ICU_CATEGORY_DATA_H 6 #define _ICU_CATEGORY_DATA_H 7 8 #include <pthread.h> 9 10 #include <unicode/locid.h> 11 #include <unicode/unistr.h> 12 13 #include <SupportDefs.h> 14 15 #include "ICUThreadLocalStorageValue.h" 16 17 18 namespace BPrivate { 19 namespace Libroot { 20 21 22 class ICUCategoryData { 23 public: 24 ICUCategoryData(pthread_key_t tlsKey); 25 virtual ~ICUCategoryData(); 26 27 virtual status_t SetTo(const Locale& locale, 28 const char* posixLocaleName); 29 virtual status_t SetToPosix(); 30 31 const char* PosixLocaleName() 32 { return fPosixLocaleName; } 33 34 const Locale& ICULocale() const; 35 36 protected: 37 status_t _ConvertUnicodeStringToLocaleconvEntry( 38 const UnicodeString& string, 39 char* destination, int destinationSize, 40 const char* defaultValue = ""); 41 42 status_t _GetConverter(UConverter*& converterOut); 43 44 static const uint16 skMaxPosixLocaleNameLen = 128; 45 static const size_t skLCBufSize = 16; 46 47 pthread_key_t fThreadLocalStorageKey; 48 Locale fLocale; 49 char fPosixLocaleName[skMaxPosixLocaleNameLen]; 50 char fGivenCharset[UCNV_MAX_CONVERTER_NAME_LENGTH]; 51 52 private: 53 status_t _SetupConverter(); 54 }; 55 56 57 inline 58 const Locale& 59 ICUCategoryData::ICULocale() const 60 { 61 return fLocale; 62 } 63 64 65 } // namespace Libroot 66 } // namespace BPrivate 67 68 69 #endif // _ICU_CATEGORY_DATA_H 70