next up previous contents
Next: DeleteColumn Up: Column methods Previous: AddElementToColumn

ClearColumn

NAME ClearColumn

PROTOTYPE

#include "SSTable.h"

int SSTable::ClearColumn(int colIndex);

EXAMPLE

#include "SSTable.h"
extern void processTableColumn(SSTable &, int);
...
SSTable * pTable = new SSTable();
ReVarCifArray<CifString> last_column;
CifString cs;

while (tokenizer.hasMoreTokens()) {
  cs = (char *) tokenizer.GetNextToken();
  last_column.Add(cs);
  cs.Clear();
}

pTable->InsertColumn(last_column, "LastColumn",
  pTable->GetNumColumns(), TRUE);

// process the last column
processTableColumn(*pTable, pTable->GetColumnIndex(
  "LastColumn"));

// clear the last column
pTable->ClearColumn(pTable->GetColumnIndex("LastColumn"));

last_column.Clear(); // clean up array and restock with new data
while (tokenizer2.hasMoreTokens()) {
  cs = (char *) tokenizer2.GetNextToken();
  last_column.Add(cs);
  cs.Clear();
}

// fill the column again and reprocess it, since ClearColumn keeps
// the column there (ONLY USE FillColumn here!!! Having a column
// smaller than it was before may lead to undesireable results. See
// "Remarks", below)
pTable->FillColumn(last_column, pTable->GetColumnIndex(
  "LastColumn"));
processTableColumn(*pTable, pTable->GetColumnIndex(
  "LastColumn"));
PURPOSE

ClearColumn erases all of the data in a particular column. It does not remove the column from the table; rather, it keeps placeholders. Thus, the number of columns and rows will not change as a result of this operation.

RECEIVES

colIndex The index of the column to be cleared.

RETURN VALUE

A negative value indicates an error or warning.

REMARKS

This method may be moved to the private section, since it is too easy to misuse. FillColumn is the only method that will refill a column properly after a call to ClearColumn. The proper method for refilling a column is to use DeleteColumn and then any method to add data to a column. The other method is to use RemoveColumn followed by InsertColumn.

See also: DeleteColumn
  RemoveColumn



Olivera Tosic
12/17/1999