Ignore:
Timestamp:
Nov 18, 2005, 6:44:57 PM (20 years ago)
Author:
ansari
Message:

debut modifs nouveau fits pour support I/O chaines de caracteres - Reza 18/11/2005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/fitsblkrw.h

    r2820 r2843  
    114114};
    115115
     116
     117/*!
     118  Write character string data to binary/ascii HDU data in a fits file.
     119  See cfitsio function fits_write_col() for more detail.
     120  \param colnum : table column number (starting from 1)
     121  \param firstrow : the write operation starting row (starting from 1)
     122  \param firstelem : the firstelem (for vector type columns)
     123  \param d : pointer to string type array to be written
     124  \param sz : number of data elements to be written
     125  \param width : column width
     126*/
     127void WriteStringColumnData(FitsInOutFile& fios, int colnum, long firstrow,
     128                           long firstelem, const string * d, size_t sz,
     129                           long width=0)
     130{
     131  int status = 0;
     132  if (width < 1) width = 16;
     133  for(size_t kk=0; kk<sz; kk++) {
     134    char * cp = const_cast<char *>(d[kk].c_str());
     135    status = 0;
     136    fits_write_col(fios.FitsPtr(), FitsTypes::DataType(cp), colnum,
     137                   firstrow+kk, firstelem, 1, &cp, &status);
     138    if ( status ) {
     139      fits_report_error(stderr, status);
     140      char buff[32];
     141      fits_get_errstatus(status, buff);
     142      string msg = "WriteStringColumnData Error: " ;
     143      msg += buff;
     144      sprintf(buff," kk=%ld",kk);  msg += buff;
     145      throw FitsIOException(msg);
     146    }
     147  }
     148  return;
     149}
     150
     151/*!
     152  Read character string data to binary/ascii HDU data in a fits file.
     153  See cfitsio function fits_read_col() for more detail.
     154  \param colnum : table column number (starting from 1)
     155  \param firstrow : the read operation starting point (row) (starting from 1)
     156  \param firstelem : the firstelem (for vector type columns)
     157  \param d : pointer to string type array to be read
     158  \param sz : number of data elements to be read
     159  \param width : column width
     160*/
     161void ReadStringColumnData(FitsInOutFile& fios, int colnum, long firstrow,
     162                          long firstelem, string * d, size_t sz, long width)
     163{
     164  int status = 0;
     165  int anynul = 0;
     166  char buff[1024];
     167  for(size_t kk=0; kk<sz; kk++) {
     168    fits_read_col(fios.FitsPtr(), FitsTypes::DataType(buff), colnum,
     169                 firstrow, firstelem+kk, 1, NULL, &buff, &anynul, &status);
     170    d[kk] = buff;
     171    if ( status ) {
     172      fits_report_error(stderr, status);
     173      char buff[32];
     174      fits_get_errstatus(status, buff);
     175      string msg = "ReadStringColumnData Error: " ;
     176      msg += buff;
     177      sprintf(buff," kk=%ld",kk);  msg += buff;
     178      throw FitsIOException(msg);
     179    }
     180  }
     181  return;
     182}
     183
    116184} // Fin du namespace
    117185
Note: See TracChangeset for help on using the changeset viewer.