CCfits: CCfits::Table Class Reference

CCfits 2.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Protected Member Functions
CCfits::Table Class Reference

`#include <Table.h>`

Inheritance diagram for CCfits::Table:

List of all members.

## Classes
class | NoSuchColumn
| Exception to be thrown on a failure to retrieve a column specified either by name or index number. More...
## Public Member Functions
| Table (const Table &right)
| copy constructor
virtual | ~Table ()
| destructor
virtual Column & | column (const String &colName, bool caseSensitive=true) const
| return a reference to a Table column specified by name.
virtual Column & | column (int colIndex) const
| return a reference to the column identified by colIndex
virtual const ColMap & | column () const
| return a reference to the multimap containing the columns.
virtual ColMap & | column ()
| return a reference to the multimap containing the columns.
virtual void | copyColumn (const Column &inColumn, int colIndx, bool insertNewCol=true)
| copy a column (from different or same HDU and file) into an existing table HDU.
virtual void | deleteColumn (const String &columnName)
| delete a column in a Table extension by name.
void | deleteRows (long first, long number=1)
| delete a range of rows in a table.
void | deleteRows (const std::vector< long > &rowList)
| delete a set of rows in the table specified by an input array.
virtual long | getRowsize () const
| return the optimal number of rows to read or write at a time
void | insertRows (long first, long number=1)
| insert empty rows into the table
virtual int | numCols () const
| return the number of Columns in the Table (the TFIELDS keyword).
virtual long | rows () const
| return the number of rows in the table (NAXIS2).
void | rows (long numRows)
| set the number of rows in the Table.
void | updateRows ()
| update the number of rows in the table
## Protected Member Functions
| Table (FITS *p, HduType xtype, const String &hduName, int rows, const std::vector< String > &columnName, const std::vector< String > &columnFmt, const std::vector< String > &columnUnit=std::vector< String >(), int version=1)
| Constructor to be used for creating new HDUs.
| Table (FITS *p, int version=1, const String &groupName=String(""))
| Constructor to be called when creating a grouping table.
| Table (FITS *p, HduType xtype, const String &hduName=String(""), int version=1)
| Constructor to be called by operations that read Table specified by hduName and version.
| Table (FITS *p, HduType xtype, int number)
| Table constructor for getting Tables by number.
void | init (bool readFlag=false, const std::vector< String > &keys=std::vector< String >())
void | numCols (int value)
| set the number of Columns in the Table

## Detailed Description

Table is the abstract common interface to Binary and Ascii Table HDUs.

Table is a subclass of ExtHDU that contains an associative array of Column objects. It implements methods for reading and writing columns

## Constructor & Destructor Documentation

CCfits::Table::Table | ( | FITS * | p,
|  | HduType | xtype,
|  | const String & | hduName,
|  | int | rows,
|  | const std::vector< String > & | columnName,
|  | const std::vector< String > & | columnFmt,
|  | const std::vector< String > & | columnUnit = `std::vector<String>()`,
|  | int | version = `1`
| ) |  | `[protected]`

Constructor to be used for creating new HDUs.

Parameters:

  p | The FITS file in which to place the new HDU
  xtype | An HduType enumerator defined in CCfits.h for type of table (AsciiTbl or BinaryTbl)
  hduName | The name of this HDU extension
  rows | The number of rows in the new HDU (the value of the NAXIS2 keyword).
  columnName | a vector of names for the columns.
  columnFmt | the format strings for the columns
  columnUnit | the units for the columns.
  version | a version number

CCfits::Table::Table | ( | FITS * | p,
|  | int | version = `1`,
|  | const String & | groupName = `String("")`
| ) |  | `[protected]`

Constructor to be called when creating a grouping table.

Parameters:

  p | The FITS file in which to place the new HDU
  version | Version number
  groupName | The name of the grouping table

CCfits::Table::Table | ( | FITS * | p,
|  | HduType | xtype,
|  | int | number
| ) |  | `[protected]`

Table constructor for getting Tables by number.

Necessary since EXTNAME is a reserved not required keyword, and users may thus read FITS files without an extension name. Since an HDU is completely specified by extension number, this is part of the public interface.

## Member Function Documentation

Column & CCfits::Table::column | ( | const String & | colName,
|  | bool | caseSensitive = `true`
| ) |  | const`[virtual]`

return a reference to a Table column specified by name.

If the caseSensitive parameter is set to false, the search will be case-insensitive. The overridden base class implementation ExtHDU::column throws an exception, which is thus the action to be taken if self is an image extension

Exceptions:

  WrongExtensionType | see above

Reimplemented from CCfits::ExtHDU.

Column & CCfits::Table::column | ( | int | colIndex | ) | const`[virtual]`

return a reference to the column identified by colIndex

Throws NoSuchColumn if the index is out of range -index must satisfy (1 <= index <= numCols() ).

N.B. the column number is assigned as 1-based, as in FORTRAN rather than 0-based as in C.

Exceptions:

  Table::NoSuchColumn | passes colIndex to the diagnostic message printed when the exception is thrown

Reimplemented from CCfits::ExtHDU.

const ColMap & CCfits::Table::column | ( |  | ) | const`[inline, virtual]`

return a reference to the multimap containing the columns.

This public version might be used to query the size of the column container in a routine that manipulates column table data.

Reimplemented from CCfits::ExtHDU.

ColMap & CCfits::Table::column | ( |  | ) | `[inline, virtual]`

return a reference to the multimap containing the columns.

To be used in the implementation of subclasses.

void CCfits::Table::copyColumn | ( | const Column & | inColumn,
|  | int | colIndx,
|  | bool | insertNewCol = `true`
| ) |  | `[virtual]`

copy a column (from different or same HDU and file) into an existing table HDU.

This is meant to provide the same functionality as CFITSIO's fits_copy_col, and therefore does not work with columns with variable length fields. Copying a column from an AsciiTable to a BinTable is prohibited. colIndx range should be from 1 to nCurrentCols+1 if inserting, or 1 to nCurrentCols if replacing.

Parameters:

  inColumn | The Column object which is to be copied
  colIndx | The position for which the copied Column will be placed (first colIndx = 1).
  insertNewCol | If 'true', new Column will be inserted in or appended to table. If 'false', Column will replace current Column at position = colIndx.

Reimplemented from CCfits::ExtHDU.

void CCfits::Table::deleteColumn | ( | const String & | columnName | ) | `[virtual]`

delete a column in a Table extension by name.

Parameters:

  columnName | The name of the column to be deleted.

Exceptions:

  WrongExtensionType | if extension is an image.

Reimplemented from CCfits::ExtHDU.

void CCfits::Table::deleteRows | ( | long | first,
|  | long | number = `1`
| ) |  |

delete a range of rows in a table.

In both this and the overloaded version which allows a selection of rows to be deleted, the cfitsio library is called first to perform the operation on the disk file, and then the FITS object is updated.

Parameters:

  first | the start row of the range
  number | the number of rows to delete; defaults to 1.

Exceptions:

  FitsError | thrown if the cfitsio call fails to return without error.

void CCfits::Table::deleteRows | ( | const std::vector< long > & | rowlist | ) |

delete a set of rows in the table specified by an input array.

Parameters:

  rowlist | The vector of row numbers to be deleted.

Exceptions:

  FitsError | thrown if the underlying cfitsio call fails to return without error.

long CCfits::Table::getRowsize | ( |  | ) | const`[virtual]`

return the optimal number of rows to read or write at a time

A wrapper for the CFITSIO function fits_get_rowsize, useful for obtaining maximum I/O efficiency. This will throw if it is not called for a Table extension.

Reimplemented from CCfits::ExtHDU.

void CCfits::Table::init | ( | bool | readFlag = `false`,
|  | const std::vector< String > & | keys = `std::vector<String>()`
| ) |  | `[protected]`

"Late Constructor." wrap-up of calls needed to construct a table. Reads header information and sets up the array of column objects in the table.

Protected function, provided to allow the implementation of extensions of the library.

void CCfits::Table::insertRows | ( | long | first,
|  | long | number = `1`
| ) |  |

insert empty rows into the table

Parameters:

  first | the start row of the range
  number | the number of rows to insert.

Exceptions:

  FitsError | thrown if the underlying cfitsio call fails to return without error.

void CCfits::Table::updateRows | ( |  | ) |

update the number of rows in the table

Called to force the Table to reset its internal "rows" attribute. public, but is called when needed internally.

The documentation for this class was generated from the following files:

- Table.h
- Table.cxx