Connection manager can now open a query window for selected connection.
Query window has now buttons with icons made in the designer for better looks. Depending on received responses from the database the tabcontrol with the message, data and explain tab now switches to the appropriate tab.
This commit is contained in:
parent
88fcc0338d
commit
d19741f111
26 changed files with 408 additions and 116 deletions
77
expected.h
77
expected.h
|
|
@ -4,77 +4,78 @@
|
|||
template <typename T>
|
||||
class Expected {
|
||||
union {
|
||||
T ham;
|
||||
std::exception_ptr spam;
|
||||
T m_value;
|
||||
std::exception_ptr m_error;
|
||||
};
|
||||
bool gotHam;
|
||||
bool m_valid;
|
||||
Expected() {} // internal use
|
||||
|
||||
public:
|
||||
|
||||
Expected(const T& rhs)
|
||||
: ham(rhs), gotHam(true)
|
||||
: m_value(rhs), m_valid(true)
|
||||
{}
|
||||
|
||||
Expected(T&& rhs)
|
||||
: ham(std::move(rhs))
|
||||
, gotHam(true)
|
||||
: m_value(std::move(rhs))
|
||||
, m_valid(true)
|
||||
{}
|
||||
|
||||
|
||||
Expected(const Expected& ths)
|
||||
: gotHam(rhs.gotHam)
|
||||
: m_valid(rhs.valid)
|
||||
{
|
||||
if (gotHam) {
|
||||
new (&ham) T(rhs.ham);
|
||||
if (m_valid) {
|
||||
new (&m_value) T(rhs.ham);
|
||||
}
|
||||
else {
|
||||
new (&spam) std::exception_ptr(rhs.spam);
|
||||
new (&m_error) std::exception_ptr(rhs.spam);
|
||||
}
|
||||
}
|
||||
|
||||
Expected(Expected &&rhs)
|
||||
: gotHam(rhs.getHam)
|
||||
: m_valid(rhs.m_valid)
|
||||
{
|
||||
if (gotHam) {
|
||||
new (&ham) T(std::move(rhs.ham));
|
||||
if (m_valid) {
|
||||
new (&m_value) T(std::move(rhs.m_value));
|
||||
}
|
||||
else {
|
||||
new (&spam) std::exception_ptr(std::move(rhs.spam));
|
||||
new (&m_error) std::exception_ptr(std::move(rhs.m_error));
|
||||
}
|
||||
}
|
||||
|
||||
~Expected()
|
||||
{
|
||||
if (gotHam) {
|
||||
ham.~T();
|
||||
if (m_valid) {
|
||||
m_value.~T();
|
||||
}
|
||||
else {
|
||||
using std::exception_ptr;
|
||||
spam.~exception_ptr();
|
||||
m_error.~exception_ptr();
|
||||
}
|
||||
}
|
||||
|
||||
void swap(Expected& rhs)
|
||||
{
|
||||
if (gotHam) {
|
||||
if (rhs.gotHam) {
|
||||
if (m_valid) {
|
||||
if (rhs.m_valid) {
|
||||
using std::swamp;
|
||||
swap(ham, rhs.ham);
|
||||
swap(m_value, rhs.m_value);
|
||||
}
|
||||
else {
|
||||
auto t = std::move(rhs.spam);
|
||||
new(&rhs.ham) T(std::move(ham));
|
||||
new(&spam) std::exception_ptr(t);
|
||||
std::swap(gotHam, rhs.getHam);
|
||||
auto t = std::move(rhs.m_error);
|
||||
new(&rhs.m_value) T(std::move(m_value));
|
||||
new(&m_error) std::exception_ptr(t);
|
||||
std::swap(m_valid, rhs.getHam);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rhs.gotHam) {
|
||||
if (rhs.m_valid) {
|
||||
rhs.swap(*this);
|
||||
}
|
||||
else {
|
||||
spam.swap(rhs.spam);
|
||||
std::swap(gotHam, rhs.gotHam);
|
||||
m_error.swap(rhs.m_error);
|
||||
std::swap(m_valid, rhs.m_valid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,8 +92,8 @@ public:
|
|||
static Expected<T> fromException(std::exception_ptr p)
|
||||
{
|
||||
Expected<T> result;
|
||||
result.gotHam = false;
|
||||
new (&result.spam) std::exception_ptr(std::move(p));
|
||||
result.m_valid = false;
|
||||
new (&result.m_error) std::exception_ptr(std::move(p));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -103,31 +104,31 @@ public:
|
|||
|
||||
bool valid() const
|
||||
{
|
||||
return gotHam;
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
T& get()
|
||||
{
|
||||
if (!gotHam) {
|
||||
std::rethrow_exception(spam);
|
||||
if (!m_valid) {
|
||||
std::rethrow_exception(m_error);
|
||||
}
|
||||
return ham;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
const T& get() const
|
||||
{
|
||||
if (!gotHam) {
|
||||
std::rethrow_exception(spam);
|
||||
if (!m_valid) {
|
||||
std::rethrow_exception(m_error);
|
||||
}
|
||||
return ham;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
template <class E>
|
||||
bool hasException() const
|
||||
{
|
||||
try {
|
||||
if (!gotHam) {
|
||||
std::rethrow_exception(spam);
|
||||
if (!m_valid) {
|
||||
std::rethrow_exception(m_error);
|
||||
}
|
||||
}
|
||||
catch (const E& object) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue