Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/med.git] / src / MEDMEM / MEDMEM_STRING.hxx
1 # ifndef STRING_HXX
2 # define STRING_HXX
3
4 # include <string>
5 //# include <sstream>
6 # include <strstream>
7
8 using namespace std;
9
10 class STRING : public string
11 {
12
13 private :
14   //  ostringstream _s ;
15   ostrstream _s ;
16
17 public :
18   
19   operator  const char * () const {     
20     return const_cast <const char *> (this->c_str()) ;
21   }
22
23   ~STRING()
24   {
25     _s.freeze(false);
26   }
27   
28   STRING() :string() , _s()
29   {
30   }
31
32   template <class T> STRING( const T &valeur ) : string() ,  _s()
33   {
34     _s.freeze(false);
35     _s << valeur ;
36     this->string::operator =( _s.str());  // freeze is true by now
37   }
38
39   template <class T> STRING &operator<<( const T &valeur )
40   {
41     _s.freeze(false);
42     _s << valeur ;
43     this->string::operator = ( _s.str()) ;  // freeze is true by now
44     return *this ;
45   }
46 } ;
47
48 // Exemple d'utilisation avec les exceptions SALOME
49 //      STRING msgErr;
50 //      msgErr << "ESSAI::ESSAI() : This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens ";
51 //      throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ;
52
53 # endif