haiku/headers/os/locale/NumberFormat.h
Emir SARI e523bfeb06 NumberFormat: add floating-point precision support
- Simplify code in AboutSystem
- Make error string translatable in Locale preflet

Change-Id: I3b967ee04d764ec1bcf0fa40e40dae8da4a35c20
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7373
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-02-27 19:27:56 +00:00

53 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();
BNumberFormat(const BLocale* locale);
~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);
status_t SetPrecision(int precision);
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_