• Page principale
  • Pages associées
  • Modules
  • Classes
  • Fichiers

/tmp/galet/src/parseur.cpp

Aller à la documentation de ce fichier.
00001 // vim:syntax=cpp.doxygen tw=3 sw=3
00002 /***************************************************************************
00003  *   Copyright (C) 2008-2009 by Brice Boyer                                *
00004  *   brice.boyer@ens-lyon.org                                              *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; if not, write to the                         *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00020  ***************************************************************************/
00021 
00029 #include "parseur.h"
00030 #include "graphe.h"
00031 
00032 using namespace std;
00033 
00034 /* outils {{{1 */
00041 entier_type get_number ( noms_type & Noms, const string & nom ) { /*{{{*/
00042    cinfo ( _DEBUG3, true, 3, _debog ) << "On appelle get_number (\n\t" << Noms << "\n\t," << nom << ")\n";
00043    noms_type::iterator la = find ( Noms.begin(), Noms.end(), nom );
00044    entier_type ici =  distance ( Noms.begin(), la );                    // plus moche...
00045    entier_type noms_taille = Noms.size();
00046    if ( ici ==  noms_taille ) {                                         // s'il n'existe pas, on le crée.
00047       Noms.resize ( noms_taille + 1 );
00048       Noms [ noms_taille ] = nom ;
00049    }
00050    cinfo ( _DEBUG3, true, 3, _resul ) << "résultat : " << ici << "\nAvec les noms : \n" << Noms << "\n";
00051    return ici;
00052 } /*}}}*/
00053 
00054 
00061 entier_type get_number ( const noms_type & Noms, const string & nom ) { /*{{{*/
00062    cinfo ( _DEBUG3, true, 3, _debog ) << "On appelle get_number (\n\t" << Noms << "\n\t," << nom << ")\n";
00063    noms_type::const_iterator la = find ( Noms.begin(), Noms.end(), nom );
00064    entier_type ici =  distance ( Noms.begin(), la );              // plus moche...
00065    cinfo ( _DEBUG3, ( ici == Noms.size() ), 3, _erreur ) << "Élément " <<  nom << " devait appartenir à " << Noms << " !\n";
00066    cinfo ( _DEBUG3, true, 3, _resul ) << "résultat : " << ici << "\n";
00067    return ici;
00068 } /*}}}*/
00069 
00070 
00076 void list2vect ( noms_type & titi, const noms_list & toto ) { /*{{{*/
00077    cinfo ( _DEBUG3, true, 3, _debog ) << "liste initiale :\n" << toto << endl;
00078    entier_type taille = toto.size();
00079    titi.resize ( taille );
00080    int i = 0;
00081    for ( noms_list::const_iterator n_it = toto.begin(); n_it != toto.end() ; ++n_it, ++i ) {
00082       titi [ i ] = ( *n_it );
00083    }
00084    cinfo ( _DEBUG3, true, 3, _resul ) << "vecteur final :\n" << titi << "\n";
00085    return;
00086 } /*}}}*/
00087 
00094 void