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 class BNumberFormatImpl; 18 19 20 class BNumberFormat : public BFormat { 21 public: 22 BNumberFormat(); 23 BNumberFormat(const BLocale* locale); 24 ~BNumberFormat(); 25 26 ssize_t Format(char* string, size_t maxSize, 27 const double value); 28 status_t Format(BString& string, const double value); 29 ssize_t Format(char* string, size_t maxSize, 30 const int32 value); 31 status_t Format(BString& string, const int32 value); 32 33 ssize_t FormatMonetary(char* string, size_t maxSize, 34 const double value); 35 status_t FormatMonetary(BString& string, 36 const double value); 37 38 ssize_t FormatPercent(char* string, size_t maxSize, 39 const double value); 40 status_t FormatPercent(BString& string, 41 const double value); 42 43 status_t Parse(const BString& string, double& value); 44 45 BString GetSeparator(BNumberElement element); 46 47 private: 48 BNumberFormat(const BNumberFormat &other); 49 50 private: 51 BNumberFormatImpl* fPrivateData; 52 }; 53 54 55 #endif // _B_NUMBER_FORMAT_H_ 56