xref: /haiku/docs/user/locale/NumberFormat.dox (revision 81ec973846ea4816c53ed8901822e43c8b06878d)
1/*
2 * Copyright 2011-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Adrien Destugues, pulkomandy@pulkomandy.ath.cx
7 *		John Scipione, jscipione@gmail.com
8 *
9 * Corresponds to:
10 *		headers/os/locale/NumberFormat.h	hrev48439
11 *		src/kits/locale/NumberFormat.cpp	hrev48439
12 */
13
14
15/*!
16	\file NumberFormat.h
17	\ingroup locale
18	\ingroup libbe
19	\brief Contains BNumberFormat class, a number formatter and parser.
20*/
21
22
23/*!
24	\class BNumberFormat
25	\ingroup locale
26	\ingroup libbe
27	\brief Formatter for numbers and monetary values.
28
29	\since Haiku R1
30*/
31
32
33/*!
34	\fn BNumberFormat::BNumberFormat(const BNumberFormat& other)
35	\brief Copy Constructor.
36
37	\param other The BNumberFormat object to copy from.
38
39	\since Haiku R1
40*/
41
42
43/*!
44	\fn BNumberFormat::~BNumberFormat()
45	\brief Destructor.
46
47	\since Haiku R1
48*/
49
50
51/*!
52	\fn ssize_t BNumberFormat::Format(char* string, size_t maxSize,
53		const double value) const
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.
56
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.
60
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
64	        object.
65	\retval B_BAD_VALUE There was not enough space to store the result.
66
67	\sa BNumberFormat::Format(char* string, size_t maxSize,
68		int32 value) const
69	\sa ssize_t BNumberFormat::FormatMonetary(char* string, size_t maxSize,
70		double value) const
71
72	\since Haiku R1
73*/
74
75
76/*!
77	\fn status_t BNumberFormat::Format(BString& string,
78		const double value) const
79	\brief \brief Format the \c double \a value as a string and put the
80	       result into \a string in the current locale.
81
82	\param string The string to put the formatted number into.
83	\param value The number that you want to get a formatted version of.
84
85	\returns A status code.
86	\retval B_OK Everything went fine.
87	\retval B_ERROR Unable to lock the BNumberFormat.
88	\retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
89	        object.
90	\retval B_BAD_VALUE There was not enough space to store the result.
91
92	\sa BNumberFormat::Format(BString* string, int32 value) const
93	\sa BNumberFormat::FormatMonetary(BString* string, double value) const
94
95	\since Haiku R1
96*/
97
98
99/*!
100	\fn ssize_t BNumberFormat::Format(char* string, size_t maxSize,
101		const int32 value) const
102	\brief Format the \c int32 \a value as a string and put the result
103	       into \a string up to \a maxSize bytes in the current locale.
104
105	\param string The string to put the formatted number into.
106	\param maxSize The maximum of bytes to copy into \a string.
107	\param value The number that you want to get a formatted version of.
108
109	\returns The length of the string created or an error status code.
110	\retval B_ERROR Unable to lock the BNumberFormat.
111	\retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
112	        object.
113	\retval B_BAD_VALUE There was not enough space to store the result.
114
115	\sa BNumberFormat::Format(char* string, size_t maxSize,
116		double value) const
117	\sa BNumberFormat::FormatMonetary(char* string, size_t maxSize,
118		double value) const
119
120	\since Haiku R1
121*/
122
123
124/*!
125	\fn status_t BNumberFormat::Format(BString& string,
126		const int32 value) const
127	\brief Format the \c int32 \a value as a string and put the result
128	       into \a string in the current locale.
129
130	\param string The string to put the formatted number into.
131	\param value The number that you want to get a formatted version of.
132
133	\returns A status code.
134	\retval B_OK Everything went fine.
135	\retval B_ERROR Unable to lock the BNumberFormat.
136	\retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
137	        object.
138	\retval B_BAD_VALUE There was not enough space to store the result.
139
140	\sa BNumberFormat::Format(BString* string, double value) const
141	\sa BNumberFormat::FormatMonetary(BString* string, double value) const
142
143	\since Haiku R1
144*/
145
146
147/*!
148	\fn ssize_t BNumberFormat::FormatMonetary(char* string, size_t maxSize,
149		const double value) const
150	\brief Format the \c double \a value as a monetary string and put the
151	       result into \a string up to \a maxSize bytes in the current locale.
152
153	It uses the money symbol set by the Locale (€, $, ...) or the generic money
154	symbol (¤) if the locale is not country-specific.
155
156	\param string The \a string to put the monetary formatted number into.
157	\param maxSize The maximum of bytes to copy into \a string.
158	\param value The number to format as a monetary \a value.
159
160	\returns The length of the string created or an error status code.
161	\retval B_ERROR Unable to lock the BNumberFormat.
162	\retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
163	        object.
164	\retval B_BAD_VALUE There was not enough space to store the result.
165
166	\sa BNumberFormat::Format(char* string, size_t maxSize, double value) const
167	\sa BNumberFormat::Format(char* string, size_t maxSize, int32 value) const
168
169	\since Haiku R1
170*/
171
172
173/*!
174	\fn status_t BNumberFormat::FormatMonetary(BString& string,
175		const double value) const
176	\brief Format the \c double \a value as a monetary string and put
177	       the result into \a string in the current locale.
178
179	\param string The \a string to put the monetary formatted number into.
180	\param value The number to format as a monetary \a value.
181
182	\returns A status code.
183	\retval B_OK Everything went fine.
184	\retval B_ERROR Unable to lock the BNumberFormat.
185	\retval B_NO_MEMORY Ran out of memory while creating the NumberFormat
186	        object.
187	\retval B_BAD_VALUE There was not enough space to store the result.
188
189	\sa BNumberFormat::Format(BString* string, double value) const
190	\sa BNumberFormat::Format(BString* string, int32 value) const
191
192	\since Haiku R1
193*/
194