MFC Grid manual

CDoubleFormat Class Reference

Transforms double-type value to its text presentation and vice versa. More...

#include <Dapfor/Common/DoubleFormat.h>

Inheritance diagram for CDoubleFormat:

CFormat

List of all members.


Public Member Functions

 CDoubleFormat (char precision=3, bool showNonSignificantZero=false, bool showZero=true, TCHAR chPrefix=_T('\0'), TCHAR chSuffix=_T('\0'), TCHAR chThousandSeparator=_T(' '))
 Constructor.
 CDoubleFormat (const CDoubleFormat &)
 Copy constructor.
 ~CDoubleFormat ()
 Destructor.
virtual TString FormatStl (double val, const CDataObject *pDO) const
 The function converts non-formatted value of double type to the formatted string.
virtual bool ParseStl (const TString &str, double &val, const CDataObject *pDO) const
 The function converts the formatted string to the non-formatted value of double type.
virtual CString FormatMfc (double val, const CDataObject *pDO) const
 The function converts non-formatted value of double type to the formatted MFC string.
virtual bool ParseMfc (const CString &str, double &val, const CDataObject *pDO) const
 The function converts the formatted MFC string to the non-formatted double -type value.
virtual CFormatClone () const
 Creates a deep copy of a format.
virtual void Serialize (CSerializer &serializer)
 Serializes a format.

Static Public Member Functions

static int GetSerializeVertion ()
 Serialization version.

Detailed Description

Transforms double-type value to its text presentation and vice versa.

 Format examples:

 1. CDoubleFormat(3).FormatStl(1234.5678, 0);
 2. CDoubleFormat(3).FormatStl(1234.56, 0);
 3. CDoubleFormat(3, true).FormatStl(1234.56, 0);
 4. CDoubleFormat(3, false, true, 0, '$').FormatStl(1234.56, 0);
 5. CDoubleFormat(3, false, true, '@').FormatStl(1234.56, 0);

 Output strings:
 1. 1 234,568
 2. 1 234,56
 3. 1 234,560
 4. 1 234,56$
 5. @1 234,56

Constructor & Destructor Documentation

CDoubleFormat ( char  mantissaLen = 3,
bool  showNonSignificantZero = false,
bool  showZero = true,
TCHAR  chPrefix = _T('\0'),
TCHAR  chSuffix = _T('\0'),
TCHAR  chThousandSeparator = _T(' ') 
)

Constructor.

Parameters:
[in] mantissaLen Number of decimals after the point.
[in] showNonSignificantZero indicates whether it should show non-significant zeros after the point in order to keep the constant number of digits.
[in] showZero Indicates whether it should show the symbols if unformatted value equals to 0.
[in] chPrefix ACSII symbol, from which the formatted string is started.
[in] chSuffix ACSII symbol, by which the formatted string is ended.
[in] chThousandSeparator ACSII symbol, to separate the thousands.

CDoubleFormat ( const CDoubleFormat format  ) 

Copy constructor.

Parameters:
[in] format Format to be copied.


Member Function Documentation

TString FormatStl ( double  val,
const CDataObject pDO 
) const [virtual]

The function converts non-formatted value of double type to the formatted string.

Parameters:
[in] val Non formatted value of double type.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
Formatted string that is a result of conversion.

Reimplemented from CFormat.

bool ParseStl ( const TString &  str,
double &  val,
const CDataObject pDO 
) const [virtual]

The function converts the formatted string to the non-formatted value of double type.

Parameters:
[in] str Formatted string.
[in,out] val Value of double type that is a result of conversion.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
True, if the string has been successfully parsed. Otherwise false.

Reimplemented from CFormat.

CString FormatMfc ( double  val,
const CDataObject pDO 
) const [virtual]

The function converts non-formatted value of double type to the formatted MFC string.

Parameters:
[in] val Non-formatted MFC string to be formatted.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
Formatted string that is a result of conversion.

Reimplemented from CFormat.

bool ParseMfc ( const CString &  str,
double &  val,
const CDataObject pDO 
) const [virtual]

The function converts the formatted MFC string to the non-formatted double -type value.

Parameters:
[in] str MFC string to be formatted.
[in,out] val A value of the double type that is a result of the parsing.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
True, if the string has been successfully parsed. Otherwise false.

Reimplemented from CFormat.

CFormat * Clone (  )  const [virtual]

Creates a deep copy of a format.

Returns:
Deep copy of a format object.

Implements CFormat.

void Serialize ( CSerializer serializer  )  [virtual]

Serializes a format.

Parameters:
[in] serializer Object, into which a format object is serialized.

Reimplemented from CFormat.