xref: /haiku/headers/os/locale/NumberFormat.h (revision 68f76d61d74f9f73085105d541b4d0a5e7df0317)
1 /*
2  * Copyright 2003-2017, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _B_NUMBER_FORMAT_H_
6 #define _B_NUMBER_FORMAT_H_
7 
8 
9 #include <Format.h>
10 
11 
12 enum BNumberElement {
13 	B_DECIMAL_SEPARATOR = 10, // Values 0-9 are reserved for digit symbols
14 	B_GROUPING_SEPARATOR,
15 };
16 
17 
18 class BNumberFormatImpl;
19 
20 
21 class BNumberFormat : public BFormat {
22 public:
23 								BNumberFormat();
24 								BNumberFormat(const BLocale* locale);
25 								~BNumberFormat();
26 
27 			ssize_t				Format(char* string, size_t maxSize, const double value);
28 			status_t			Format(BString& string, const double value);
29 			ssize_t				Format(char* string, size_t maxSize, const int32 value);
30 			status_t			Format(BString& string, const int32 value);
31 
32 			status_t			SetPrecision(int precision);
33 
34 			ssize_t				FormatMonetary(char* string, size_t maxSize, const double value);
35 			status_t			FormatMonetary(BString& string, const double value);
36 
37 			ssize_t				FormatPercent(char* string, size_t maxSize, const double value);
38 			status_t			FormatPercent(BString& string, const double value);
39 
40 			status_t			Parse(const BString& string, double& value);
41 
42 			BString				GetSeparator(BNumberElement element);
43 
44 private:
45 								BNumberFormat(const BNumberFormat &other);
46 
47 private:
48 			BNumberFormatImpl*	fPrivateData;
49 };
50 
51 
52 #endif	// _B_NUMBER_FORMAT_H_
53