QtGStreamer 0.10.1
|
00001 /* 00002 Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published 00006 by the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #include "error.h" 00018 #include <glib/gerror.h> 00019 #include <QtCore/QDebug> 00020 00021 namespace QGlib { 00022 00023 Error::Error(GError *error) 00024 : std::exception() 00025 { 00026 m_error = error; 00027 } 00028 00029 Error::Error(Quark domain, int code, const QString & message) 00030 : std::exception() 00031 { 00032 m_error = g_error_new_literal(domain, code, message.toUtf8()); 00033 } 00034 00035 Error::Error(const Error & other) 00036 : std::exception() 00037 { 00038 m_error = g_error_copy(other.m_error); 00039 } 00040 00041 Error & Error::operator=(const Error & other) 00042 { 00043 g_error_free(m_error); 00044 m_error = g_error_copy(other.m_error); 00045 return *this; 00046 } 00047 00048 Error::~Error() throw() 00049 { 00050 g_error_free(m_error); 00051 } 00052 00053 const char* Error::what() const throw() 00054 { 00055 return m_error->message; 00056 } 00057 00058 Quark Error::domain() const 00059 { 00060 return m_error->domain; 00061 } 00062 00063 int Error::code() const 00064 { 00065 return m_error->code; 00066 } 00067 00068 QString Error::message() const 00069 { 00070 return QString::fromUtf8(m_error->message); 00071 } 00072 00073 Error::operator GError *() 00074 { 00075 return m_error; 00076 } 00077 00078 Error::operator const GError *() const 00079 { 00080 return m_error; 00081 } 00082 00083 QDebug operator<<(QDebug dbg, const Error & error) 00084 { 00085 return dbg << error.message(); 00086 } 00087 00088 } //namespace QGlib