soprano/error.h

Go to the documentation of this file.
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             ErrorUnknown = 0x1000        
00047         };
00048 
00052         SOPRANO_EXPORT QString errorMessage( ErrorCode );
00053 
00061         SOPRANO_EXPORT ErrorCode convertErrorCode( int code );
00062 
00063         class ErrorData;
00064         class ParserError;
00065 
00075         class SOPRANO_EXPORT Error
00076         {
00077         public:
00081             Error();
00082 
00091             Error( const QString& message, int code = ErrorUnknown );
00092 
00096             Error( const Error& );
00097 
00101             virtual ~Error();
00102 
00103             Error& operator=( const Error& );
00104 
00119             operator bool() const { return code() != ErrorNone; }
00120 
00129             QString message() const;
00130 
00145             int code() const;
00146 
00151             bool isParserError() const;
00152 
00165             ParserError toParserError() const;
00166     
00167         protected:
00169             Error( ErrorData* );
00170             QSharedDataPointer<ErrorData> d;
00172         };
00173 
00174         class Locator;
00175 
00198         class SOPRANO_EXPORT ParserError : public Error
00199         {
00200         public:
00204             ParserError();
00205 
00206             ParserError( const Locator&, const QString& message = QString(), int code = ErrorParsingFailed );
00207 
00208             ParserError( const Error& );
00209 
00210             ~ParserError();
00211 
00212             ParserError& operator=( const Error& );
00213 
00214             Locator locator() const;
00215         };
00216 
00230         class SOPRANO_EXPORT ErrorCache
00231         {
00232         public:
00233             virtual ~ErrorCache();
00234 
00238             virtual Error lastError() const;
00239         
00240         protected:
00241             ErrorCache();
00242 
00246             void clearError() const;
00247 
00253             void setError( const Error& ) const;
00254 
00259             void setError( const QString& errorMessage, int code = ErrorUnknown ) const;
00260 
00261         private:
00262             class Private;
00263             Private* const d;
00264         };
00265     }
00266 }
00267 
00268 class QDebug;
00269 class QTextStream;
00270 
00271 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Error::Error& );
00272 SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Error::Error& );
00273 
00274 #endif

Generated on Fri Mar 7 19:00:11 2008 for Soprano by  doxygen 1.5.4