Herezh_dev/herezh_pp/Enumeration/EnumFonction_nD.cc

126 lines
4 KiB
C++
Executable file

// FICHIER : EnumFonction_nD.cp
// 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/>.
#include "EnumFonction_nD.h"
# include <iostream>
using namespace std; //introduces namespace std
#include <stdlib.h>
#include "Sortie.h"
#if defined SYSTEM_MAC_OS_CARBON
#include <stringfwd.h> // a priori ce n'est pas portable
#else
#include <string.h> // pour le flot en memoire centrale
#endif
#include <string>
string Nom_Fonction_nD (EnumFonction_nD id_Fonction_nD)
// Retourne le nom de la Fonction_nD correspondant a l'identificateur
// de type enumere id_Fonction_nD
{
string result;
switch (id_Fonction_nD)
{
case FONCTION_EXPRESSION_LITTERALE_nD :result="FONCTION_EXPRESSION_LITTERALE_nD";break;
case FONCTION_COURBE1D :result="FONCTION_COURBE1D";break;
case FONC_SCAL_COMBINEES_ND : result="FONC_SCAL_COMBINEES_ND";break;
case FONCTION_EXTERNE_ND : result="FONCTION_EXTERNE_ND";break;
case AUCUNE_FONCTION_nD :result="AUCUNE_FONCTION_nD";break;
default :
cout << "\nErreur : valeur incorrecte du type EnumFonction_nD !\n";
cout << "Nom_Fonction_nD(EnumFonction_nD ) \n";
Sortie(1);
};
return result;
};
EnumFonction_nD Id_Nom_Fonction_nD (const string& nom_Fonction_nD)
// Retourne la variable de type enumere associee au nom de la Fonction_nD
{
EnumFonction_nD result;
if ( nom_Fonction_nD == "FONCTION_EXPRESSION_LITTERALE_nD" )
result=FONCTION_EXPRESSION_LITTERALE_nD;
else if ( nom_Fonction_nD == "FONCTION_COURBE1D" )
result=FONCTION_COURBE1D;
else if ( nom_Fonction_nD == "FONC_SCAL_COMBINEES_ND")
result = FONC_SCAL_COMBINEES_ND;
else if ( nom_Fonction_nD == "FONCTION_EXTERNE_ND")
result = FONCTION_EXTERNE_ND;
else if ( nom_Fonction_nD == "AUCUNE_FONCTION_nD" )
result=AUCUNE_FONCTION_nD;
else
{
cout << "\nErreur : nom de la Fonction_nD inconnu !: " << nom_Fonction_nD << "\n";
cout << "Id_Nom_Fonction_nD (string nom_Fonction_nD) \n";
Sortie(1);
};
return result;
};
// Retourne vrai si le nom passé en argument représente un type de Fonction_nD reconnu
// sinon false
bool Type_EnumFonction_nD_existe(const string& nom)
{ bool result;
if ( nom == "FONCTION_EXPRESSION_LITTERALE_nD") result=true;
else if ( nom == "FONCTION_COURBE1D") result=true;
else if ( nom == "FONC_SCAL_COMBINEES_ND") result = true;
else if ( nom == "FONCTION_EXTERNE_ND") result = true;
else if ( nom == "AUCUNE_FONCTION_nD") result=true;
else result = false;
return result;
};
// surcharge de l'operator de lecture
istream & operator >> (istream & entree, EnumFonction_nD& a)
{ string nom_EnumFonction_nD;
entree >> nom_EnumFonction_nD;
a = Id_Nom_Fonction_nD ( nom_EnumFonction_nD);
return entree;
};
// surcharge de l'operator d'ecriture
ostream & operator << (ostream & sort, const EnumFonction_nD& a)
{ // on ecrit la forme caractère
sort << Nom_Fonction_nD(a) << " ";
return sort;
};