2009-05-01 23:23:59 +04:00
|
|
|
#ifndef _B_LOCALE_H_
|
|
|
|
#define _B_LOCALE_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <Collator.h>
|
|
|
|
#include <Language.h>
|
|
|
|
#include <Country.h>
|
|
|
|
|
|
|
|
class BCatalog;
|
2009-05-02 05:09:26 +04:00
|
|
|
class BLocaleRoster;
|
2009-05-01 23:23:59 +04:00
|
|
|
class BString;
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
class BLocale {
|
2009-05-01 23:23:59 +04:00
|
|
|
public:
|
|
|
|
BLocale();
|
|
|
|
~BLocale();
|
|
|
|
|
|
|
|
BCollator *Collator() const { return fCollator; }
|
|
|
|
BCountry *Country() const { return fCountry; }
|
|
|
|
BLanguage *Language() const { return fLanguage; }
|
|
|
|
|
|
|
|
// see definitions in LocaleStrings.h
|
|
|
|
const char *GetString(uint32 id);
|
|
|
|
|
|
|
|
void FormatString(char *target, size_t maxSize, char *fmt, ...);
|
|
|
|
void FormatString(BString *, char *fmt, ...);
|
|
|
|
void FormatDateTime(char *target, size_t maxSize, const char *fmt, time_t);
|
|
|
|
void FormatDateTime(BString *, const char *fmt, time_t);
|
|
|
|
|
|
|
|
// Country short-hands
|
|
|
|
|
|
|
|
void FormatDate(char *target, size_t maxSize, time_t, bool longFormat);
|
|
|
|
void FormatDate(BString *target, time_t, bool longFormat);
|
|
|
|
void FormatTime(char *target, size_t maxSize, time_t, bool longFormat);
|
|
|
|
void FormatTime(BString *target, time_t, bool longFormat);
|
|
|
|
|
|
|
|
// Collator short-hands
|
|
|
|
|
|
|
|
int StringCompare(const char *, const char *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT) const;
|
|
|
|
int StringCompare(const BString *, const BString *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT) const;
|
|
|
|
|
|
|
|
void GetSortKey(const char *string, BString *key);
|
2009-05-02 01:56:16 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
status_t GetAppCatalog(BCatalog *);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BCollator *fCollator;
|
|
|
|
BLanguage *fLanguage;
|
|
|
|
BCountry *fCountry;
|
|
|
|
};
|
|
|
|
|
|
|
|
// global objects
|
2009-05-02 01:56:16 +04:00
|
|
|
extern BLocale *be_locale;
|
|
|
|
extern BLocaleRoster *be_locale_roster;
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//--- country short-hands inlines ---
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline void
|
2009-05-01 23:23:59 +04:00
|
|
|
BLocale::FormatDate(char *target, size_t maxSize, time_t timer, bool longFormat)
|
|
|
|
{
|
|
|
|
fCountry->FormatDate(target, maxSize, timer, longFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline void
|
2009-05-01 23:23:59 +04:00
|
|
|
BLocale::FormatDate(BString *target, time_t timer, bool longFormat)
|
|
|
|
{
|
|
|
|
fCountry->FormatDate(target, timer, longFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline void
|
2009-05-01 23:23:59 +04:00
|
|
|
BLocale::FormatTime(char *target, size_t maxSize, time_t timer, bool longFormat)
|
|
|
|
{
|
|
|
|
fCountry->FormatTime(target, maxSize, timer, longFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline void
|
2009-05-01 23:23:59 +04:00
|
|
|
BLocale::FormatTime(BString *target, time_t timer, bool longFormat)
|
|
|
|
{
|
|
|
|
fCountry->FormatTime(target, timer, longFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--- locale short-hands inlines ---
|
|
|
|
// #pragma mark -
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline int
|
2009-05-01 23:23:59 +04:00
|
|
|
BLocale::StringCompare(const char *string1, const char *string2, int32 length, int8 strength) const
|
|
|
|
{
|
|
|
|
return fCollator->Compare(string1, string2, length, strength);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline int
|
2009-05-01 23:23:59 +04:00
|
|
|
BLocale::StringCompare(const BString *string1, const BString *string2, int32 length, int8 strength) const
|
|
|
|
{
|
|
|
|
return fCollator->Compare(string1->String(), string2->String(), length, strength);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
BLocale::GetSortKey(const char *string, BString *key)
|
|
|
|
{
|
|
|
|
fCollator->GetSortKey(string, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _B_LOCALE_H_ */
|