Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Friends

bdldfp::DecimalFormatConfig Class Reference

#include <bdldfp_decimalformatconfig.h>

List of all members.

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)
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 &)

Detailed Description

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

See Component bdldfp_decimalformatconfig


Member Enumeration Documentation

Enumerator:
e_NEGATIVE_ONLY 

no sign output when sign bit is not set

e_ALWAYS 

output + when sign bit is not set

Enumerator:
e_SCIENTIFIC 

output number in scientific notation

e_FIXED 

output number in fixed-format

e_NATURAL 

output number in "to-scientific-string" format described in {http://speleotrove.com/decimal/decarith.pdf}


Constructor & Destructor Documentation

bdldfp::DecimalFormatConfig::DecimalFormatConfig (  ) 

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

          precision == 0
          style     == e_NATURAL
          sign      == e_NEGATIVE_ONLY
          infinity  == "inf"
          nan       == "nan"
          snan      == "snan"
          point     == '.'
          exponent  == 'e'
          expwidth  == 2
          showpoint == false
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 
) [explicit]

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

void bdldfp::DecimalFormatConfig::setPrecision ( int  value  ) 

Set the precision attribute of this object to the specified value. Behavior is undefined if value is negative.

void bdldfp::DecimalFormatConfig::setStyle ( Style  value  ) 

Set the style attribute of this object to the specified value.

void bdldfp::DecimalFormatConfig::setSign ( Sign  value  ) 

Set the sign attribute of this object to the specified value.

void bdldfp::DecimalFormatConfig::setInfinity ( const char *  value  ) 

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.

void bdldfp::DecimalFormatConfig::setNan ( const char *  value  ) 

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.

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

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.

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

Set the point attribute of this object to the specified value.

void bdldfp::DecimalFormatConfig::setExponent ( char  value  ) 

Set the exponent attribute of this object to the specified value.

void bdldfp::DecimalFormatConfig::setShowpoint ( bool  value  ) 

Set the showpoint attribute of this object to the specified value.

void bdldfp::DecimalFormatConfig::setExpWidth ( int  value  ) 

Set the expwidth attribute of this object to the specified value. The behavior is undefined unless value is 1, 2, 3, or 4.

int bdldfp::DecimalFormatConfig::precision (  )  const

Return the number of digits of precision in the outputs.

Style bdldfp::DecimalFormatConfig::style (  )  const

Return the style of output format.

Sign bdldfp::DecimalFormatConfig::sign (  )  const

Return the sign attribute.

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

Return infinity string representation.

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

Return NaN string representation.

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

Return sNaN string representation.

char bdldfp::DecimalFormatConfig::decimalPoint (  )  const

Return point character.

char bdldfp::DecimalFormatConfig::exponent (  )  const

Return exponent character.

bool bdldfp::DecimalFormatConfig::showpoint (  )  const

Return the showpoint attribute.

int bdldfp::DecimalFormatConfig::expWidth (  )  const

Return the minimum exponent width.


Friends And Related Function Documentation

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 'bslstrcmp() function.

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 'bslstrcmp() function.


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