Files
Work/worksht/LABEL.CPP
2024-08-07 09:16:27 -04:00

38 lines
1.1 KiB
C++

#include <worksht/label.hpp>
bool Label::read(FileIO &inFile)
{
char *pString;
mLabelString.reserve(256,TRUE);
pString=mLabelString;
if(!inFile.read((char*)&mFormat,sizeof(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*)&mFormatPrefix,sizeof(mFormatPrefix)))return false;
while(true)
{
if(!inFile.read(pString))return false;
if(!*pString)break;
pString++;
}
return true;
}
bool Label::write(FileIO &outFile)
{
char strNull[]={'\0'};
type(Record::Label);
length(sizeof(mFormat)+sizeof(mColumn)+sizeof(mRow)+sizeof(mFormatPrefix)+mLabelString.length()+1);
Record::write(outFile);
if(!outFile.write((char*)&mFormat,sizeof(mFormat)))return false;
if(!outFile.write((char*)&mColumn,sizeof(mColumn)))return false;
if(!outFile.write((char*)&mRow,sizeof(mRow)))return false;
if(!outFile.write((char*)&mFormatPrefix,sizeof(mFormatPrefix)))return false;
if(!outFile.write(mLabelString.str(),mLabelString.length()))return false;
if(!outFile.write(strNull,1))return false;
return true;
}