Changeset 2962 in Sophya


Ignore:
Timestamp:
Jun 2, 2006, 1:23:46 PM (19 years ago)
Author:
ansari
Message:

Ajout methode BaseDataTable::CheckCorrectColName() pour correction des noms de colonnes (pour lecture FITS en particulier), Reza 2/6/2006

Location:
trunk/SophyaLib/HiStats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/HiStats/basedtable.cc

    r2891 r2962  
    179179}
    180180
     181//! Check the validity of column name \b cnom - throw exception.
    181182bool BaseDataTable::CheckColName(string const & cnom)
    182183{
     
    194195      throw ParmError("BaseDataTable::CheckColName() already existing name");
    195196  return true;
     197}
     198
     199/*!
     200  \brief Check  the validity of column name \b cnom and correct it if necessary
     201  return true if \b cnom has been changed
     202*/
     203bool BaseDataTable::CheckCorrectColName(string& cnom)
     204{
     205  size_t l,k;
     206  l = cnom.length();
     207  string ssn;
     208  MuTyV mvv = (NCols()+1);
     209  mvv.Convert(ssn);
     210  bool fgrc = false;
     211  if (l < 1) { cnom = "C"+ssn;   fgrc = true; }
     212  if (!isalpha(cnom[0]))  { cnom = "C"+cnom;  fgrc = true; }
     213  for(k=1; k<l; k++)
     214    if ((!isalnum(cnom[k])) && (cnom[k] != '_'))  {
     215      cnom[k] = '_';  fgrc = true;
     216    }
     217  bool fgdouble = true;
     218  while (fgdouble) {
     219    fgdouble = false;
     220    for(k=0; k<mNames.size(); k++)
     221      if (cnom == mNames[k].nom) {
     222        fgdouble = true;  break;
     223      }
     224    if (fgdouble) { cnom = cnom+ssn; fgrc = true; }
     225  }
     226  return fgrc;
    196227}
    197228
  • trunk/SophyaLib/HiStats/basedtable.h

    r2851 r2962  
    144144  // si nom en double ou non valide
    145145  virtual bool      CheckColName(string const & cnom);
     146  // Verifie et corrige si besoin un nom de colonne
     147  virtual bool      CheckCorrectColName(string & cnom);
    146148
    147149  // Acces to various counts and parameters
Note: See TracChangeset for help on using the changeset viewer.