Public Member Functions | List of all members
BLocale Class Reference

Class for representing a locale and its settings. More...

Public Member Functions

 BLocale (const BLanguage *language=NULL, const BFormattingConventions *conventions=NULL)
 Initializes a BLocale object corresponding to the passed in language and conventions. More...
 
 BLocale (const BLocale &other)
 Initializes a BLocale object as a copy of other. More...
 
 ~BLocale ()
 Destructor method. More...
 
status_t GetCollator (BCollator *collator) const
 Sets collator object to the default collator for the BLocale. More...
 
status_t GetFormattingConventions (BFormattingConventions *conventions) const
 Fills out conventions with the default formatting conventions for the BLocale. More...
 
status_t GetLanguage (BLanguage *language) const
 Sets language object to the default language for the BLocale. More...
 
const char * GetString (uint32 id) const
 Gets the language string for the locale. More...
 
BLocaleoperator= (const BLocale &other)
 Gets the collator associated to this locale. More...
 
void SetCollator (const BCollator &newCollator)
 Set the collator for this locale. More...
 
void SetFormattingConventions (const BFormattingConventions &conventions)
 Sets the formatting convention for this locale. More...
 
void SetLanguage (const BLanguage &newLanguage)
 Set the language for this locale. More...
 

Detailed Description

Class for representing a locale and its settings.

A locale is defined by the combination of a country and a language. Using these two informations, it is possible to determine the format to use for date, time, and number formatting. The BLocale class also provide collators, which allows you to sort a list of strings properly depending on a set of rules about accented chars and other special cases that vary over the different locales.

BLocale is also the class to use when you want to perform formatting or parsing of dates, times, and numbers, in the natural language of the user.

Since
Haiku R1

Constructor & Destructor Documentation

◆ BLocale() [1/2]

BLocale::BLocale ( const BLanguage *  language = NULL,
const BFormattingConventions *  conventions = NULL 
)

Initializes a BLocale object corresponding to the passed in language and conventions.

Since
Haiku R1

◆ BLocale() [2/2]

BLocale::BLocale ( const BLocale other)

Initializes a BLocale object as a copy of other.

Parameters
otherThe BLocale object to initialize from.
Since
Haiku R1

◆ ~BLocale()

BLocale::~BLocale ( )

Destructor method.

Since
Haiku R1

Member Function Documentation

◆ GetCollator()

status_t BLocale::GetCollator ( BCollator collator) const

Sets collator object to the default collator for the BLocale.

Parameters
collatorA pointer to a BCollator object to fill out.
Returns
A status code.
Return values
B_OKEverything went well.
B_BAD_VALUENULL collator object passed in.
B_ERRORUnable to lock the BLocale.
Since
Haiku R1

◆ GetFormattingConventions()

status_t BLocale::GetFormattingConventions ( BFormattingConventions *  conventions) const

Fills out conventions with the default formatting conventions for the BLocale.

Parameters
conventionsA pointer to a BFormattingConventions object to fill out.
Returns
A status code.
Return values
B_OKEverything went well.
B_BAD_VALUENULL conventions object passed in.
B_ERRORUnable to lock the BLocale.
Since
Haiku R1

◆ GetLanguage()

status_t BLocale::GetLanguage ( BLanguage *  language) const

Sets language object to the default language for the BLocale.

Parameters
languageA pointer to a BLanguage object to fill out.
Returns
A status code.
Return values
B_OKEverything went well.
B_BAD_VALUENULL language object passed in.
B_ERRORUnable to lock the BLocale.
Since
Haiku R1

◆ GetString()

const char * BLocale::GetString ( uint32  id) const

Gets the language string for the locale.

Parameters
idThe locale id to get the language of.

◆ operator=()

BLocale & BLocale::operator= ( const BLocale other)

Gets the collator associated to this locale.

status_t BLocale::GetCollator(BCollator* collator) const Returns the collator in use for this locale, allowing you to use it to sort a set of strings.

Since
Haiku R1

Initializes a BLocale object as a copy of other by overloading the = operator.

Parameters
otherThe BLocale object to initialize from.
Since
Haiku R1

◆ SetCollator()

void BLocale::SetCollator ( const BCollator newCollator)

Set the collator for this locale.

If unable to lock the BLocale newCollator is left untouched.

Parameters
newCollatorThe collator to set.
Since
Haiku R1

◆ SetFormattingConventions()

void BLocale::SetFormattingConventions ( const BFormattingConventions &  conventions)

Sets the formatting convention for this locale.

If unable to lock the BLocale conventions is left untouched.

Parameters
conventionsThe formatting convention to set.
Since
Haiku R1

◆ SetLanguage()

void BLocale::SetLanguage ( const BLanguage &  newLanguage)

Set the language for this locale.

If unable to lock the BLocale newLanguage is left untouched.

Parameters
newLanguageThe code of the language to set to locale to.
Since
Haiku R1