ximol/error.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002  *                                                                           *
00003  * library XiMoL                                                             *
00004  * Copyright (C) 2002, 2003, 2004 Florent Tournois                           *
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, or (at your option) any later version.        *
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 \*****************************************************************************/
00021 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022 /** \file 
00023         \brief GetFrom and PutTo operator for common char and xchar_t (Implementation).
00024 
00025     \author Tournois Florent
00026         \version 1.0
00027 
00028     $Id: error.cpp,v 1.11 2004/03/03 22:05:30 tournois Exp $
00029     $Log: error.cpp,v $
00030     Revision 1.11  2004/03/03 22:05:30  tournois
00031     Add a short roadmap.
00032     Add BOOST_NO_STD_WSTRING for gcc.
00033 
00034     Revision 1.10  2004/02/22 10:27:32  tournois
00035     Add some doc.
00036 
00037     Revision 1.9  2004/02/22 09:54:19  tournois
00038     Change years on the copyright.
00039 
00040     Revision 1.8  2003/11/18 18:54:51  tournois
00041     Add str_cast and drop the transformation.hpp file.
00042 
00043     Revision 1.7  2003/11/16 13:25:25  tournois
00044     Change the error to use wide string.
00045     Change the translation to use wide string.
00046 
00047     Revision 1.6  2003/11/02 19:23:01  tournois
00048     Go to the boost coding standard.
00049     Change all name to lower case.
00050 
00051     Revision 1.5  2003/10/29 17:51:52  tournois
00052     Modifie error copy constructor for the VC7.1 compiler
00053 
00054     Revision 1.4  2003/10/25 13:53:39  hfp
00055     review and separation
00056 
00057     Revision 1.3  2003/09/24 08:28:17  tournois
00058     Create the namespace Encoders, Parser, Xml
00059     Change the library organization.
00060     add VC7.1 project for this organization.
00061 
00062   */
00063 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00064 #include <ximol/error.hpp>
00065 #include <ximol/str_cast.hpp>
00066 
00067 XIMOL_BEGIN_NAMESPACE
00068 
00069 //-----------------------------------------------------------------------------
00070 // Constructor
00071 //-----------------------------------------------------------------------------
00072 error::error()
00073 {
00074 }
00075 
00076 //-----------------------------------------------------------------------------
00077 // Constructor
00078 //-----------------------------------------------------------------------------
00079 error::error(const string_type& str)
00080 {
00081         static_cast<stream_type &>(*this) << str;
00082 }
00083 
00084 //-----------------------------------------------------------------------------
00085 // Copy-Constructor
00086 //-----------------------------------------------------------------------------
00087 error::error(const error& err)
00088 {
00089         static_cast<stream_type &>(*this) << err.str();
00090 }
00091 
00092 //-----------------------------------------------------------------------------
00093 // Destructor
00094 //-----------------------------------------------------------------------------
00095 error::~error() throw()
00096 {
00097 }
00098 
00099 //-----------------------------------------------------------------------------
00100 // The most important function.
00101 //-----------------------------------------------------------------------------
00102 const char* error::what() const throw()
00103 { 
00104     buffer_= XIMOL_NAMESPACE_PATH::str< ::std::string>::cast(str());
00105         return buffer_.c_str();
00106 }
00107 
00108 //-----------------------------------------------------------------------------
00109 /// Get the error message.
00110 //-----------------------------------------------------------------------------
00111 const error::string_type & error::message() const throw()
00112 {
00113     wbuffer_=str();
00114         return wbuffer_;
00115 };
00116 
00117 XIMOL_END_NAMESPACE


Donate to the XiMoL project SourceForge.net Logo If you have any questions about XiMoL, you could write to tournois@users.sourceforge.net.