Back to index

salome-med  6.5.0
MEDMEM_STRING.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 # ifndef MEDMEM_STRING_HXX
00024 # define MEDMEM_STRING_HXX
00025 
00026 #include "MEDMEM.hxx"
00027 
00028 using namespace std;
00029 
00030 # include <string>
00031 # include <sstream>
00032 
00041 namespace MEDMEM {
00042   class MEDMEM_EXPORT STRING : public string
00043   {
00044 
00045   private :
00046     ostringstream _s ;
00047 
00048   public :
00049   
00050     STRING() :string(), _s() 
00051     {
00052     }
00053     STRING(const STRING& s) :string(s)
00054     {
00055       _s << s ;
00056       this->string::operator =( s );
00057     }
00058     STRING& operator= (const STRING& s)
00059     {
00060       _s.str("");
00061       _s << s ;
00062 
00063       this->string::operator = ( _s.str() ) ;  // freeze is true by now
00064 
00065       return *this ;
00066     }
00067 
00068     ~STRING()
00069     {
00070     }
00071 
00072     operator const char * () const 
00073     {
00074       // return const_cast <const char *> (this->c_str()) ;
00075       return this->c_str();
00076     }
00077 
00078     template <class T> STRING( const T &valeur ) : string(), _s() 
00079     {
00080       _s << valeur ;
00081 
00082       this->string::operator =( _s.str());
00083     }
00084 
00085     template <class T> STRING & operator<<( const T &valeur )
00086     {
00087       _s << valeur ;
00088 
00089       this->string::operator = ( _s.str() ) ;  // freeze is true by now
00090 
00091       return *this ;
00092     }
00093   } ;
00094 } 
00095 
00096 # endif