MED fichier
Documentation MED
Guides d'utilisation
Guides de référence
Dev_V3
src
misc
MEDerreur.cxx
Aller à la documentation de ce fichier.
1
/* This file is part of MED.
2
*
3
* COPYRIGHT (C) 1999 - 2016 EDF R&D, CEA/DEN
4
* MED is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* MED is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with MED. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
#include "
MEDerreur.hxx
"
18
19
#include <iostream>
20
#include <sstream>
21
//#include <memory>
22
23
#include <cstdlib>
24
#include <cstring>
25
30
class
OSS
31
{
32
private
:
33
std::ostringstream
oss_
;
34
35
public
:
36
explicit
OSS
() : oss_() {}
37
38
template
<
class
T>
39
OSS
&
operator<<
(T obj)
40
{
41
oss_ << obj;
42
return
*
this
;
43
}
44
45
operator
std::string()
46
{
47
return
oss_.str();
48
}
49
50
// Surtout ne pas écrire le code suivant:
51
// car oss_.str() renvoie une string temporaire
52
// operator const char*()
53
// {
54
// return oss_.str().c_str();
55
// }
56
57
58
};
/* end class OSS */
59
60
61
MEDerreur::~MEDerreur
() throw() {};
62
63
MEDerreur::MEDerreur
(
const
char
*fichier,
64
const
unsigned
int
ligneNo,
65
const
char
* message,
66
const
char
* arg )
67
{
68
OSS
oss ;
69
oss <<
"MEDerreur"
;
70
71
if
( strcmp(fichier,
""
) ) {
72
oss <<
" dans le fichier "
<< fichier;
73
74
if
( ligneNo) oss <<
"["
<< ligneNo <<
"]"
;
75
}
76
77
oss <<
" : "
<< message;
78
79
_what
= oss;
80
}
81
82
const
char
*
MEDerreur::what
(
void
)
const
throw ()
83
{
84
return
_what
.c_str();
85
}
86
87
OSS::operator<<
OSS & operator<<(T obj)
Definition:
MEDerreur.cxx:39
MEDerreur::_what
std::string _what
Definition:
MEDerreur.hxx:39
OSS::OSS
OSS()
Definition:
MEDerreur.cxx:36
MEDerreur::what
virtual const char * what(void) const
Definition:
MEDerreur.cxx:82
MEDerreur::MEDerreur
MEDerreur(const char *fichier="", const unsigned int ligneNo=0, const char *message="", const char *arg="")
Definition:
MEDerreur.cxx:63
MEDerreur::~MEDerreur
virtual ~MEDerreur(void)
Definition:
MEDerreur.cxx:61
OSS::oss_
std::ostringstream oss_
Definition:
MEDerreur.cxx:33
OSS
Definition:
MEDerreur.cxx:30
MEDerreur.hxx
Généré le Lundi 7 Novembre 2016 14:19:23 pour MED fichier par
1.8.9.1