Soprano
2.7.2
|
00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org> 00005 * 00006 * This library 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 * 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 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef _SOPRANO_ERROR_H_ 00023 #define _SOPRANO_ERROR_H_ 00024 00025 #include "soprano_export.h" 00026 00027 #include <QtCore/QString> 00028 #include <QtCore/QSharedDataPointer> 00029 00030 00031 namespace Soprano { 00032 namespace Error { 00040 enum ErrorCode { 00041 ErrorNone = 0x0, 00042 ErrorInvalidArgument = 0x1, 00043 ErrorInvalidStatement = ErrorInvalidArgument, 00044 ErrorNotSupported = 0x2, 00045 ErrorParsingFailed = 0x3, 00046 ErrorPermissionDenied = 0x4, 00047 ErrorUnknown = 0x1000 00048 }; 00049 00053 SOPRANO_EXPORT QString errorMessage( ErrorCode ); 00054 00062 SOPRANO_EXPORT ErrorCode convertErrorCode( int code ); 00063 00064 class ErrorData; 00065 class ParserError; 00066 00076 class SOPRANO_EXPORT Error 00077 { 00078 public: 00082 Error(); 00083 00092 Error( const QString& message, int code = ErrorUnknown ); 00093 00097 Error( const Error& ); 00098 00102 virtual ~Error(); 00103 00104 Error& operator=( const Error& ); 00105 00120 operator bool() const { return code() != ErrorNone; } 00121 00130 QString message() const; 00131 00146 int code() const; 00147 00152 bool isParserError() const; 00153 00166 ParserError toParserError() const; 00167 00168 protected: 00170 Error( ErrorData* ); 00171 QSharedDataPointer<ErrorData> d; 00173 }; 00174 00175 class Locator; 00176 00199 class SOPRANO_EXPORT ParserError : public Error 00200 { 00201 public: 00205 ParserError(); 00206 00207 ParserError( const Locator&, const QString& message = QString(), int code = ErrorParsingFailed ); 00208 00209 ParserError( const Error& ); 00210 00211 ~ParserError(); 00212 00213 ParserError& operator=( const Error& ); 00214 00215 Locator locator() const; 00216 }; 00217 00233 class SOPRANO_EXPORT ErrorCache 00234 { 00235 public: 00236 virtual ~ErrorCache(); 00237 00241 virtual Error lastError() const; 00242 00243 protected: 00244 ErrorCache(); 00245 00249 void clearError() const; 00250 00256 void setError( const Error& ) const; 00257 00262 void setError( const QString& errorMessage, int code = ErrorUnknown ) const; 00263 00264 private: 00265 class Private; 00266 Private* const d; 00267 }; 00268 } 00269 } 00270 00271 class QDebug; 00272 class QTextStream; 00273 00274 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Error::Error& ); 00275 SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Error::Error& ); 00276 00277 #endif