2011-08-10 01:46:13 +04:00
|
|
|
/*
|
2014-12-05 03:13:46 +03:00
|
|
|
* Copyright 2011-2014 Haiku, Inc. All rights reserved.
|
2011-08-10 01:46:13 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de.
|
|
|
|
* John Scipione, jscipione@gmail.com
|
|
|
|
* Oliver Tappe, zooey@hirschkaefer.de.
|
2013-02-07 06:05:00 +04:00
|
|
|
*
|
2011-08-10 01:46:13 +04:00
|
|
|
* Corresponds to:
|
2014-12-05 03:13:46 +03:00
|
|
|
* headers/os/locale/Locale.h hrev48439
|
|
|
|
* src/kits/locale/Locale.cpp hrev48439
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-08-03 20:02:55 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\file Locale.h
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup locale
|
|
|
|
\ingroup libbe
|
|
|
|
\brief Provides the BLocale class, the base class of the Locale Kit.
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
2010-08-03 20:02:55 +04:00
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\class BLocale
|
2011-08-10 01:46:13 +04:00
|
|
|
\ingroup locale
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup libbe
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Class for representing a locale and its settings.
|
2010-08-05 16:09:20 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
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.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-03 20:02:55 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BLocale::BLocale(const BLanguage* language,
|
|
|
|
const BFormattingConventions* conventions)
|
|
|
|
\brief Initializes a BLocale object corresponding to the passed in
|
2014-06-12 00:48:17 +04:00
|
|
|
\a language and \a conventions.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-08-03 20:02:55 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn BLocale::BLocale(const BLocale& other)
|
2014-06-12 00:48:17 +04:00
|
|
|
\brief Initializes a BLocale object as a copy of \a other.
|
|
|
|
|
|
|
|
\param other The BLocale object to initialize from.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
|
|
|
|
2010-08-03 20:02:55 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
/*!
|
|
|
|
status_t BLocale::GetCollator(BCollator* collator) const
|
|
|
|
\brief Gets the collator associated to this locale.
|
2010-08-03 20:02:55 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
Returns the collator in use for this locale, allowing you to use it
|
|
|
|
to sort a set of strings.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-03 20:02:55 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-03 20:02:55 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn BLocale& BLocale::operator=(const BLocale& other)
|
2014-06-12 00:48:17 +04:00
|
|
|
\brief Initializes a BLocale object as a copy of \a other by overloading
|
|
|
|
the = operator.
|
|
|
|
|
|
|
|
\param other The BLocale object to initialize from.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
2010-08-03 20:02:55 +04:00
|
|
|
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
/*!
|
|
|
|
\fn BLocale::~BLocale()
|
|
|
|
\brief Destructor method.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-03 20:02:55 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-03 20:02:55 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn status_t BLocale::GetCollator(BCollator* collator) const
|
|
|
|
\brief Sets \a collator object to the default collator for the BLocale.
|
2010-08-05 16:09:20 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\param collator A pointer to a BCollator object to fill out.
|
|
|
|
|
|
|
|
\returns A status code.
|
|
|
|
\retval B_OK Everything went well.
|
|
|
|
\retval B_BAD_VALUE \c NULL \a collator object passed in.
|
|
|
|
\retval B_ERROR Unable to lock the BLocale.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-05 16:09:20 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-05 16:09:20 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn status_t BLocale::GetLanguage(BLanguage* language) const
|
|
|
|
\brief Sets \a language object to the default language for the BLocale.
|
2010-08-05 16:09:20 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\param language A pointer to a BLanguage object to fill out.
|
|
|
|
|
|
|
|
\returns A status code.
|
|
|
|
\retval B_OK Everything went well.
|
|
|
|
\retval B_BAD_VALUE \c NULL \a language object passed in.
|
|
|
|
\retval B_ERROR Unable to lock the BLocale.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-05 16:09:20 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-05 16:09:20 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn status_t BLocale::GetFormattingConventions(
|
|
|
|
BFormattingConventions* conventions) const
|
2014-06-12 00:48:17 +04:00
|
|
|
\brief Fills out \a conventions with the default formatting conventions
|
|
|
|
for the BLocale.
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2014-06-12 00:48:17 +04:00
|
|
|
\param conventions A pointer to a BFormattingConventions object to fill
|
|
|
|
out.
|
2010-08-05 16:09:20 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\returns A status code.
|
|
|
|
\retval B_OK Everything went well.
|
|
|
|
\retval B_BAD_VALUE \c NULL \a conventions object passed in.
|
|
|
|
\retval B_ERROR Unable to lock the BLocale.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-05 16:09:20 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-05 16:09:20 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn const char* BLocale::GetString(uint32 id) const
|
|
|
|
\brief Gets the language string for the locale.
|
|
|
|
|
|
|
|
\param id The locale \a id to get the language of.
|
|
|
|
|
|
|
|
\internal Assumes a certain order of the string bases.
|
|
|
|
|
2014-06-12 00:48:17 +04:00
|
|
|
\returns A blank string in the case of an error or the string "UTF-8"
|
|
|
|
if there is \a id is set to \a B_CODESET.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-05 16:09:20 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-05 16:09:20 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn void BLocale::SetFormattingConventions(
|
|
|
|
const BFormattingConventions& conventions)
|
|
|
|
\brief Sets the formatting convention for this locale.
|
|
|
|
|
2011-11-02 10:02:36 +04:00
|
|
|
If unable to lock the BLocale \a conventions is left untouched.
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\param conventions The formatting convention to set.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-05 16:09:20 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-05 16:09:20 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn void BLocale::SetCollator(const BCollator& newCollator)
|
|
|
|
\brief Set the collator for this locale.
|
|
|
|
|
2011-11-02 10:02:36 +04:00
|
|
|
If unable to lock the BLocale \a newCollator is left untouched.
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\param newCollator The collator to set.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-08-05 16:09:20 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
|
2010-08-05 16:09:20 +04:00
|
|
|
/*!
|
2011-08-10 01:46:13 +04:00
|
|
|
\fn void BLocale::SetLanguage(const BLanguage& newLanguage)
|
|
|
|
\brief Set the language for this locale.
|
|
|
|
|
2011-11-02 10:02:36 +04:00
|
|
|
If unable to lock the BLocale \a newLanguage is left untouched.
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\param newLanguage The code of the language to set to locale to.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|