2010-07-27 02:05:39 +04:00
|
|
|
/*
|
2014-10-02 11:19:54 +04:00
|
|
|
* Copyright 2003-2014, Haiku, Inc.
|
2010-07-27 02:05:39 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2009-05-01 23:23:59 +04:00
|
|
|
#ifndef _B_LOCALE_H_
|
|
|
|
#define _B_LOCALE_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <Collator.h>
|
2010-10-24 16:57:55 +04:00
|
|
|
#include <FormattingConventions.h>
|
2010-08-02 00:28:19 +04:00
|
|
|
#include <Language.h>
|
2010-08-30 00:55:00 +04:00
|
|
|
#include <Locker.h>
|
2010-08-02 00:28:19 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
class BCatalog;
|
|
|
|
class BString;
|
2011-09-08 01:41:57 +04:00
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
class BLocale {
|
2010-08-02 00:28:19 +04:00
|
|
|
public:
|
2010-10-20 01:36:44 +04:00
|
|
|
BLocale(const BLanguage* language = NULL,
|
2010-10-24 16:57:55 +04:00
|
|
|
const BFormattingConventions* conventions
|
|
|
|
= NULL);
|
2010-08-04 22:45:06 +04:00
|
|
|
BLocale(const BLocale& other);
|
2010-08-02 00:28:19 +04:00
|
|
|
~BLocale();
|
|
|
|
|
2010-11-22 16:06:36 +03:00
|
|
|
static const BLocale* Default();
|
|
|
|
|
2010-08-30 00:55:00 +04:00
|
|
|
BLocale& operator=(const BLocale& other);
|
|
|
|
|
|
|
|
status_t GetCollator(BCollator* collator) const;
|
|
|
|
status_t GetLanguage(BLanguage* language) const;
|
2010-10-24 16:57:55 +04:00
|
|
|
status_t GetFormattingConventions(
|
|
|
|
BFormattingConventions* conventions) const;
|
2010-08-04 22:45:06 +04:00
|
|
|
|
2010-10-24 16:57:55 +04:00
|
|
|
void SetFormattingConventions(
|
|
|
|
const BFormattingConventions& conventions);
|
2010-08-04 22:45:06 +04:00
|
|
|
void SetCollator(const BCollator& newCollator);
|
2010-10-20 01:36:44 +04:00
|
|
|
void SetLanguage(const BLanguage& newLanguage);
|
|
|
|
|
2010-08-02 00:28:19 +04:00
|
|
|
// see definitions in LocaleStrings.h
|
2010-08-30 22:57:17 +04:00
|
|
|
const char* GetString(uint32 id) const;
|
2010-08-02 00:28:19 +04:00
|
|
|
|
|
|
|
// Collator short-hands
|
|
|
|
int StringCompare(const char* s1,
|
|
|
|
const char* s2) const;
|
|
|
|
int StringCompare(const BString* s1,
|
|
|
|
const BString* s2) const;
|
|
|
|
|
|
|
|
void GetSortKey(const char* string,
|
2010-10-24 16:57:55 +04:00
|
|
|
BString* sortKey) const;
|
2010-08-02 00:28:19 +04:00
|
|
|
|
2010-10-20 01:36:44 +04:00
|
|
|
private:
|
2010-08-30 00:55:00 +04:00
|
|
|
mutable BLocker fLock;
|
2010-08-02 00:28:19 +04:00
|
|
|
BCollator fCollator;
|
2010-10-24 16:57:55 +04:00
|
|
|
BFormattingConventions fConventions;
|
2010-08-02 00:28:19 +04:00
|
|
|
BLanguage fLanguage;
|
2010-08-04 22:45:06 +04:00
|
|
|
};
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
|
2010-08-04 22:45:06 +04:00
|
|
|
//--- collator short-hands inlines ---
|
2009-05-01 23:23:59 +04:00
|
|
|
// #pragma mark -
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline int
|
2010-08-02 00:28:19 +04:00
|
|
|
BLocale::StringCompare(const char* s1, const char* s2) const
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
2010-08-02 00:28:19 +04:00
|
|
|
return fCollator.Compare(s1, s2);
|
2009-05-01 23:23:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline int
|
2010-08-02 00:28:19 +04:00
|
|
|
BLocale::StringCompare(const BString* s1, const BString* s2) const
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
2010-08-02 00:28:19 +04:00
|
|
|
return fCollator.Compare(s1->String(), s2->String());
|
2009-05-01 23:23:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
2010-10-24 16:57:55 +04:00
|
|
|
BLocale::GetSortKey(const char* string, BString* sortKey) const
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
2010-10-24 16:57:55 +04:00
|
|
|
fCollator.GetSortKey(string, sortKey);
|
2009-05-01 23:23:59 +04:00
|
|
|
}
|
|
|
|
|
2010-08-02 00:28:19 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
#endif /* _B_LOCALE_H_ */
|