mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-25 00:50:04 -05:00
Add an assignment operator to Uuid and support serialization with QDataStream.
This commit is contained in:
parent
d5cd0dcd14
commit
9e0a6ad2d8
@ -60,6 +60,13 @@ bool Uuid::isNull() const
|
||||
return true;
|
||||
}
|
||||
|
||||
Uuid& Uuid::operator=(const Uuid& other)
|
||||
{
|
||||
m_data = other.m_data;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Uuid::operator==(const Uuid& other) const
|
||||
{
|
||||
return m_data == other.m_data;
|
||||
@ -80,3 +87,19 @@ uint qHash(const Uuid& key)
|
||||
{
|
||||
return qHash(key.toByteArray());
|
||||
}
|
||||
|
||||
QDataStream& operator<<(QDataStream& stream, const Uuid& uuid)
|
||||
{
|
||||
return stream << uuid.toByteArray();
|
||||
}
|
||||
|
||||
QDataStream& operator>>(QDataStream& stream, Uuid& uuid)
|
||||
{
|
||||
QByteArray data;
|
||||
stream >> data;
|
||||
if (data.size() == Uuid::LENGTH) {
|
||||
uuid = Uuid(data);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
QString toBase64() const;
|
||||
QByteArray toByteArray() const;
|
||||
bool isNull() const;
|
||||
Uuid& operator=(const Uuid& other);
|
||||
bool operator==(const Uuid& other) const;
|
||||
bool operator!=(const Uuid& other) const;
|
||||
static const int LENGTH;
|
||||
@ -43,4 +44,7 @@ Q_DECLARE_TYPEINFO(Uuid, Q_MOVABLE_TYPE);
|
||||
|
||||
uint qHash(const Uuid& key);
|
||||
|
||||
QDataStream& operator<<(QDataStream& stream, const Uuid& uuid);
|
||||
QDataStream& operator>>(QDataStream& stream, Uuid& uuid);
|
||||
|
||||
#endif // KEEPASSX_UUID_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user