|
Quantum GIS API Documentation
master-693a1fe
|
00001 /*************************************************************************** 00002 qgserror.h - Error container 00003 ------------------- 00004 begin : October 2012 00005 copyright : (C) 2012 Radim Blazek 00006 email : radim dot blazek at gmail dot com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 #ifndef QGSERROR_H 00018 #define QGSERROR_H 00019 00020 #include <QString> 00021 #include <QList> 00022 00023 // Macro to create Error message including info about where it was created. 00024 #define QGS_ERROR_MESSAGE(message, tag) QgsErrorMessage(QString(message),QString(tag), QString(__FILE__), QString(__FUNCTION__), __LINE__) 00025 00029 class CORE_EXPORT QgsErrorMessage 00030 { 00031 public: 00033 enum Format 00034 { 00035 Text, // Plain text 00036 Html 00037 }; 00038 00039 QgsErrorMessage() {} 00040 00048 QgsErrorMessage( const QString & theMessage, const QString & theTag = QString::null, const QString & theFile = QString::null, const QString & theFunction = QString::null, int theLine = 0 ); 00049 00050 QString message() const { return mMessage; } 00051 QString tag() const { return mTag; } 00052 QString file() const { return mFile; } 00053 QString function() const { return mFunction; } 00054 int line() const { return mLine; } 00055 00056 private: 00058 QString mMessage; 00059 00061 QString mTag; 00062 00064 QString mFile; 00065 QString mFunction; 00066 int mLine; 00067 00068 /* Message format */ 00069 Format mFormat; 00070 }; 00071 00077 class CORE_EXPORT QgsError 00078 { 00079 public: 00080 00081 QgsError() {} 00082 00087 QgsError( const QString & theMessage, const QString & theTag ); 00088 00093 void append( const QString & theMessage, const QString & theTag ); 00094 00098 void append( const QgsErrorMessage & theMessage ); 00099 00103 bool isEmpty() const { return mMessageList.isEmpty(); } 00104 00109 QString message( QgsErrorMessage::Format theFormat = QgsErrorMessage::Html ) const; 00110 00114 QString summary() const; 00115 00117 void clear() { mMessageList.clear(); } 00118 00119 private: 00121 QList<QgsErrorMessage> mMessageList; 00122 }; 00123 00124 #endif