source: XMLIO_V2/trunk/src/XMLIO/xmlio_exception.hpp @ 68

Last change on this file since 68 was 68, checked in by ymipsl, 14 years ago

ajout trunk xmlioserver
YM

File size: 1.8 KB
Line 
1#ifndef XMLIO_EXCEPTION_HPP
2#define XMLIO_EXCEPTION_HPP
3
4#include <sstream>
5#include "xmlio_std.hpp"
6using namespace std ;
7
8class ex_error
9{
10  public :
11  string what ;
12  ex_error(const string & what_ ) : what(what_) {} ;
13} ;
14
15//class error;
16//ostringstream & operator << (const error & err,char const * str) ;
17//ostringstream & operator << (const error & err,const string & str) ;
18
19
20class error : public ostringstream
21{
22  public :
23   
24    error(const string & where) : ostringstream()
25    {
26      *this<<"*** Error **** in function : "<<where<<endl<<"------> "<<string("toto") ;
27    } ;
28   
29    error(const char * where) : ostringstream()
30    {
31      *this<<"Error in function : "<<where<<endl<<"------> " ;
32    } ;
33
34    ~error()
35    {
36      StdErr<< this->str() <<endl ;
37      throw(ex_error(this->str())) ;
38    } ;
39
40   ostringstream & operator << (char const * str) const
41   {
42     ostringstream * tmp=const_cast <error *>(this) ;
43     *tmp<<str ;
44     return *tmp ;
45   } ;
46
47   ostringstream & operator << (const string& str) const
48   {
49     ostringstream * tmp=const_cast <error *>(this) ;
50     *tmp<<str ;
51     return *tmp ;
52   } ; 
53
54} ;
55
56class warning : public ostringstream
57{
58  public :
59   
60    warning(const string & where) : ostringstream()
61    {
62      *this<<"*** Warning **** in function : "<<where<<endl<<"------> ";
63    } ;
64   
65    warning(const char * where) : ostringstream()
66    {
67      *this<<"Error in function : "<<where<<endl<<"------> " ;
68    } ;
69
70    ~warning()
71    {
72      StdErr<< this->str() <<endl ;
73    } ;
74
75   ostringstream & operator << (char const * str) const
76   {
77     ostringstream * tmp=const_cast <warning *>(this) ;
78     *tmp<<str ;
79     return *tmp ;
80   } ;
81
82   ostringstream & operator << (const string& str) const
83   {
84     ostringstream * tmp=const_cast <warning *>(this) ;
85     *tmp<<str ;
86     return *tmp ;
87   } ; 
88
89} ;
90
91
92#endif
Note: See TracBrowser for help on using the repository browser.