2 * Copyright 2011-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de.
7 * John Scipione, jscipione@gmail.com
8 * Oliver Tappe, zooey@hirschkaefer.de.
11 * headers/os/locale/Locale.h hrev48439
12 * src/kits/locale/Locale.cpp hrev48439
20 \brief Provides the BLocale class, the base class of the Locale Kit.
28 \brief Class for representing a locale and its settings.
30 A locale is defined by the combination of a country and a language.
31 Using these two informations, it is possible to determine the format
32 to use for date, time, and number formatting. The BLocale class also
33 provide collators, which allows you to sort a list of strings properly
34 depending on a set of rules about accented chars and other special
35 cases that vary over the different locales.
37 BLocale is also the class to use when you want to perform formatting
38 or parsing of dates, times, and numbers, in the natural language of
46 \fn BLocale::BLocale(const BLanguage* language,
47 const BFormattingConventions* conventions)
48 \brief Initializes a BLocale object corresponding to the passed in
49 \a language and \a conventions.
56 \fn BLocale::BLocale(const BLocale& other)
57 \brief Initializes a BLocale object as a copy of \a other.
59 \param other The BLocale object to initialize from.
66 status_t BLocale::GetCollator(BCollator* collator) const
67 \brief Gets the collator associated to this locale.
69 Returns the collator in use for this locale, allowing you to use it
70 to sort a set of strings.
77 \fn BLocale& BLocale::operator=(const BLocale& other)
78 \brief Initializes a BLocale object as a copy of \a other by overloading
81 \param other The BLocale object to initialize from.
88 \fn BLocale::~BLocale()
89 \brief Destructor method.
96 \fn status_t BLocale::GetCollator(BCollator* collator) const
97 \brief Sets \a collator object to the default collator for the BLocale.
99 \param collator A pointer to a BCollator object to fill out.
101 \returns A status code.
102 \retval B_OK Everything went well.
103 \retval B_BAD_VALUE \c NULL \a collator object passed in.
104 \retval B_ERROR Unable to lock the BLocale.
111 \fn status_t BLocale::GetLanguage(BLanguage* language) const
112 \brief Sets \a language object to the default language for the BLocale.
114 \param language A pointer to a BLanguage object to fill out.
116 \returns A status code.
117 \retval B_OK Everything went well.
118 \retval B_BAD_VALUE \c NULL \a language object passed in.
119 \retval B_ERROR Unable to lock the BLocale.
126 \fn status_t BLocale::GetFormattingConventions(
127 BFormattingConventions* conventions) const
128 \brief Fills out \a conventions with the default formatting conventions
131 \param conventions A pointer to a BFormattingConventions object to fill
134 \returns A status code.
135 \retval B_OK Everything went well.
136 \retval B_BAD_VALUE \c NULL \a conventions object passed in.
137 \retval B_ERROR Unable to lock the BLocale.
144 \fn const char* BLocale::GetString(uint32 id) const
145 \brief Gets the language string for the locale.
147 \param id The locale \a id to get the language of.
149 \internal Assumes a certain order of the string bases.
151 \returns A blank string in the case of an error or the string "UTF-8"
152 if there is \a id is set to \a B_CODESET.
159 \fn void BLocale::SetFormattingConventions(
160 const BFormattingConventions& conventions)
161 \brief Sets the formatting convention for this locale.
163 If unable to lock the BLocale \a conventions is left untouched.
165 \param conventions The formatting convention to set.
172 \fn void BLocale::SetCollator(const BCollator& newCollator)
173 \brief Set the collator for this locale.
175 If unable to lock the BLocale \a newCollator is left untouched.
177 \param newCollator The collator to set.
184 \fn void BLocale::SetLanguage(const BLanguage& newLanguage)
185 \brief Set the language for this locale.
187 If unable to lock the BLocale \a newLanguage is left untouched.
189 \param newLanguage The code of the language to set to locale to.