Public Member Functions | List of all members
BNumberFormat Class Reference

Formatter for numbers and monetary values. More...

Inherits BFormat.

Public Member Functions

 ~BNumberFormat ()
 Destructor. More...
 
ssize_t Format (char *string, size_t maxSize, const double value)
 Format the double value as a string and put the result into string up to maxSize bytes in the current locale. More...
 
status_t Format (BString &string, const double value)
 Format the double value as a string and put the result into string in the current locale. More...
 
ssize_t Format (char *string, size_t maxSize, const int32 value)
 Format the int32 value as a string and put the result into string up to maxSize bytes in the current locale. More...
 
status_t Format (BString &string, const int32 value)
 Format the int32 value as a string and put the result into string in the current locale. More...
 
ssize_t FormatMonetary (char *string, size_t maxSize, const double value)
 Format the double value as a monetary string and put the result into string up to maxSize bytes in the current locale. More...
 
status_t FormatMonetary (BString &string, const double value)
 Format the double value as a monetary string and put the result into string in the current locale. More...
 

Detailed Description

Formatter for numbers and monetary values.

Since
Haiku R1

Constructor & Destructor Documentation

◆ ~BNumberFormat()

BNumberFormat::~BNumberFormat ( )

Destructor.

Since
Haiku R1

Member Function Documentation

◆ Format() [1/4]

ssize_t BNumberFormat::Format ( char *  string,
size_t  maxSize,
const double  value 
)

Format the double value as a string and put the result into string up to maxSize bytes in the current locale.

Parameters
stringThe string to put the formatted number into.
maxSizeThe maximum of bytes to copy into string.
valueThe number that you want to get a formatted version of.
Returns
The length of the string created or an error status code.
Return values
B_ERRORUnable to lock the BNumberFormat.
B_NO_MEMORYRan out of memory while creating the NumberFormat object.
B_BAD_VALUEThere was not enough space to store the result.
See also
BNumberFormat::Format(char* string, size_t maxSize, int32 value) const
ssize_t BNumberFormat::FormatMonetary(char* string, size_t maxSize, double value) const
Since
Haiku R1

◆ Format() [2/4]

status_t BNumberFormat::Format ( BString string,
const double  value 
)

Format the double value as a string and put the result into string in the current locale.

Parameters
stringThe string to put the formatted number into.
valueThe number that you want to get a formatted version of.
Returns
A status code.
Return values
B_OKEverything went fine.
B_ERRORUnable to lock the BNumberFormat.
B_NO_MEMORYRan out of memory while creating the NumberFormat object.
B_BAD_VALUEThere was not enough space to store the result.
See also
BNumberFormat::Format(BString* string, int32 value) const
BNumberFormat::FormatMonetary(BString* string, double value) const
Since
Haiku R1

◆ Format() [3/4]

ssize_t BNumberFormat::Format ( char *  string,
size_t  maxSize,
const int32  value 
)

Format the int32 value as a string and put the result into string up to maxSize bytes in the current locale.

Parameters
stringThe string to put the formatted number into.
maxSizeThe maximum of bytes to copy into string.
valueThe number that you want to get a formatted version of.
Returns
The length of the string created or an error status code.
Return values
B_ERRORUnable to lock the BNumberFormat.
B_NO_MEMORYRan out of memory while creating the NumberFormat object.
B_BAD_VALUEThere was not enough space to store the result.
See also
BNumberFormat::Format(char* string, size_t maxSize, double value) const
BNumberFormat::FormatMonetary(char* string, size_t maxSize, double value) const
Since
Haiku R1

◆ Format() [4/4]

status_t BNumberFormat::Format ( BString string,
const int32  value 
)

Format the int32 value as a string and put the result into string in the current locale.

Parameters
stringThe string to put the formatted number into.
valueThe number that you want to get a formatted version of.
Returns
A status code.
Return values
B_OKEverything went fine.
B_ERRORUnable to lock the BNumberFormat.
B_NO_MEMORYRan out of memory while creating the NumberFormat object.
B_BAD_VALUEThere was not enough space to store the result.
See also
BNumberFormat::Format(BString* string, double value) const
BNumberFormat::FormatMonetary(BString* string, double value) const
Since
Haiku R1

◆ FormatMonetary() [1/2]

ssize_t BNumberFormat::FormatMonetary ( char *  string,
size_t  maxSize,
const double  value 
)

Format the double value as a monetary string and put the result into string up to maxSize bytes in the current locale.

It uses the money symbol set by the Locale (€, $, ...) or the generic money symbol (¤) if the locale is not country-specific.

Parameters
stringThe string to put the monetary formatted number into.
maxSizeThe maximum of bytes to copy into string.
valueThe number to format as a monetary value.
Returns
The length of the string created or an error status code.
Return values
B_ERRORUnable to lock the BNumberFormat.
B_NO_MEMORYRan out of memory while creating the NumberFormat object.
B_BAD_VALUEThere was not enough space to store the result.
See also
BNumberFormat::Format(char* string, size_t maxSize, double value) const
BNumberFormat::Format(char* string, size_t maxSize, int32 value) const
Since
Haiku R1

◆ FormatMonetary() [2/2]

status_t BNumberFormat::FormatMonetary ( BString string,
const double  value 
)

Format the double value as a monetary string and put the result into string in the current locale.

Parameters
stringThe string to put the monetary formatted number into.
valueThe number to format as a monetary value.
Returns
A status code.
Return values
B_OKEverything went fine.
B_ERRORUnable to lock the BNumberFormat.
B_NO_MEMORYRan out of memory while creating the NumberFormat object.
B_BAD_VALUEThere was not enough space to store the result.
See also
BNumberFormat::Format(BString* string, double value) const
BNumberFormat::Format(BString* string, int32 value) const
Since
Haiku R1