Soprano  2.9.3
error.h
Go to the documentation of this file.
1 /*
2  * This file is part of Soprano Project.
3  *
4  * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef _SOPRANO_ERROR_H_
23 #define _SOPRANO_ERROR_H_
24 
25 #include "soprano_export.h"
26 
27 #include <QtCore/QString>
28 #include <QtCore/QSharedDataPointer>
29 
30 
31 namespace Soprano {
32  namespace Error {
40  enum ErrorCode {
41  ErrorNone = 0x0,
47  ErrorTimeout = 0x5,
48  ErrorUnknown = 0x1000
49  };
50 
55 
64 
65  class ErrorData;
66  class ParserError;
67 
78  {
79  public:
83  Error();
84 
93  Error( const QString& message, int code = ErrorUnknown );
94 
98  Error( const Error& );
99 
103  virtual ~Error();
104 
105  Error& operator=( const Error& );
106 
121  operator bool() const { return code() != ErrorNone; }
122 
131  QString message() const;
132 
147  int code() const;
148 
153  bool isParserError() const;
154 
167  ParserError toParserError() const;
168 
169  protected:
171  Error( ErrorData* );
174  };
175 
176  class Locator;
177 
201  {
202  public:
206  ParserError();
207 
208  ParserError( const Locator&, const QString& message = QString(), int code = ErrorParsingFailed );
209 
210  ParserError( const Error& );
211 
212  ~ParserError();
213 
214  ParserError& operator=( const Error& );
215 
216  Locator locator() const;
217  };
218 
235  {
236  public:
237  virtual ~ErrorCache();
238 
242  virtual Error lastError() const;
243 
244  protected:
245  ErrorCache();
246 
250  void clearError() const;
251 
257  void setError( const Error& ) const;
258 
263  void setError( const QString& errorMessage, int code = ErrorUnknown ) const;
264 
265  private:
266  class Private;
267  Private* const d;
268  };
269  }
270 }
271 
272 class QDebug;
273 class QTextStream;
274 
275 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Error::Error& );
277 
278 #endif