143 lines
4.0 KiB
C++
143 lines
4.0 KiB
C++
/*
|
|
* Squawk messenger.
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "identity.h"
|
|
|
|
Shared::Identity::Identity():
|
|
category(),
|
|
type(),
|
|
language(),
|
|
name() {}
|
|
|
|
bool Shared::Identity::operator==(const Shared::Identity& other) const {
|
|
return category == other.category && type == other.type && language == other.language && name == other.name;
|
|
}
|
|
|
|
bool Shared::Identity::operator!=(const Shared::Identity& other) const {
|
|
return category != other.category || type != other.type || language != other.language || name != other.name;
|
|
}
|
|
|
|
bool Shared::Identity::operator > (const Shared::Identity& other) const {
|
|
if (category > other.category) {
|
|
return true;
|
|
} else if (category < other.category) {
|
|
return false;
|
|
} else if (type > other.type) {
|
|
return true;
|
|
} else if (type < other.type) {
|
|
return false;
|
|
} else if (language > other.language) {
|
|
return true;
|
|
} else if (language < other.language) {
|
|
return false;
|
|
} else if (name > other.name) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool Shared::Identity::operator < (const Shared::Identity& other) const {
|
|
if (category < other.category) {
|
|
return true;
|
|
} else if (category > other.category) {
|
|
return false;
|
|
} else if (type < other.type) {
|
|
return true;
|
|
} else if (type > other.type) {
|
|
return false;
|
|
} else if (language < other.language) {
|
|
return true;
|
|
} else if (language > other.language) {
|
|
return false;
|
|
} else if (name < other.name) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool Shared::Identity::operator >= (const Shared::Identity& other) const {
|
|
if (category > other.category) {
|
|
return true;
|
|
} else if (category < other.category) {
|
|
return false;
|
|
} else if (type > other.type) {
|
|
return true;
|
|
} else if (type < other.type) {
|
|
return false;
|
|
} else if (language > other.language) {
|
|
return true;
|
|
} else if (language < other.language) {
|
|
return false;
|
|
} else if (name > other.name) {
|
|
return true;
|
|
} else if (name < other.name) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool Shared::Identity::operator <= (const Shared::Identity& other) const {
|
|
if (category < other.category) {
|
|
return true;
|
|
} else if (category > other.category) {
|
|
return false;
|
|
} else if (type < other.type) {
|
|
return true;
|
|
} else if (type > other.type) {
|
|
return false;
|
|
} else if (language < other.language) {
|
|
return true;
|
|
} else if (language > other.language) {
|
|
return false;
|
|
} else if (name < other.name) {
|
|
return true;
|
|
} else if (name > other.name) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
QDataStream & Shared::Identity::operator >> (QDataStream& stream) const {
|
|
stream << category;
|
|
stream << type;
|
|
stream << language;
|
|
stream << name;
|
|
}
|
|
|
|
QDataStream & Shared::Identity::operator << (QDataStream& stream) {
|
|
stream >> category;
|
|
stream >> type;
|
|
stream >> language;
|
|
stream >> name;
|
|
}
|
|
|
|
QDataStream & operator >> (QDataStream& stream, Shared::Identity& identity) {
|
|
identity << stream;
|
|
return stream;
|
|
}
|
|
|
|
QDataStream & operator << (QDataStream& stream, const Shared::Identity& identity) {
|
|
identity >> stream;
|
|
return stream;
|
|
}
|
|
|