151 lines
6.2 KiB
C++
151 lines
6.2 KiB
C++
// This file is part of the Herezh++ application.
|
|
//
|
|
// The finite element software Herezh++ is dedicated to the field
|
|
// of mechanics for large transformations of solid structures.
|
|
// It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600)
|
|
// INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) <https://www.irdl.fr/>.
|
|
//
|
|
// Herezh++ is distributed under GPL 3 license ou ultérieure.
|
|
//
|
|
// Copyright (C) 1997-2021 Université Bretagne Sud (France)
|
|
// AUTHOR : Gérard Rio
|
|
// E-MAIL : gerardrio56@free.fr
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License,
|
|
// or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
// See the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
//
|
|
// For more information, please consult: <https://herezh.irdl.fr/>.
|
|
|
|
/************************************************************************
|
|
* DATE: 04/01/2007 *
|
|
* $ *
|
|
* AUTEUR: G RIO (mailto:gerardrio56@free.fr) *
|
|
* $ *
|
|
* PROJET: Herezh++ *
|
|
* $ *
|
|
************************************************************************
|
|
* BUT: création d'un conteneur map stl, qui comporte en plus *
|
|
* une surcharge de lecture écriture. *
|
|
* $ *
|
|
* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' *
|
|
************************************************************************/
|
|
#ifndef MAP_IO_H
|
|
#define MAP_IO_H
|
|
|
|
#include <iostream>
|
|
#include <stdlib.h>
|
|
#include <map>
|
|
#include <iomanip>
|
|
#include "Sortie.h"
|
|
#include "ParaGlob.h"
|
|
using namespace std; //introduces namespace std
|
|
|
|
//------------------------------------------------------------------
|
|
//! Map_io classe template de type map STL avec une lecture et écriture
|
|
//------------------------------------------------------------------
|
|
/// \author Gérard Rio
|
|
/// \version 1.0
|
|
/// \date 04/01/2007
|
|
|
|
template <class T>
|
|
class Map_io : public map<T>
|
|
{ // surcharge de l'operator de lecture
|
|
friend istream & operator >> (istream & entree, Map_io<T> & )
|
|
{ // du au pb de lecture de pointeur
|
|
cout << "\n erreur dans la lecture d'une Map_io, la methode n'est pas utilisable en template "
|
|
<< "\n friend istream & operator >> (... ";
|
|
Sortie(1);
|
|
return entree;
|
|
}
|
|
// --- information pour créer un programme de lecture cohérent avec l'écriture ----
|
|
// exemple de surcharge de l'operator de lecture
|
|
// friend istream & operator >> (istream & entree, Map_io& a)
|
|
// { string nom; entree >> nom;
|
|
// #ifdef MISE_AU_POINT
|
|
// if (nom != "debut_Map_IO=")
|
|
// { cout << "\n erreur dans la lecture d'une Map_io, on ne trouve pas le mot cle: debut_Map_IO= "
|
|
// << "\n friend istream & operator >> (... ";
|
|
// Sortie(1);
|
|
// }
|
|
// #endif
|
|
// int taille;entree >> taille; // lecture de la taille
|
|
// T un_elem;
|
|
// for (int i=1;i<=taille;i++)
|
|
// { entree >> un_elem; // lecture
|
|
// a.push_back(un_elem); // enregistrement
|
|
// }
|
|
// return entree;
|
|
// }
|
|
// fin --- information pour créer un programme de lecture cohérent avec l'écriture ----
|
|
|
|
// surcharge de l'operator d'ecriture
|
|
friend ostream & operator << (ostream & sort, const Map_io<T> & a)
|
|
{ // tout d'abord un indicateur donnant le type
|
|
sort << "\n debut_Map_IO= " << "(taille= " << a.size() << " ) ";
|
|
typename Map_io<T>::const_iterator iter_courant,iter_fin;
|
|
iter_fin = a.end();
|
|
for (iter_courant=a.begin();iter_courant!=iter_fin;iter_courant++)
|
|
{ sort << setprecision(ParaGlob::NbdigdoCA()) << (*iter_courant) ; sort << " "; }
|
|
sort << "\n";
|
|
return sort;
|
|
}
|
|
|
|
public:
|
|
// on définit également une opération de lecture et d'écriture pour
|
|
// les itérators, ce qui permettera de créer des tableaux d'iterator
|
|
// surcharge de l'operator de lecture, a priori pas utile
|
|
friend istream & operator >> (istream & entree, typename map<T>::iterator& )
|
|
{ cout << "erreur, cette surcharge ne doit pas être utilisée "
|
|
<< "Map_io::iterator, operator << \n";
|
|
Sortie(1);
|
|
return entree;
|
|
}
|
|
// surcharge de l'operator d'ecriture, a priori pas utile
|
|
friend ostream & operator << (ostream & sort, const typename map<T>::iterator )
|
|
{ cout << "erreur, cette surcharge ne doit pas être utilisée "
|
|
<< "Map_io::iterator, operator >> \n";
|
|
Sortie(1);
|
|
return sort;
|
|
}
|
|
|
|
// surcharge de l'operator de lecture, a priori pas utile
|
|
friend istream & operator >> (istream & entree, typename map<T>::const_iterator& )
|
|
{ cout << "erreur, cette surcharge ne doit pas être utilisée "
|
|
<< "Map_io::const_iterator, operator << \n";
|
|
Sortie(1);
|
|
return entree;
|
|
}
|
|
// surcharge de l'operator d'ecriture, a priori pas utile
|
|
friend ostream & operator << (ostream & sort, const typename map<T>::const_iterator& )
|
|
{ cout << "erreur, cette surcharge ne doit pas être utilisée "
|
|
<< "Map_io::const_iterator_io, operator >> \n";
|
|
Sortie(1);
|
|
return sort;
|
|
}
|
|
|
|
public :
|
|
// CONSTRUCTEURS :
|
|
|
|
// DESTRUCTEUR :
|
|
// METHODES PUBLIQUES :
|
|
|
|
private :
|
|
// VARIABLES PROTEGEES :
|
|
// CONSTRUCTEURS :
|
|
// DESTRUCTEUR :
|
|
// METHODES PROTEGEES :
|
|
|
|
};
|
|
|
|
|
|
#endif
|