vfs: check userland buffers before reading them.
[haiku.git] / headers / private / libroot / locale / ICUCategoryData.h
blob82df10ccf84690d3183a14d2f405ff197678eb23
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
8 #include <pthread.h>
10 #include <unicode/locid.h>
11 #include <unicode/unistr.h>
13 #include <SupportDefs.h>
15 #include "ICUThreadLocalStorageValue.h"
18 namespace BPrivate {
19 namespace Libroot {
22 class ICUCategoryData {
23 public:
24 ICUCategoryData(pthread_key_t tlsKey);
25 virtual ~ICUCategoryData();
27 virtual status_t SetTo(const Locale& locale,
28 const char* posixLocaleName);
29 virtual status_t SetToPosix();
31 const char* PosixLocaleName()
32 { return fPosixLocaleName; }
34 const Locale& ICULocale() const;
36 protected:
37 status_t _ConvertUnicodeStringToLocaleconvEntry(
38 const UnicodeString& string,
39 char* destination, int destinationSize,
40 const char* defaultValue = "");
42 status_t _GetConverter(UConverter*& converterOut);
44 static const uint16 skMaxPosixLocaleNameLen = 128;
45 static const size_t skLCBufSize = 16;
47 pthread_key_t fThreadLocalStorageKey;
48 Locale fLocale;
49 char fPosixLocaleName[skMaxPosixLocaleNameLen];
50 char fGivenCharset[UCNV_MAX_CONVERTER_NAME_LENGTH];
52 private:
53 status_t _SetupConverter();
57 inline
58 const Locale&
59 ICUCategoryData::ICULocale() const
61 return fLocale;
65 } // namespace Libroot
66 } // namespace BPrivate
69 #endif // _ICU_CATEGORY_DATA_H