1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
   |  47 bool Parseur::allerSousPartie(string nomSP, int nb)
 48 {
 49     //Placer le curseur au tout début du fichier
 50     fichier.seekg(0, ios::beg);
 51     string tmp;
 52     //Parcourir les lignes jusqu'à trouver '"begin" + nomSP' nb fois
 53     int cpt=0;
 54     bool dansSP = false;
 55     bool continuer = true;
 56     cout << "test2" << endl;
 57     while (continuer);
 58     {   
 59         cout << "test2" << endl;
 60         getline(fichier, tmp);
 61         cout << tmp << endl; 
 62         if (tmp == ("begin " + nomSP) && dansSP == false)
 63         {   
 64             cout << "trouvé!" << endl;
 65             cpt++;
 66             if (cpt == nb)
 67             {   
 68                 ligneDebut.push_back(fichier.tellg());
 69                 dansSP = true;
 70             }
 71         }
 72         if (tmp == ("end " + nomSP) && dansSP == true)
 73         {   
 74             ligneFin.push_back(fichier.tellg());
 75             compteurSP++;
 76             return true;
 77         }
 78         tmp.clear();
 79         if (fichier.eof())
 80             continuer = false;
 81     }   
 82     return false;
 83 } | 
Partager