BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdldfp::DecimalFormatConfig Class Reference

#include <bdldfp_decimalformatconfig.h>

Detailed Description

This attribute class characterizes how to configure certain behavior of bdldfp::DecimalUtil::format functions.

See bdldfp_decimalformatconfig

Public Types

enum  Sign { e_NEGATIVE_ONLY , e_ALWAYS , e_POSITIVE_AS_SPACE }
 
enum  Style { e_SCIENTIFIC , e_FIXED , e_NATURAL }
 

Public Member Functions

 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)
 
void setPrecision (int value)
 
void setStyle (Style value)
 
void setSign (Sign value)
 
void setInfinity (const char *value)
 
void setNan (const char *value)
 
void setSNan (const char *value)
 
void setDecimalPoint (char value)
 
void setExponent (char value)
 
void setShowpoint (bool value)
 
void setExpWidth (int value)
 
int precision () const
 
Style style () const
 
Sign sign () const
 
const char * infinity () const
 
const char * nan () const
 
const char * sNan () const
 
char decimalPoint () const
 
char exponent () const
 
bool showpoint () const
 
int expWidth () const
 

Friends

bool operator== (const DecimalFormatConfig &, const DecimalFormatConfig &)
 
bool operator!= (const DecimalFormatConfig &, const DecimalFormatConfig &)
 

Member Enumeration Documentation

◆ Sign

Enumerator
e_NEGATIVE_ONLY 
e_ALWAYS 
e_POSITIVE_AS_SPACE 

◆ Style

Enumerator
e_SCIENTIFIC 
e_FIXED 
e_NATURAL 

Constructor & Destructor Documentation

◆ DecimalFormatConfig() [1/2]

bdldfp::DecimalFormatConfig::DecimalFormatConfig ( )
inline

Create an object of this class having the (default) attribute values:

infinity == "inf"
nan == "nan"
snan == "snan"
point == '.'
exponent == 'e'
expwidth == 2
showpoint == false
@ e_NATURAL
Definition bdldfp_decimalformatconfig.h:133
bool showpoint() const
Return the showpoint attribute.
Definition bdldfp_decimalformatconfig.h:486
Sign sign() const
Return the sign attribute.
Definition bdldfp_decimalformatconfig.h:450
Style style() const
Return the style of output format.
Definition bdldfp_decimalformatconfig.h:444
int precision() const
Return the number of digits of precision in the outputs.
Definition bdldfp_decimalformatconfig.h:438
const char * infinity() const
Return infinity string representation.
Definition bdldfp_decimalformatconfig.h:456
@ e_NEGATIVE_ONLY
Definition bdldfp_decimalformatconfig.h:125
const char * nan() const
Return NaN string representation.
Definition bdldfp_decimalformatconfig.h:462
char exponent() const
Return exponent character.
Definition bdldfp_decimalformatconfig.h:480

◆ 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.

Member Function Documentation

◆ decimalPoint()

char bdldfp::DecimalFormatConfig::decimalPoint ( ) const
inline

Return point character.

◆ 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()

DecimalFormatConfig::Sign bdldfp::DecimalFormatConfig::sign ( ) const
inline

Return the sign attribute.

◆ sNan()

const char * bdldfp::DecimalFormatConfig::sNan ( ) const
inline

Return sNaN string representation.

◆ style()

DecimalFormatConfig::Style bdldfp::DecimalFormatConfig::style ( ) const
inline

Return the style of output format.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const DecimalFormatConfig ,
const DecimalFormatConfig  
)
friend

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==

bool operator== ( const DecimalFormatConfig ,
const DecimalFormatConfig  
)
friend

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: