//----------------------- CSPNumber.h-- -----------------------

//*************************************************************
//*****       Copyright ©2002 - 2004 Micronovae Ltd       *****
//*****                All rights reserved                *****
//*************************************************************


#ifndef _CSPNUMBER
#define _CSPNUMBER

#include "CSPConf.h"
#include "CSPLib.h"
#include "CSPString.h"
#include "CSPWString.h"

class CSPLIB_CLASS_EXPORT CSPNumber : public CSPObject
{
public:
	enum
	{
		MAX_DIGITS = 32
	};

	CSPNumber();
	virtual ~CSPNumber();

	bool SetScale( unsigned short ushScale );
	unsigned short GetScale() const;
	bool SetPrecision( unsigned short ushPrecision );
	unsigned short GetPrecision() const;
	bool SetSign( bool bSign );
	bool GetSign() const;
	bool SetDigit( unsigned short uchDigit, unsigned char uchValue );
	unsigned char GetDigit( unsigned short uchDigit ) const;

	CSPString GetString() const;
	CSPWString GetWString() const;
	operator CSPString() const;

	bool SetInt( int iVal );
	bool SetUInt( unsigned int uiVal );
	bool SetLong( long lVal );
	bool SetULong( unsigned long ulVal );
	bool SetShort( short shVal );
	bool SetUShort( unsigned short ushVal );
	bool SetChar( char chVal );
	bool SetUChar( unsigned char uchVal );
	bool SetDouble( double dblBal );
	bool SetFloat( float fVal );
	bool SetLongDouble( long double ldblVal );

	int GetInt() const;
	unsigned int GetUInt();
	long GetLong();
	unsigned long GetULong();
	short GetShort() const;
	unsigned short GetUShort() const;
	char GetChar() const;
	unsigned char GetUChar() const;
	double GetDouble() const;
	float GetFloat() const;
	long double GetLongDouble() const;

	CSPNumber& operator = ( int iVal );
	CSPNumber& operator = ( unsigned int uiVal );
	CSPNumber& operator = ( long lVal );
	CSPNumber& operator = ( unsigned long ulVal );
	CSPNumber& operator = ( short shVal );
	CSPNumber& operator = ( unsigned short ushVal );
	CSPNumber& operator = ( char chVal );
	CSPNumber& operator = ( unsigned char uchVal );
	CSPNumber& operator = ( double dblVal );
	CSPNumber& operator = ( float fVal );
	CSPNumber& operator = ( long double ldblVal );


protected:
	unsigned char m_Digits[ MAX_DIGITS ];

	bool m_bSign;
	unsigned short m_ushScale;
	unsigned short m_ushPrecision;
};

#endif
