ClearSilverException.cc

00001 /*
00002  * $Id: ClearSilverException.cc,v 1.4 2006/03/29 14:21:35 brook Exp $
00003  */
00004 
00005 /*
00006  * ClearSilver++ Software License.
00007  *
00008  * Copyright (c) 2005,2006 Brook Milligan <brook@nmsu.edu>
00009  * All rights reserved.
00010  * 
00011  * Redistribution and use in source and binary forms, with or without
00012  * modification, are permitted provided that the following conditions
00013  * are met:
00014  * 
00015  * 1. Redistributions of source code must retain the above copyright
00016  *    notice, this list of conditions and the following disclaimer.
00017  * 2. Redistributions in binary form must reproduce the above
00018  *    copyright notice, this list of conditions and the following
00019  *    disclaimer in the documentation and/or other materials provided
00020  *    with the distribution.
00021  * 3. The name of the author may not be used to endorse or promote
00022  *    products derived from this software without specific prior
00023  *    written permission.
00024  * 
00025  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
00026  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00027  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00029  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00031  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00033  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036  */
00037 
00038 #include "ClearSilverException.h"
00039 
00040 #include <boost/lexical_cast.hpp>
00041 #include <ClearSilver/util/neo_misc.h> // must precede neo_err.h
00042 #include <ClearSilver/util/neo_err.h>
00043 #include "ClearSilverError.h"
00044 
00045 using namespace std;
00046 
00047 
00048                                 // constructors
00049 ClearSilver::ClearSilverException::ClearSilverException ()
00050   : message_() {}
00051 ClearSilver::ClearSilverException::ClearSilverException (const char * message)
00052   : message_(message) {}
00053 ClearSilver::ClearSilverException::ClearSilverException (const string& message)
00054   : message_(message) {}
00055 ClearSilver::ClearSilverException::ClearSilverException
00056 (const ClearSilverException& e)
00057   : message_(e.message_) {}
00058 ClearSilver::ClearSilverException::~ClearSilverException () throw()
00059 {}
00060 
00061                                 // assignment
00062 ClearSilver::ClearSilverException&
00063 ClearSilver::ClearSilverException::operator = (const ClearSilverException& e)
00064 {
00065   message_ = e.message_;
00066   return *this;
00067 }
00068 
00069 ClearSilver::ClearSilverException&
00070 ClearSilver::ClearSilverException::operator += (const ClearSilverError& error)
00071 {
00072   _neo_err* e (error.get());
00073   while (e)
00074     {
00075       if (!message_.empty())
00076         message_ += "\n";
00077       message_ += e->file;
00078       message_ += ":";
00079       message_ += boost::lexical_cast<string>(e->lineno);
00080       message_ += ":";
00081       message_ += e->func;
00082       message_ += "(): ";
00083       message_ += e->desc;
00084       e = e->next;
00085     }
00086   return *this;
00087 }
00088 
00089                                 // return the error message.
00090 const char*
00091 ClearSilver::ClearSilverException::what () const throw()
00092 {
00093   return message_.c_str();
00094 }
00095 
00096 void
00097 ClearSilver::ClearSilverException::swap (ClearSilverException& e) throw ()
00098 {
00099   message_.swap (e.message_);
00100 }

Generated on Tue May 16 14:50:52 2006 for ClearSilver C++ Library by  doxygen 1.4.5