|
rllib
1
|
#include <rlspreadsheet.h>

Public Member Functions | |
| rlSpreadsheetRow () | |
| column = 1...N | |
| virtual | ~rlSpreadsheetRow () |
| const char * | text (int column) |
| void | setText (int column, const char *text) |
| int | printf (int column, const char *format,...) |
| void | clear () |
| void | setNextRow (rlSpreadsheetRow *next) |
| rlSpreadsheetRow * | getNextRow () |
| rlSpreadsheetCell * | getFirstCell () |
| void | readRow (const unsigned char *line, char delimitor='\t') |
| void | writeRow (void *fp, char delimitor='\t') |
| int | exists (int column) |
Private Attributes | |
| rlSpreadsheetCell * | firstCell |
| rlSpreadsheetRow * | nextRow |
A row within a spreadsheet.
Definition at line 44 of file rlspreadsheet.h.
| rlSpreadsheetRow::rlSpreadsheetRow | ( | ) |
column = 1...N
Definition at line 97 of file rlspreadsheet.cpp.
| rlSpreadsheetRow::~rlSpreadsheetRow | ( | ) | [virtual] |
Definition at line 103 of file rlspreadsheet.cpp.
{
rlSpreadsheetCell *item,*last;
item = firstCell;
while(item != NULL)
{
last = item;
item = item->getNextCell();
if(item != last) delete last;
}
}
| void rlSpreadsheetRow::clear | ( | ) |
Definition at line 161 of file rlspreadsheet.cpp.
{
rlSpreadsheetCell *item;
item = firstCell;
while(item != NULL)
{
item->clear();
item = item->getNextCell();
}
}
| int rlSpreadsheetRow::exists | ( | int | column | ) |
Definition at line 237 of file rlspreadsheet.cpp.
{
rlSpreadsheetCell *item;
int c;
c = 1;
item = firstCell;
while(item != NULL)
{
if(c == column) return 1;
c++;
item = item->getNextCell();
}
return 0;
}
| rlSpreadsheetCell * rlSpreadsheetRow::getFirstCell | ( | ) |
Definition at line 183 of file rlspreadsheet.cpp.
{
return firstCell;
}
| rlSpreadsheetRow * rlSpreadsheetRow::getNextRow | ( | ) |
Definition at line 178 of file rlspreadsheet.cpp.
{
return nextRow;
}
| int rlSpreadsheetRow::printf | ( | int | column, |
| const char * | format, | ||
| ... | |||
| ) |
Definition at line 148 of file rlspreadsheet.cpp.
{
int ret;
char buf[rl_PRINTF_LENGTH_SPREADSHEET]; // should be big enough
va_list ap;
va_start(ap,format);
ret = rlvsnprintf(buf, rl_PRINTF_LENGTH_SPREADSHEET - 1, format, ap);
va_end(ap);
setText(column,buf);
return ret;
}
| void rlSpreadsheetRow::readRow | ( | const unsigned char * | line, |
| char | delimitor = '\t' |
||
| ) |
Definition at line 188 of file rlspreadsheet.cpp.
{
int i,tab1,tab2,col;
unsigned char *celltext;
clear();
tab1 = tab2 = -1;
col = 1;
i = 0;
while(line[i] != '\0')
{
if(line[i] == delimitor || line[i] == '\n' || line[i] == 0x0d) // normally delimitor='\t'
{
tab1 = tab2;
tab2 = i;
celltext = new unsigned char[tab2-tab1+1];
if(tab2 > tab1)
{
strncpy((char *) celltext,(const char *) &line[tab1+1],tab2-tab1);
celltext[tab2-tab1-1] = '\0';
}
else
{
celltext[0] = '\0';
}
setText(col++, (char *) celltext);
delete [] celltext;
}
i++;
}
return;
}
| void rlSpreadsheetRow::setNextRow | ( | rlSpreadsheetRow * | next | ) |
Definition at line 173 of file rlspreadsheet.cpp.
{
nextRow = next;
}
| void rlSpreadsheetRow::setText | ( | int | column, |
| const char * | text | ||
| ) |
Definition at line 130 of file rlspreadsheet.cpp.
{
int c = 1;
rlSpreadsheetCell *item;
if(column < 1) return;
if(firstCell == NULL) firstCell = new rlSpreadsheetCell;
item = firstCell;
while(1)
{
if(c == column) { item->setText(text); return; }
if(item->getNextCell() == NULL) item->setNextCell(new rlSpreadsheetCell);
item = item->getNextCell();
c++;
}
}
| const char * rlSpreadsheetRow::text | ( | int | column | ) |
Definition at line 115 of file rlspreadsheet.cpp.
{
int c = 1;
rlSpreadsheetCell *item;
item = firstCell;
while(item != NULL)
{
if(c == column) return item->text();
item = item->getNextCell();
c++;
}
return null_string;
}
| void rlSpreadsheetRow::writeRow | ( | void * | fp, |
| char | delimitor = '\t' |
||
| ) |
Definition at line 223 of file rlspreadsheet.cpp.
{
rlSpreadsheetCell *cell;
if(fp == NULL) return;
cell = firstCell;
while(cell != NULL)
{
fprintf((FILE *) fp,"%s",cell->text());
cell = cell->getNextCell();
if(cell != NULL) fprintf((FILE *) fp, "%c", delimitor);
}
fprintf((FILE *) fp,"\n");
}
rlSpreadsheetCell* rlSpreadsheetRow::firstCell [private] |
Definition at line 61 of file rlspreadsheet.h.
rlSpreadsheetRow* rlSpreadsheetRow::nextRow [private] |
Definition at line 62 of file rlspreadsheet.h.
1.7.5.1