2 * Copyright 2011-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Adrien Destugues, pulkomandy@pulkomandy.ath.cx
7 * John Scipione, jscipione@gmail.com
10 * headers/os/locale/NumberFormat.h hrev48439
11 * src/kits/locale/NumberFormat.cpp hrev48439
19 \brief Contains BNumberFormat class, a number formatter and parser.
27 \brief Formatter for numbers and monetary values.
34 \fn BNumberFormat::BNumberFormat(const BNumberFormat& other)
35 \brief Copy Constructor.
37 \param other The BNumberFormat object to copy from.
44 \fn BNumberFormat::~BNumberFormat()
52 \fn ssize_t BNumberFormat::Format(char* string, size_t maxSize,
54 \brief Format the \c double \a value as a string and put the result
55 into \a string up to \a maxSize bytes in the current locale.
57 \param string The string to put the formatted number into.
58 \param maxSize The maximum of bytes to copy into \a string.
59 \param value The number that you want to get a formatted version of.
61 \returns The length of the string created or an error status code.
62 \retval B_ERROR Unable to lock the BNumberFormat.
63 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
65 \retval B_BAD_VALUE There was not enough space to store the result.
67 \sa BNumberFormat::Format(char* string, size_t maxSize,
69 \sa ssize_t BNumberFormat::FormatMonetary(char* string, size_t maxSize,
77 \fn status_t BNumberFormat::Format(BString& string, const double value)
78 \brief \brief Format the \c double \a value as a string and put the
79 result into \a string in the current locale.
81 \param string The string to put the formatted number into.
82 \param value The number that you want to get a formatted version of.
84 \returns A status code.
85 \retval B_OK Everything went fine.
86 \retval B_ERROR Unable to lock the BNumberFormat.
87 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
89 \retval B_BAD_VALUE There was not enough space to store the result.
91 \sa BNumberFormat::Format(BString* string, int32 value) const
92 \sa BNumberFormat::FormatMonetary(BString* string, double value) const
99 \fn ssize_t BNumberFormat::Format(char* string, size_t maxSize,
101 \brief Format the \c int32 \a value as a string and put the result
102 into \a string up to \a maxSize bytes in the current locale.
104 \param string The string to put the formatted number into.
105 \param maxSize The maximum of bytes to copy into \a string.
106 \param value The number that you want to get a formatted version of.
108 \returns The length of the string created or an error status code.
109 \retval B_ERROR Unable to lock the BNumberFormat.
110 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
112 \retval B_BAD_VALUE There was not enough space to store the result.
114 \sa BNumberFormat::Format(char* string, size_t maxSize,
116 \sa BNumberFormat::FormatMonetary(char* string, size_t maxSize,
124 \fn status_t BNumberFormat::Format(BString& string, const int32 value)
125 \brief Format the \c int32 \a value as a string and put the result
126 into \a string in the current locale.
128 \param string The string to put the formatted number into.
129 \param value The number that you want to get a formatted version of.
131 \returns A status code.
132 \retval B_OK Everything went fine.
133 \retval B_ERROR Unable to lock the BNumberFormat.
134 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
136 \retval B_BAD_VALUE There was not enough space to store the result.
138 \sa BNumberFormat::Format(BString* string, double value) const
139 \sa BNumberFormat::FormatMonetary(BString* string, double value) const
146 \fn ssize_t BNumberFormat::FormatMonetary(char* string, size_t maxSize,
148 \brief Format the \c double \a value as a monetary string and put the
149 result into \a string up to \a maxSize bytes in the current locale.
151 It uses the money symbol set by the Locale (€, $, ...) or the generic money
152 symbol (¤) if the locale is not country-specific.
154 \param string The \a string to put the monetary formatted number into.
155 \param maxSize The maximum of bytes to copy into \a string.
156 \param value The number to format as a monetary \a value.
158 \returns The length of the string created or an error status code.
159 \retval B_ERROR Unable to lock the BNumberFormat.
160 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
162 \retval B_BAD_VALUE There was not enough space to store the result.
164 \sa BNumberFormat::Format(char* string, size_t maxSize, double value) const
165 \sa BNumberFormat::Format(char* string, size_t maxSize, int32 value) const
172 \fn status_t BNumberFormat::FormatMonetary(BString& string,
174 \brief Format the \c double \a value as a monetary string and put
175 the result into \a string in the current locale.
177 \param string The \a string to put the monetary formatted number into.
178 \param value The number to format as a monetary \a value.
180 \returns A status code.
181 \retval B_OK Everything went fine.
182 \retval B_ERROR Unable to lock the BNumberFormat.
183 \retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
185 \retval B_BAD_VALUE There was not enough space to store the result.
187 \sa BNumberFormat::Format(BString* string, double value) const
188 \sa BNumberFormat::Format(BString* string, int32 value) const