Commit 98b5d10c2d5effcaf4fdc1bcaa7a3c75b9b7d53a

Authored by knodlseder
1 parent 097dd38a

add table column access by column number

include/GFitsHDU.hpp
... ... @@ -68,6 +68,7 @@ public:
68 68 GFitsHeader* header(void) const;
69 69 GFitsData* data(void) const;
70 70 GFitsTableCol* column(const std::string& colname) const;
  71 + GFitsTableCol* column(const int& colnum) const;
71 72 void primary(void);
72 73  
73 74 private:
... ...
src/fits/GFitsHDU.cpp
... ... @@ -316,6 +316,40 @@ GFitsTableCol* GFitsHDU::column(const std::string& colname) const
316 316  
317 317  
318 318 /***********************************************************************//**
  319 + * @brief Return pointer to column of table
  320 + *
  321 + * @param[in] colnum Number FITS table column to be returned (starting from 1)
  322 + *
  323 + * If this method is called for an image a 'fits_HDU_not_a_table' exception
  324 + * will be thrown.
  325 + ***************************************************************************/
  326 +GFitsTableCol* GFitsHDU::column(const int& colnum) const
  327 +{
  328 + // Initialise pointer
  329 + GFitsTableCol* ptr = NULL;
  330 +
  331 + // Get pointer to table column
  332 + switch (m_type) {
  333 + case HT_IMAGE: // Image HDU
  334 + throw GException::fits_HDU_not_a_table(G_COLUMN, m_type);
  335 + break;
  336 + case HT_ASCII_TABLE: // ASCII Table HDU
  337 + ptr = ((GFitsAsciiTable*)this->data())->column(colnum);
  338 + break;
  339 + case HT_BIN_TABLE: // Binary Table HDU
  340 + ptr = ((GFitsBinTable*)this->data())->column(colnum);
  341 + break;
  342 + default:
  343 + throw GException::fits_unknown_HDU_type(G_COLUMN, m_type);
  344 + break;
  345 + }
  346 +
  347 + // Return pointer
  348 + return ptr;
  349 +}
  350 +
  351 +
  352 +/***********************************************************************//**
319 353 * @brief Setup minimal primary HDU
320 354 ***************************************************************************/
321 355 void GFitsHDU::primary(void)
... ...