2014-10-02 11:19:54 +04:00
|
|
|
/*
|
2017-07-23 11:24:02 +03:00
|
|
|
* Copyright 2003-2017, Haiku, Inc.
|
2014-10-02 11:19:54 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2009-05-01 23:23:59 +04:00
|
|
|
#ifndef _B_NUMBER_FORMAT_H_
|
|
|
|
#define _B_NUMBER_FORMAT_H_
|
|
|
|
|
2014-10-02 11:19:54 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
#include <Format.h>
|
|
|
|
|
2014-10-02 11:19:54 +04:00
|
|
|
|
|
|
|
enum BNumberElement {
|
2017-07-23 12:40:25 +03:00
|
|
|
B_DECIMAL_SEPARATOR = 10, // Values 0-9 are reserved for digit symbols
|
|
|
|
B_GROUPING_SEPARATOR,
|
2014-10-02 11:19:54 +04:00
|
|
|
};
|
|
|
|
|
2017-07-23 11:24:02 +03:00
|
|
|
class BNumberFormatImpl;
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
class BNumberFormat : public BFormat {
|
2014-10-02 11:19:54 +04:00
|
|
|
public:
|
2021-03-20 01:03:50 +03:00
|
|
|
BNumberFormat();
|
|
|
|
BNumberFormat(const BLocale* locale);
|
2014-12-05 03:13:46 +03:00
|
|
|
~BNumberFormat();
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2014-10-02 11:19:54 +04:00
|
|
|
ssize_t Format(char* string, size_t maxSize,
|
2017-07-23 11:24:02 +03:00
|
|
|
const double value);
|
|
|
|
status_t Format(BString& string, const double value);
|
2014-10-02 11:19:54 +04:00
|
|
|
ssize_t Format(char* string, size_t maxSize,
|
2017-07-23 11:24:02 +03:00
|
|
|
const int32 value);
|
|
|
|
status_t Format(BString& string, const int32 value);
|
2014-10-02 11:19:54 +04:00
|
|
|
|
|
|
|
ssize_t FormatMonetary(char* string, size_t maxSize,
|
2017-07-23 11:24:02 +03:00
|
|
|
const double value);
|
2014-10-02 11:19:54 +04:00
|
|
|
status_t FormatMonetary(BString& string,
|
2017-07-23 11:24:02 +03:00
|
|
|
const double value);
|
|
|
|
|
2021-03-09 12:06:14 +03:00
|
|
|
ssize_t FormatPercent(char* string, size_t maxSize,
|
|
|
|
const double value);
|
|
|
|
status_t FormatPercent(BString& string,
|
|
|
|
const double value);
|
|
|
|
|
2017-07-23 12:40:25 +03:00
|
|
|
status_t Parse(const BString& string, double& value);
|
|
|
|
|
2021-03-09 12:06:14 +03:00
|
|
|
BString GetSeparator(BNumberElement element);
|
2017-07-23 12:40:25 +03:00
|
|
|
|
2017-07-23 11:24:02 +03:00
|
|
|
private:
|
|
|
|
BNumberFormat(const BNumberFormat &other);
|
|
|
|
|
|
|
|
private:
|
|
|
|
BNumberFormatImpl* fPrivateData;
|
2009-05-01 23:23:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _B_NUMBER_FORMAT_H_
|