#include <bdldfp_decimalformatconfig.h>
This attribute class characterizes how to configure certain behavior of bdldfp::DecimalUtil::format functions.
See bdldfp_decimalformatconfig
◆ Sign
| Enumerator |
|---|
| e_NEGATIVE_ONLY | |
| e_ALWAYS | |
| e_POSITIVE_AS_SPACE | |
◆ Style
| Enumerator |
|---|
| e_SCIENTIFIC | |
| e_FIXED | |
| e_NATURAL | |
◆ DecimalFormatConfig() [1/2]
| bdldfp::DecimalFormatConfig::DecimalFormatConfig |
( |
| ) |
|
|
inline |
Create an object of this class having the (default) attribute values:
snan == "snan"
point == '.'
expwidth == 2
◆ DecimalFormatConfig() [2/2]
| bdldfp::DecimalFormatConfig::DecimalFormatConfig |
( |
int |
precision, |
|
|
Style |
style = e_NATURAL, |
|
|
Sign |
sign = e_NEGATIVE_ONLY, |
|
|
const char * |
infinity = "inf", |
|
|
const char * |
nan = "nan", |
|
|
const char * |
snan = "snan", |
|
|
char |
point = '.', |
|
|
char |
exponent = 'e', |
|
|
bool |
showpoint = false, |
|
|
int |
expWidth = 2 |
|
) |
| |
|
inlineexplicit |
Create an object of this class having the specified precision to control how many digits are written after a decimal point.
- Precondition
- The behavior is undefined unless
precision >= -1. Optionally specify style to control how the number is written. If it is not specified, e_NATURAL is used. Optionally specify sign to control how the sign is output. If is not specified, e_NEGATIVE_ONLY is used. Optionally specify infinity as a string to output infinity value. If it is not specified, "inf" is used. Optionally specify nan as a string to output NaN value. If it is not specified, "nan" is used. Optionally specify snan as a string to output signaling NaN value. If it is not specified, "snan" is used.
-
The behavior is undefined unless the pointers to
infinity, nan and snan remain valid for the lifetime of this object. Optionally specify point as the character to use for decimal points. If it is not specified, . is used. Optionally specify exponent as the character to use for exponent. If it is not specified, e is used. Optionally specify showpoint to force a decimal point to always be written. Optionally specify expWidth to force at least that many digits to be written for an exponent, up to the number of digits in the largest supported exponent. If it is not specified, 2 is used.
-
The behavior is undefined unless
expWidth is 1, 2, 3, or 4. See the Attributes section for information on the class attributes.
◆ decimalPoint()
| char bdldfp::DecimalFormatConfig::decimalPoint |
( |
| ) |
const |
|
inline |
◆ exponent()
| char bdldfp::DecimalFormatConfig::exponent |
( |
| ) |
const |
|
inline |
Return exponent character.
◆ expWidth()
| int bdldfp::DecimalFormatConfig::expWidth |
( |
| ) |
const |
|
inline |
Return the minimum exponent width.
◆ infinity()
| const char * bdldfp::DecimalFormatConfig::infinity |
( |
| ) |
const |
|
inline |
Return infinity string representation.
◆ nan()
| const char * bdldfp::DecimalFormatConfig::nan |
( |
| ) |
const |
|
inline |
Return NaN string representation.
◆ precision()
| int bdldfp::DecimalFormatConfig::precision |
( |
| ) |
const |
|
inline |
Return the number of digits of precision in the outputs.
◆ setDecimalPoint()
| void bdldfp::DecimalFormatConfig::setDecimalPoint |
( |
char |
value | ) |
|
|
inline |
Set the point attribute of this object to the specified value.
◆ setExponent()
| void bdldfp::DecimalFormatConfig::setExponent |
( |
char |
value | ) |
|
|
inline |
Set the exponent attribute of this object to the specified value.
◆ setExpWidth()
| void bdldfp::DecimalFormatConfig::setExpWidth |
( |
int |
value | ) |
|
|
inline |
Set the expwidth attribute of this object to the specified value.
- Precondition
- The behavior is undefined unless
value is 1, 2, 3, or 4.
◆ setInfinity()
| void bdldfp::DecimalFormatConfig::setInfinity |
( |
const char * |
value | ) |
|
|
inline |
Set the infinity attribute of this object to the specified value.
- Precondition
- The behavior is undefined unless the pointer to the
value remains valid for the lifetime of this object.
◆ setNan()
| void bdldfp::DecimalFormatConfig::setNan |
( |
const char * |
value | ) |
|
|
inline |
Set the nan attribute of this object to the specified value.
- Precondition
- The behavior is undefined unless the pointer to the
value remains valid for the lifetime of this object.
◆ setPrecision()
| void bdldfp::DecimalFormatConfig::setPrecision |
( |
int |
value | ) |
|
|
inline |
Set the precision attribute of this object to the specified value. Behavior is undefined unless value >= -1.
◆ setShowpoint()
| void bdldfp::DecimalFormatConfig::setShowpoint |
( |
bool |
value | ) |
|
|
inline |
Set the showpoint attribute of this object to the specified value.
◆ setSign()
| void bdldfp::DecimalFormatConfig::setSign |
( |
Sign |
value | ) |
|
|
inline |
Set the sign attribute of this object to the specified value.
◆ setSNan()
| void bdldfp::DecimalFormatConfig::setSNan |
( |
const char * |
value | ) |
|
|
inline |
Set the snan attribute of this object to the specified value.
- Precondition
- The behavior is undefined unless the pointer to the
value remains valid for the lifetime of this object.
◆ setStyle()
| void bdldfp::DecimalFormatConfig::setStyle |
( |
Style |
value | ) |
|
|
inline |
Set the style attribute of this object to the specified value.
◆ showpoint()
| bool bdldfp::DecimalFormatConfig::showpoint |
( |
| ) |
const |
|
inline |
Return the showpoint attribute.
◆ sign()
Return the sign attribute.
◆ sNan()
| const char * bdldfp::DecimalFormatConfig::sNan |
( |
| ) |
const |
|
inline |
Return sNaN string representation.
◆ style()
Return the style of output format.
◆ operator!=
Return true if the specified lhs and rhs objects do not have the same value, and false otherwise. Two DecimalFormatConfig objects do not have the same value if any of their attributes (respectively) do not have the same value.
- Note
- Note that comparison of two string type attributes are done via 'bsl::strcmp() function.
◆ operator==
Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two DecimalFormatConfig objects have the same value if each of their attributes (respectively) have the same value.
- Note
- Note that comparison of two string type attributes are done via 'bsl::strcmp() function.
The documentation for this class was generated from the following file: