BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdldfp::DecimalFormatConfig Class Reference

#include <bdldfp_decimalformatconfig.h>

Public Types

enum  Sign { e_NEGATIVE_ONLY , e_ALWAYS }
 
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)
 Set the style attribute of this object to the specified value.
 
void setSign (Sign value)
 Set the sign attribute of this object to the specified value.
 
void setInfinity (const char *value)
 
void setNan (const char *value)
 
void setSNan (const char *value)
 
void setDecimalPoint (char value)
 Set the point attribute of this object to the specified value.
 
void setExponent (char value)
 
void setShowpoint (bool value)
 
void setExpWidth (int value)
 
int precision () const
 Return the number of digits of precision in the outputs.
 
Style style () const
 Return the style of output format.
 
Sign sign () const
 Return the sign attribute.
 
const char * infinity () const
 Return infinity string representation.
 
const char * nan () const
 Return NaN string representation.
 
const char * sNan () const
 Return sNaN string representation.
 
char decimalPoint () const
 Return point character.
 
char exponent () const
 Return exponent character.
 
bool showpoint () const
 Return the showpoint attribute.
 
int expWidth () const
 Return the minimum exponent width.
 

Friends

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

Detailed Description

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

See bdldfp_decimalformatconfig

Member Enumeration Documentation

◆ Sign

Enumerator
e_NEGATIVE_ONLY 
e_ALWAYS 

◆ 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:130
bool showpoint() const
Return the showpoint attribute.
Definition bdldfp_decimalformatconfig.h:476
Sign sign() const
Return the sign attribute.
Definition bdldfp_decimalformatconfig.h:440
Style style() const
Return the style of output format.
Definition bdldfp_decimalformatconfig.h:434
int precision() const
Return the number of digits of precision in the outputs.
Definition bdldfp_decimalformatconfig.h:428
const char * infinity() const
Return infinity string representation.
Definition bdldfp_decimalformatconfig.h:446
@ e_NEGATIVE_ONLY
Definition bdldfp_decimalformatconfig.h:123
const char * nan() const
Return NaN string representation.
Definition bdldfp_decimalformatconfig.h:452
char exponent() const
Return exponent character.
Definition bdldfp_decimalformatconfig.h:470

◆ 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. The behavior is undefined if precision is negative. 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 under @DESCRIPTION in the component-level documentation for information on the class attributes.

Member Function Documentation

◆ decimalPoint()

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

◆ exponent()

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

◆ expWidth()

int bdldfp::DecimalFormatConfig::expWidth ( ) const
inline

◆ infinity()

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

◆ nan()

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

◆ precision()

int bdldfp::DecimalFormatConfig::precision ( ) const
inline

◆ setDecimalPoint()

void bdldfp::DecimalFormatConfig::setDecimalPoint ( char  value)
inline

◆ 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. 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. 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. 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 if value is negative.

◆ 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

◆ setSNan()

void bdldfp::DecimalFormatConfig::setSNan ( const char *  value)
inline

Set the snan attribute of this object to the specified value. 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

◆ showpoint()

bool bdldfp::DecimalFormatConfig::showpoint ( ) const
inline

◆ sign()

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

◆ sNan()

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

◆ style()

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

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 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 that comparison of two string type attributes are done via 'bsl::strcmp() function.


The documentation for this class was generated from the following file: