TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Ouvrir_fichier.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15#include <Ouvrir_fichier.h>
16
17// reset : mode d'ecriture en append ou en out.
18// suffix : fichier nomme nom_du_cas()+suffix
19// msg : message a imprimer
20// head : Si (reset=1), ios::out, on cree une entete : "# "+message+\n
21SFichier Ouvrir_fichier(const Nom& suffix,
22 const Nom& head,
23 const int reset,
24 const int prec)
25{
27 s+= suffix;
28 IOS_OPEN_MODE mode = (reset) ? ios::out : ios::app;
29 SFichier fic;
30 fic.ouvrir(s,mode);
31 if (reset)
32 fic << "# " << head << finl;
33 fic.setf(ios::scientific);
34 fic.precision(prec);
35 //fic << msg;
36 return fic;
37}
38
39SFichier Open_file_folder(const Nom& folder,
40 const Nom& suffix,
41 const Nom& head,
42 const int reset,
43 const int sep,
44 const int prec)
45{
46
47 Nom s(folder);
48 if (sep)
49 s+= "/";
51 s+= suffix;
52 IOS_OPEN_MODE mode = (reset) ? ios::out : ios::app;
53 SFichier fic;
54 fic.ouvrir(s,mode);
55 if (reset)
56 fic << "# " << head << finl;
57 fic.setf(ios::scientific);
58 fic.precision(prec);
59 //fic << msg;
60 return fic;
61}
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
Definition Objet_U.cpp:145
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
void precision(int pre) override
void setf(IOS_FORMAT code) override