MFC Grid manual

CCharFormat Class Reference

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

#include <Dapfor/Common/CharFormat.h>

Inheritance diagram for CCharFormat:

CFormat

List of all members.


Public Types

enum  Style { Decimal, Hex, Char }
 Styles. More...

Public Member Functions

 CCharFormat (Style style=Char, bool showZero=true, bool showHexPrefix=true, bool showNonSignificantZero=true)
 Constructor.
 CCharFormat (const CCharFormat &format)
 Copy constructor.
 ~CCharFormat ()
 virtual destructor
virtual TString FormatStl (char val, const CDataObject *pDO) const
 The function converts non-formatted value of char type to the formatted string.
virtual bool ParseStl (const TString &, char &val, const CDataObject *pDO) const
 The function converts the formatted string to the non-formatted value of char type.
virtual CString FormatMfc (char val, const CDataObject *pDO) const
 The function converts non-formatted value of char type to the formatted MFC string.
virtual bool ParseMfc (const CString &str, char &val, const CDataObject *pDO) const
 The function converts the formatted MFC string to the non-formatted char-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 char-type value to its text presentation and vice versa.

 Format examples:

 1. CCharFormat(CCharFormat::Decimal).FormatStl(65, 0);
 2. CCharFormat(CCharFormat::Decimal).FormatStl(165, 0);
 3. CCharFormat(CCharFormat::Hex, true, false, false).FormatStl(15, 0);
 4. CCharFormat(CCharFormat::Hex, true, true, false).FormatStl(15, 0);
 5. CCharFormat(CCharFormat::Hex, true, true, true).FormatStl(15, 0);
 6. CCharFormat(CCharFormat::Char).FormatStl(65, 0);

 Output strings:
 1. 65
 2. -91
 3. F
 4. 0xF
 5. 0x0F
 6. A

Member Enumeration Documentation

enum Style

Styles.

Enumerator:
Decimal  Display char as a decimal number.
Hex  Display char as a hexadecimal number.
Char  Display char as ASCII symbol.


Constructor & Destructor Documentation

CCharFormat ( Style  style = Char,
bool  showZero = true,
bool  showHexPrefix = true,
bool  showNonSignificantZero = true 
)

Constructor.

Parameters:
[in] style Style of the format.
[in] showZero Indicates whether it should show the symbols if unformatted value equals to 0.
[in] showHexPrefix indicates whether it should add hexadecimal prefix '0x'.
[in] showNonSignificantZero indicates whether it should show non-significant zeros in order to keep the constant number of digits for the hexadecimal style.

CCharFormat ( const CCharFormat format  ) 

Copy constructor.

Parameters:
[in] format Format to be copied.


Member Function Documentation

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

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

Parameters:
[in] val Non formatted value of char 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,
char &  val,
const CDataObject pDO 
) const [virtual]

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

Parameters:
[in] str Formatted string.
[in,out] val Value of char 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 ( char  val,
const CDataObject pDO 
) const [virtual]

The function converts non-formatted value of char 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,
char &  val,
const CDataObject pDO 
) const [virtual]

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

Parameters:
[in] str MFC string to be formatted.
[in,out] val A value of the char 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.