RCSB PDB Protein Data Bank A Member of the wwPDB
An Information Portal to Biological Macromolecular Structures
PDB Home | Contact Us
next up previous contents
Next: Merge Up: General Methods Previous: GetColumnNames

GetColumnIndex

NAME GetColumnIndex

PROTOTYPE

#include "ISTable.h"

int ISTable::GetColumnIndex(const char * columnName);

EXAMPLE

#include <string.h>
#include <stdlib.h>
#include "ISTable.h"
extern char ** ConvertRVCACifString(ReVarCifArray<CifString>*);

ISTable * pTable = new ISTable("MyTable");

... // add some columns and stuff

ReVarCifArray<CifString> * cifarray = pTable->GetColumnNames();
char ** colNames = ConvertRVCACifString(cifarray);

// sort the names
qsort(colNames, pTable->GetNumColumns(), sizeof(char *), strcmp);

// do something to each column, alphabetically
for (int i = 0; i < pTable->GetNumColumns(); i++) {
  int index = pTable->GetColumnIndex(colNames[i]);
  ...
}
PURPOSE

GetColumnIndex returns the index of the column with the given name.

RECEIVES

columnName The name of the column.

RETURN VALUE

An integer representing the position of the column in the table. For example, an index of 0 represents the 1st column.
A negative value means that an error has occured, i.e. the column with the specified name was not found in the table.

REMARKS

None  



Olivera Tosic
6/12/2002

 

© RCSB PDB