Initial
This commit is contained in:
177
worksht/NUMBER.HPP
Normal file
177
worksht/NUMBER.HPP
Normal file
@@ -0,0 +1,177 @@
|
||||
#ifndef _WORKSHT_NUMBER_HPP_
|
||||
#define _WORKSHT_NUMBER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
#ifndef _FILEIO_FILEIO_HPP_
|
||||
#include <fileio/fileio.hpp>
|
||||
#endif
|
||||
#ifndef _WORKSHT_RECORD_HPP_
|
||||
#include <worksht/record.hpp>
|
||||
#endif
|
||||
|
||||
class Number : public Record
|
||||
{
|
||||
public:
|
||||
Number(void);
|
||||
Number(const Number &someNumber);
|
||||
Number(const Record &someRecord);
|
||||
virtual ~Number();
|
||||
Number &operator=(const Number &someNumber);
|
||||
Number &operator=(const Record &someRecord);
|
||||
BOOL operator==(const Number &someNumber)const;
|
||||
operator String(void)const;
|
||||
char *catstr(char *pString);
|
||||
BYTE format(void)const;
|
||||
void format(BYTE format);
|
||||
WORD column(void)const;
|
||||
void column(WORD column);
|
||||
WORD row(void)const;
|
||||
void row(WORD row);
|
||||
double number(void)const;
|
||||
void number(double number);
|
||||
BOOL read(FileIO &inFile);
|
||||
private:
|
||||
BYTE mFormat;
|
||||
WORD mColumn;
|
||||
WORD mRow;
|
||||
double mNumber;
|
||||
};
|
||||
|
||||
inline
|
||||
Number::Number(void)
|
||||
: mFormat(0), mColumn(0), mRow(0), mNumber(0.00)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Number::Number(const Number &someNumber)
|
||||
{
|
||||
*this=someNumber;
|
||||
}
|
||||
|
||||
inline
|
||||
Number::Number(const Record &someRecord)
|
||||
: mFormat(0), mColumn(0), mRow(0), mNumber(0.00)
|
||||
{
|
||||
*this=someRecord;
|
||||
}
|
||||
|
||||
inline
|
||||
Number::~Number()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Number &Number::operator=(const Number &someNumber)
|
||||
{
|
||||
format(someNumber.format());
|
||||
column(someNumber.column());
|
||||
row(someNumber.row());
|
||||
number(someNumber.number());
|
||||
(Record&)*this=(Record&)someNumber;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
Number &Number::operator=(const Record &someRecord)
|
||||
{
|
||||
(Record&)*this=someRecord;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
Number::operator String(void)const
|
||||
{
|
||||
String strString;
|
||||
::sprintf(strString,"%9.3lf",number());
|
||||
return strString;
|
||||
}
|
||||
|
||||
inline
|
||||
char *Number::catstr(char *pString)
|
||||
{
|
||||
::sprintf(pString,"%9.3lf",number());
|
||||
while(*pString)pString++;
|
||||
return pString;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Number::operator==(const Number &someNumber)const
|
||||
{
|
||||
return (format()==someNumber.format()&&
|
||||
column()==someNumber.column()&&
|
||||
row()==someNumber.row()&&
|
||||
number()==someNumber.number()&&
|
||||
(Record&)*this==(Record&)someNumber);
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE Number::format(void)const
|
||||
{
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
void Number::format(BYTE format)
|
||||
{
|
||||
mFormat=format;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Number::column(void)const
|
||||
{
|
||||
return mColumn;
|
||||
}
|
||||
|
||||
inline
|
||||
void Number::column(WORD column)
|
||||
{
|
||||
mColumn=column;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Number::row(void)const
|
||||
{
|
||||
return mRow;
|
||||
}
|
||||
|
||||
inline
|
||||
void Number::row(WORD row)
|
||||
{
|
||||
mRow=row;
|
||||
}
|
||||
|
||||
inline
|
||||
double Number::number(void)const
|
||||
{
|
||||
return mNumber;
|
||||
}
|
||||
|
||||
inline
|
||||
void Number::number(double number)
|
||||
{
|
||||
mNumber=number;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Number::read(FileIO &inFile)
|
||||
{
|
||||
if(!inFile.read((char*)&mFormat))return FALSE;
|
||||
if(!inFile.read((char*)&mColumn,sizeof(mColumn)))return FALSE;
|
||||
if(!inFile.read((char*)&mRow,sizeof(mRow)))return FALSE;
|
||||
if(!inFile.read((char*)&mNumber,sizeof(mNumber)))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user