Changeset 3097 for trunk


Ignore:
Timestamp:
03/29/16 19:56:26 (9 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Bug fix on string handling in NRO data filler. Remove trailing null character ('\0').

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/atnf/PKSIO/NROReader.cc

    r3066 r3097  
    5656
    5757using namespace std ;
     58
     59namespace {
     60// to limit template argument to specified type
     61template<class T>
     62constexpr inline bool type_guard() {
     63  return false;
     64}
     65template<>
     66constexpr inline bool type_guard<string>() {
     67  return true;
     68}
     69template<>
     70constexpr inline bool type_guard<String>() {
     71  return true;
     72}
     73
     74// T must be std::string or casa::String
     75template<class T>
     76inline String trim_nro_string(T const &s) {
     77  static_assert(type_guard<T>(), "");
     78  return s.substr(0, s.find_first_of('\0'));
     79}
     80}
    5881
    5982//
     
    469492  npol = getPolarizationNum() ;
    470493  //cout << "npol = " << npol << endl ;
    471   observer = dataset_->getOBSVR() ;
    472   //cout << "observer = " << observer << endl ;
    473   project = dataset_->getPROJ() ;
    474   //cout << "project = " << project << endl ;
    475   obstype = dataset_->getSWMOD() ;
    476   //cout << "obstype = " << obstype << endl ;
    477   antname = dataset_->getSITE() ;
    478   //cout << "antname = " << antname << endl ;
     494  observer = trim_nro_string(dataset_->getOBSVR()) ;
     495  //cout << "observer = \"" << observer << "\" (size " << observer.size() << ")" << endl ;
     496  project = trim_nro_string(dataset_->getPROJ()) ;
     497  //cout << "project = \"" << project << "\" (size " << project.size() << ")" << endl ;
     498  obstype = trim_nro_string(dataset_->getSWMOD()) ;
     499  //cout << "obstype = \"" << obstype << "\" (size " << obstype.size() << ")" << endl ;
     500  antname = trim_nro_string(dataset_->getSITE()) ;
     501  //cout << "antname = \"" << antname << "\" (size " << antname.size() << ")" << endl ;
    479502  // TODO: should be investigated antenna position since there are
    480503  //       no corresponding information in the header
     
    514537  //freqref = "LSRK" ;
    515538  //freqref = "REST" ;
    516   freqref = freqRefFromVREF_ ? vref : "REST" ;
    517   //cout << "freqref = " << freqref << endl ;
     539  freqref = freqRefFromVREF_ ? trim_nro_string(vref) : "REST" ;
     540  //cout << "freqref = \"" << freqref << "\" (size " << freqref.size() << ")" << endl ;
    518541  const NRODataRecord *record = dataset_->getRecord( 0 ) ;
    519542  reffreq = record->FREQ0 ; // rest frequency
     
    528551  epoch = "UTC" ; 
    529552  //cout << "epoch = " << epoch << endl ;
    530   string poltp = dataset_->getPOLTP()[0] ;
    531   //cout << "poltp = '" << poltp << "'" << endl ;
     553  string poltp = trim_nro_string(dataset_->getPOLTP()[0]) ;
     554  //cout << "poltp = \"" << poltp << "\" (size " << poltp.size() << ")" << endl ;
    532555  if ( poltp.empty() || poltp[0] == ' ' || poltp[0] == '\0' )
    533556    //poltp = "None" ;
     
    660683
    661684  // srcname
    662   srcname = String( dataset_->getOBJ() ) ;
    663   //cout << "srcname = " << srcname << endl ;
     685  srcname = trim_nro_string( dataset_->getOBJ() ) ;
     686  //cout << "srcname = \"" << srcname << "\" (size " << srcname.size() << ")" << endl ;
    664687
    665688  // fieldname
    666   fieldname = String( dataset_->getOBJ() ) ;
    667   //cout << "fieldname = " << fieldname << endl ;
     689  fieldname = trim_nro_string( dataset_->getOBJ() ) ;
     690  //cout << "fieldname = \"" << fieldname << "\" (size " << fieldname.size() << ")" << endl ;
    668691
    669692  // spectra
Note: See TracChangeset for help on using the changeset viewer.