Changeset 2286 in Sophya for trunk/SophyaLib/TArray/utilarr.cc


Ignore:
Timestamp:
Dec 5, 2002, 12:15:55 PM (23 years ago)
Author:
ansari
Message:

Correction lecture tableaux en ASCII - Reza 5/12/02

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/utilarr.cc

    r2149 r2286  
    195195/*!
    196196  \param str : string to be decoded
    197   \param nbad : number of unmatched quotes or parenthesis
     197  \param nbad : number of unmatched quotes or parenthesis (returned value)
     198  \param sep : word separator in string. Each word is decoded as a MuTyV value.
    198199  \return the number of added elements.
    199200*/
    200 sa_size_t EnumeratedSequence::Append(string const & str, int& nbad)
     201sa_size_t EnumeratedSequence::Append(string const & str, int& nbad, const char* sep)
    201202{
    202203  nbad = 0;
     
    204205  size_t l = str.length();
    205206  if (l < 1) return(0);
    206   if ((str[0] == '#') || (str[0] == '*')) return(0);
     207  //  if ((str[0] == '#') || (str[0] == '*')) return(0);
    207208  size_t q = 0;
    208   size_t p = str.find_first_not_of(" \t");
     209  size_t p = 0;
     210  /*
     211  size_t p = str.find_first_not_of(sep);
    209212  if ((str[p] == '+') || (str[p] == '-')) {
    210213    if (p == l-1)  return(0);
     
    212215  }
    213216  else if (!isdigit(str[p]) && (str[p] != '\'') && (str[p] != '(') ) return(0);
    214 
     217  */
    215218  while(q < l) {
    216     p = str.find_first_not_of(" \t",q);
     219    p = str.find_first_not_of(sep,q);
    217220    if (p >= l)  break;
    218221    if (str[p] == '\'')    {  // Decodage d'un string
     
    236239    }
    237240    else {
    238       q = str.find_first_of(" \t",p);
     241      q = str.find_first_of(sep,p);
    239242      if (!isdigit(str[p]) && !(str[p] == '+') && !(str[p] == '-') ) { // une chaine
    240         continue;
     243        vecv_.push_back(MuTyV(str.substr(p,q-p)));
    241244      }
    242245      else {  // C'est un nombre
     
    260263    \param nr : Number of non empty (or comment) lines in stream (return value)
    261264    \param nc : Number of columns (= ntot/nlines) (return value)
     265    \param clm : Lines starting with clm character are treated as comment lines
     266    \param sep : word separator in lines
    262267    \return Number of decoded elements
    263268*/
    264 sa_size_t EnumeratedSequence::FillFromFile(istream& is,
    265                                            sa_size_t& nr, sa_size_t& nc)
     269sa_size_t EnumeratedSequence::FillFromFile(istream& is, sa_size_t& nr, sa_size_t& nc,
     270                                           char clm, const char* sep)
    266271{
    267272  nr = 0;
     
    278283    line += buff;
    279284    if (is.good()) {
    280       nel = Append(line, nbad);
    281       //      cout << " Decoding line = " << line << " Nel= " << nel << endl;
    282       if (nel > 0)  {
    283         nr++;  n += nel;
    284       }
    285       nbadtot += nbad;
     285      if ((line.length() > 0) && (line[0]!=clm)) {
     286        nel = Append(line, nbad);
     287        if (nel > 0)  {
     288          nr++;  n += nel;
     289        }
     290        nbadtot += nbad;
     291      }
     292              cout << " Decoding line = " << line << " Nel= " << nel << endl;
    286293      line = "";
    287294    }
    288295  }
    289   if (line.length() > 0) {
     296  if ((line.length() > 0) && (line[0]!=clm)) {
    290297    nel = Append(line, nbad);
    291     //    cout << " Decoding Eline = " << line << " Nel= " << nel << endl;
     298        cout << " Decoding Eline = " << line << " Nel= " << nel << endl;
    292299    if (nel > 0)  {
    293300      nr++;  n += nel;
Note: See TracChangeset for help on using the changeset viewer.