WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZsqlError.cpp
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2013, 2014 Bob Dinitto
4  *
5  * ZsqlError.cpp
6  *
7  * Created on: 06-Aug, 2014
8  * Author: Bob Dinitto bob@ninzo.com
9  *
10  * Zuble is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 #include "ZsqlError.h"
26 
27 namespace Zbl
28 {
29 
30 ZsqlError::ZsqlError(QObject *parent) :
31  QObject(parent)
32 {
33 }
34 
36 {
37  return m_error.text();
38 }
39 
41 {
42  return m_error.driverText();
43 }
44 
46 {
47  return m_error.databaseText();
48 }
49 
51 {
52  switch (static_cast<int>(m_error.type())) {
53  case QSqlError::NoError:
54  return QString("NoError");
55  case QSqlError::ConnectionError:
56  return QString("ConnectionError");
57  case QSqlError::StatementError:
58  return QString("StatementError");
59  case QSqlError::TransactionError:
60  return QString("TransactionError");
61  case QSqlError::UnknownError:
62  return QString("UnknownError");
63  case -1:
64  return QString("UndeterminedError");
65  default:
66  return QString("TwilightZoneError");
67  }
68  return m_error.text();
69 }
70 
72 {
73  return m_error.number();
74 
75 }
76 
78 {
79  return m_error.isValid();
80 
81 }
82 
84 {
85  m_error = other.m_error;
86  return *this;
87 }
88 
89 ZsqlError& ZsqlError::operator=(const QSqlError& sqlError)
90 {
91  m_error = sqlError;
92  return *this;
93 }
94 
95 bool ZsqlError::operator==(const ZsqlError& other) const
96 {
97  return m_error == other.m_error;
98 }
99 
100 bool ZsqlError::operator==(const QSqlError& other) const
101 {
102  return m_error == other;
103 }
104 
105 bool ZsqlError::equals(QObject* other)
106 {
107  ZsqlError* error = qobject_cast<ZsqlError*>(other);
108 
109  if(!error)
110  return false;
111  else
112  return error == this;
113  }
114 
115 
116 } // Zbl
bool operator==(const ZsqlError &other) const
Definition: ZsqlError.cpp:95
int getErrorNumber()
Definition: ZsqlError.cpp:71
bool isValid()
Definition: ZsqlError.cpp:77
QString getText()
Definition: ZsqlError.cpp:35
Definition: ZAndGate.cpp:6
Q_INVOKABLE bool equals(QObject *other)
Returns true if specified object is a ZsqlError object with the same value as this object...
Definition: ZsqlError.cpp:105
QSqlError m_error
Definition: ZsqlError.h:120
QString getDatabaseText()
Definition: ZsqlError.cpp:45
ZsqlError(QObject *parent=0)
Definition: ZsqlError.cpp:30
ZsqlError & operator=(const ZsqlError &other)
Definition: ZsqlError.cpp:83
QString getErrorType()
Definition: ZsqlError.cpp:50
QString getDriverText()
Definition: ZsqlError.cpp:40
A Javascript wrapper for QSqlError objects. (database sprocket)
Definition: ZsqlError.h:40