Files
Work/worksht/INTEGER.HPP
2024-08-07 09:16:27 -04:00

175 lines
3.0 KiB
C++

#ifndef _WORKSHT_INTEGER_HPP_
#define _WORKSHT_INTEGER_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 Integer : public Record
{
public:
Integer(void);
Integer(const Integer &someInteger);
Integer(const Record &someRecord);
Integer(int row,int col,WORD value);
virtual ~Integer();
Integer &operator=(const Integer &someInteger);
Integer &operator=(const Record &someRecord);
BOOL operator==(const Integer &someInteger)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);
WORD integer(void)const;
void integer(WORD integer);
bool read(FileIO &inFile);
bool write(FileIO &outFile);
private:
BYTE mFormat;
WORD mColumn;
WORD mRow;
WORD mInteger;
};
inline
Integer::Integer(void)
: mFormat(255), mColumn(0), mRow(0), mInteger(0)
{
type(Record::Integer);
}
inline
Integer::Integer(const Integer &someInteger)
: mFormat(255)
{
type(Record::Integer);
*this=someInteger;
}
inline
Integer::Integer(const Record &someRecord)
: mFormat(255), mColumn(0), mRow(0), mInteger(0)
{
type(Record::Integer);
*this=someRecord;
}
inline
Integer::Integer(int row,int col,WORD value)
: mFormat(255), mRow(row), mColumn(col), mInteger(value)
{
type(Record::Integer);
}
inline
Integer::~Integer()
{
}
inline
Integer &Integer::operator=(const Integer &someInteger)
{
format(someInteger.format());
column(someInteger.column());
row(someInteger.row());
integer(someInteger.integer());
(Record&)*this=(Record&)someInteger;
return *this;
}
inline
Integer &Integer::operator=(const Record &someRecord)
{
(Record&)*this=someRecord;
return *this;
}
inline
BOOL Integer::operator==(const Integer &someInteger)const
{
return (format()==someInteger.format()&&
column()==someInteger.column()&&
row()==someInteger.row()&&
integer()==someInteger.integer()&&
(Record&)*this==(Record&)someInteger);
}
inline
Integer::operator String(void)const
{
String strString;
::sprintf(strString,"%d",integer());
return strString;
}
inline
char *Integer::catstr(char *pString)
{
::sprintf(pString,"%d",integer());
while(*pString)pString++;
return pString;
}
inline
BYTE Integer::format(void)const
{
return mFormat;
}
inline
void Integer::format(BYTE format)
{
mFormat=format;
}
inline
WORD Integer::column(void)const
{
return mColumn;
}
inline
void Integer::column(WORD column)
{
mColumn=column;
}
inline
WORD Integer::row(void)const
{
return mRow;
}
inline
void Integer::row(WORD row)
{
mRow=row;
}
inline
WORD Integer::integer(void)const
{
return mInteger;
}
inline
void Integer::integer(WORD integer)
{
mInteger=integer;
}
#endif