X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Ftypes.h;h=104deb728a20ca343ddf96d890b07c5c212502ea;hp=64bfbbc784860e4993807a1977ac67eea873566c;hb=3282d98e3b3324f1b1fb573b03dca9e4e247417c;hpb=e733408e4759473bf38831f498f48a0f2f5e6dc7 diff --git a/src/common/types.h b/src/common/types.h index 64bfbbc7..104deb72 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,12 +18,13 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _TYPES_H_ -#define _TYPES_H_ +#ifndef TYPES_H_ +#define TYPES_H_ #include #include #include +#include class SignedId { protected: @@ -32,10 +33,14 @@ class SignedId { public: inline SignedId(int _id = 0) { id = _id; } inline qint32 toInt() const { return id; } + inline bool isValid() const { return id > 0; } inline bool operator==(const SignedId &other) const { return id == other.id; } inline bool operator!=(const SignedId &other) const { return id != other.id; } inline bool operator<(const SignedId &other) const { return id < other.id; } + inline bool operator<=(const SignedId &other) const { return id <= other.id; } + inline bool operator>(const SignedId &other) const { return id > other.id; } + inline bool operator>=(const SignedId &other) const { return id >= other.id; } inline bool operator==(int i) const { return id == i; } inline bool operator!=(int i) const { return id != i; } inline bool operator<(int i) const { return id < i; } @@ -50,6 +55,7 @@ class SignedId { inline QDataStream &operator<<(QDataStream &out, const SignedId &signedId) { out << signedId.toInt(); return out; } inline QDataStream &operator>>(QDataStream &in, SignedId &signedId) { in >> signedId.id; return in; } +inline QTextStream &operator<<(QTextStream &out, const SignedId &signedId) { out << QString::number(signedId.toInt()); return out; } inline QDebug operator<<(QDebug dbg, const SignedId &signedId) { dbg.space() << signedId.toInt(); return dbg; } inline uint qHash(const SignedId &id) { return qHash(id.toInt()); } @@ -78,11 +84,16 @@ struct IdentityId : public SignedId { //inline operator QVariant() const { return QVariant::fromValue(*this); } }; -Q_DECLARE_METATYPE(UserId); -Q_DECLARE_METATYPE(MsgId); -Q_DECLARE_METATYPE(BufferId); -Q_DECLARE_METATYPE(NetworkId); -Q_DECLARE_METATYPE(IdentityId); +struct AccountId : public SignedId { + inline AccountId(int _id = 0) : SignedId(_id) {}; +}; + +Q_DECLARE_METATYPE(UserId) +Q_DECLARE_METATYPE(MsgId) +Q_DECLARE_METATYPE(BufferId) +Q_DECLARE_METATYPE(NetworkId) +Q_DECLARE_METATYPE(IdentityId) +Q_DECLARE_METATYPE(AccountId) //! Base class for exceptions. struct Exception {