564de1924a
Updates BNumberFormat to be able to format percentages. Also re-introduces some unit tests and updates the BNumberFormat ones. This doesn't actually fix #16312 as the defaults for percentage formatting don't seem to track the selected language, but goes part way there. Related to #16312 Change-Id: Id6ddf426ce5571f4e8513c0eb1663cf42ac53cb1 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3767 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
/*
|
|
* Copyright 2003-2017, Haiku, Inc.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _B_NUMBER_FORMAT_H_
|
|
#define _B_NUMBER_FORMAT_H_
|
|
|
|
|
|
#include <Format.h>
|
|
|
|
|
|
enum BNumberElement {
|
|
B_DECIMAL_SEPARATOR = 10, // Values 0-9 are reserved for digit symbols
|
|
B_GROUPING_SEPARATOR,
|
|
};
|
|
|
|
class BNumberFormatImpl;
|
|
|
|
|
|
class BNumberFormat : public BFormat {
|
|
public:
|
|
BNumberFormat(const BLocale* locale = NULL);
|
|
~BNumberFormat();
|
|
|
|
ssize_t Format(char* string, size_t maxSize,
|
|
const double value);
|
|
status_t Format(BString& string, const double value);
|
|
ssize_t Format(char* string, size_t maxSize,
|
|
const int32 value);
|
|
status_t Format(BString& string, const int32 value);
|
|
|
|
ssize_t FormatMonetary(char* string, size_t maxSize,
|
|
const double value);
|
|
status_t FormatMonetary(BString& string,
|
|
const double value);
|
|
|
|
ssize_t FormatPercent(char* string, size_t maxSize,
|
|
const double value);
|
|
status_t FormatPercent(BString& string,
|
|
const double value);
|
|
|
|
status_t Parse(const BString& string, double& value);
|
|
|
|
BString GetSeparator(BNumberElement element);
|
|
|
|
private:
|
|
BNumberFormat(const BNumberFormat &other);
|
|
|
|
private:
|
|
BNumberFormatImpl* fPrivateData;
|
|
};
|
|
|
|
|
|
#endif // _B_NUMBER_FORMAT_H_
|