kexi

exception.cpp

00001 /***************************************************************************
00002  * This file is part of the KDE project
00003  * copyright (C) 2005 by Sebastian Sauer (mail@dipe.org)
00004  * copyright (C) 2005 by Tobi Krebs (tobi.krebs@gmail.com)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  ***************************************************************************/
00019 
00020 #include "exception.h"
00021 
00022 #include <kdebug.h>
00023 
00024 using namespace KoMacro;
00025 
00026 namespace KoMacro {
00027 
00032     class Exception::Private
00033     {
00034         public:
00035 
00037             const QString errormessage;
00038 
00040             QString tracemessages;
00041 
00045             Private(const QString& errormessage)
00046                 : errormessage(errormessage)
00047             {
00048             }
00049 
00050     };
00051 
00052 }
00053 
00054 //constructor
00055 Exception::Exception(const QString& errormessage)
00056     : d( new Private(errormessage) ) // create the private d-pointer instance.
00057 {
00058     //debuging infos
00059     kdDebug() << QString("Exception errormessage=\"%1\"").arg(errormessage) << endl;
00060 }
00061 
00062 //copy constructor
00063 Exception::Exception (const Exception& e)
00064     : d( new Private( e.errorMessage() ) )
00065 {
00066     d->tracemessages = e.traceMessages();
00067 }
00068 
00069 //deconstructor
00070 Exception::~Exception()
00071 {
00072     delete d;
00073 }
00074 
00075 //get d-pointer errormessage
00076 const QString Exception::errorMessage() const
00077 {
00078     return d->errormessage;
00079 }
00080 
00081 //get d-pointer tracemessages
00082 const QString Exception::traceMessages() const
00083 {
00084     return d->tracemessages;
00085 }
00086 
00087 //add a Qstring to d-pointer tracemessages
00088 void Exception::addTraceMessage(const QString& tracemessage)
00089 {
00090     //no tracemessages till now
00091     if(d->tracemessages.isEmpty())
00092         d->tracemessages = tracemessage;
00093     //append to existing ones
00094     else
00095         d->tracemessages += "\n" + tracemessage;
00096 }
00097 
KDE Home | KDE Accessibility Home | Description of Access Keys