MFC Grid manual

CUShortFormat Class Reference

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

#include <Dapfor/Common/UShortFormat.h>

Inheritance diagram for CUShortFormat:

CFormat

List of all members.


Public Types

enum  Style { Decimal, Hex }
 Format styles. More...

Public Member Functions

 CUShortFormat (Style=Decimal, bool showZero=true, TCHAR chThousandSeparator=_T(' '), bool showHexPrefix=true, bool showNonSignificantZero=true)
 Constructor.
 CUShortFormat (const CUShortFormat &)
 Copy constructor.
 ~CUShortFormat ()
 Virtual destructor.
virtual TString FormatStl (unsigned short val, const CDataObject *pDO) const
 The function converts non-formatted value of unsigned short type to the formatted string.
virtual bool ParseStl (const TString &, unsigned short &val, const CDataObject *pDO) const
 The function converts the formatted string to the non-formatted value of unsigned short type.
virtual CString FormatMfc (unsigned short val, const CDataObject *pDO) const
 The function converts non-formatted value of unsigned short type to the formatted MFC string.
virtual bool ParseMfc (const CString &str, unsigned short &val, const CDataObject *pDO) const
 The function converts the formatted MFC string to the non-formatted unsigned unsigned short-type value.
virtual CFormatClone () const
 Creates a deep copy of a format.
virtual void Serialize (CSerializer &serializer)
 Serializes a format.
TCHAR GetSeparator () const
 Gets ASCII symbol, representing a thousand separator.
void SetSeparator (TCHAR chSeparator)
 Sets a new thousand separator.
Style GetStyle () const
 Gets a current style of a format.
void SetStyle (Style style)
 Sets a new format style.

Static Public Member Functions

static int GetSerializeVertion ()
 Serialization version.

Detailed Description

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

 Format examples:

 1. CUShortFormat().FormatStl(1234, 0);
 2. CUShortFormat().FormatStl(-1234, 0);
 3. CUShortFormat(CUShortFormat.Hex, true, _T(' '), false, false).FormatStl(1234, 0);
 4. CUShortFormat(CUShortFormat.Hex, true, _T(' '), true, false).FormatStl(1234, 0);
 5. CUShortFormat(CUShortFormat.Hex, true, _T(' '), true, true).FormatStl(1234, 0);

 Output strings:

 1. 1 234
 2. 64 302
 3. 4D2
 4. 0x4D2
 5. 0x04D2

Member Enumeration Documentation

enum Style

Format styles.

Enumerator:
Decimal  Display short as decimal number.
Hex  Display short as hexadecimal number.


Constructor & Destructor Documentation

CUShortFormat ( Style  style = Decimal,
bool  showZero = true,
TCHAR  thousandSeparator = _T(' '),
bool  showHexPrefix = true,
bool  showNonSignificantZero = true 
)

Constructor.

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

CUShortFormat ( const CUShortFormat format  ) 

Copy constructor.

Parameters:
[in] format to be copied


Member Function Documentation

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

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

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

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

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

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

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

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

TCHAR GetSeparator (  )  const [inline]

Gets ASCII symbol, representing a thousand separator.

Returns:
Thousand separator

void SetSeparator ( TCHAR  separator  )  [inline]

Sets a new thousand separator.

Parameters:
[in] separator ASCII symbol, representing a thousand separator

CUShortFormat::Style GetStyle (  )  const [inline]

Gets a current style of a format.

Returns:
format style

void SetStyle ( Style  style  )  [inline]

Sets a new format style.

Parameters:
[in] style A new format style