summaryrefslogtreecommitdiff
path: root/Network/NetworkMessage.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2025-01-09 22:12:12 +0100
committerChristoph Berg <myon@debian.org>2025-01-09 22:12:12 +0100
commit98c02f78b26811ba5d9962ba27ec24cacf82bb22 (patch)
treedaaf609cde31d8fb3b6c3457c43663d14f0dda80 /Network/NetworkMessage.cpp
parent332d2ce88c2f0bc2908cacdc6707e2f9fa49f26d (diff)
parent992d4b4b8d3f3a630a2cf00d593ee4ce4dfa7ce8 (diff)
Update upstream source from tag 'upstream/2.7.0_rc8+repack'
Update to upstream version '2.7.0~rc8+repack' with Debian dir 6fce941c8282d35c8df23d3de779a42e27688bc1
Diffstat (limited to 'Network/NetworkMessage.cpp')
-rwxr-xr-xNetwork/NetworkMessage.cpp272
1 files changed, 136 insertions, 136 deletions
diff --git a/Network/NetworkMessage.cpp b/Network/NetworkMessage.cpp
index 5e2dbb51..a1e7050f 100755
--- a/Network/NetworkMessage.cpp
+++ b/Network/NetworkMessage.cpp
@@ -1,136 +1,136 @@
-#include "NetworkMessage.hpp"
-
-#include <exception>
-
-#include <QString>
-#include <QByteArray>
-#include <QDebug>
-
-#include "pimpl_impl.hpp"
-
-namespace NetworkMessage
-{
- Builder::Builder (QIODevice * device, Type type, QString const& id, quint32 schema)
- : QDataStream {device}
- {
- common_initialization (type, id, schema);
- }
-
- Builder::Builder (QByteArray * a, Type type, QString const& id, quint32 schema)
- : QDataStream {a, QIODevice::WriteOnly}
- {
- common_initialization (type, id, schema);
- }
-
- void Builder::common_initialization (Type type, QString const& id, quint32 schema)
- {
- if (schema <= 1)
- {
- setVersion (QDataStream::Qt_5_0); // Qt schema version
- }
-#if QT_VERSION >= QT_VERSION_CHECK (5, 2, 0)
- else if (schema <= 2)
- {
- setVersion (QDataStream::Qt_5_2); // Qt schema version
- }
-#endif
-#if QT_VERSION >= QT_VERSION_CHECK (5, 4, 0)
- else if (schema <= 3)
- {
- setVersion (QDataStream::Qt_5_4); // Qt schema version
- }
-#endif
- else
- {
- throw std::runtime_error {"Unrecognized message schema"};
- }
-
- // the following two items assume that the quint32 encoding is
- // unchanged over QDataStream versions
- *this << magic;
- *this << schema;
-
- *this << static_cast<quint32> (type) << id.toUtf8 ();
- }
-
- class Reader::impl
- {
- public:
- void common_initialization (Reader * parent)
- {
- quint32 magic;
- *parent >> magic;
- if (magic != Builder::magic)
- {
- throw std::runtime_error {"Invalid message format"};
- }
- *parent >> schema_;
- if (schema_ > Builder::schema_number)
- {
- throw std::runtime_error {"Unrecognized message schema"};
- }
- if (schema_ <= 1)
- {
- parent->setVersion (QDataStream::Qt_5_0);
- }
-#if QT_VERSION >= QT_VERSION_CHECK (5, 2, 0)
- else if (schema_ <= 2)
- {
- parent->setVersion (QDataStream::Qt_5_2);
- }
-#endif
-#if QT_VERSION >= QT_VERSION_CHECK (5, 4, 0)
- else if (schema_ <= 3)
- {
- parent->setVersion (QDataStream::Qt_5_4);
- }
-#endif
- quint32 type;
- *parent >> type >> id_;
- if (type >= maximum_message_type_)
- {
- qDebug () << "Unrecognized message type:" << type << "from id:" << id_;
- type_ = maximum_message_type_;
- }
- else
- {
- type_ = static_cast<Type> (type);
- }
- }
-
- quint32 schema_;
- Type type_;
- QByteArray id_;
- };
-
- Reader::Reader (QIODevice * device)
- : QDataStream {device}
- {
- m_->common_initialization (this);
- }
-
- Reader::Reader (QByteArray const& a)
- : QDataStream {a}
- {
- m_->common_initialization (this);
- }
-
- Reader::~Reader ()
- {
- }
-
- quint32 Reader::schema () const
- {
- return m_->schema_;
- }
-
- Type Reader::type () const
- {
- return static_cast<Type> (m_->type_);
- }
-
- QString Reader::id () const
- {
- return QString::fromUtf8 (m_->id_);
- }
-}
+#include "NetworkMessage.hpp"
+
+#include <exception>
+
+#include <QString>
+#include <QByteArray>
+#include <QDebug>
+
+#include "pimpl_impl.hpp"
+
+namespace NetworkMessage
+{
+ Builder::Builder (QIODevice * device, Type type, QString const& id, quint32 schema)
+ : QDataStream {device}
+ {
+ common_initialization (type, id, schema);
+ }
+
+ Builder::Builder (QByteArray * a, Type type, QString const& id, quint32 schema)
+ : QDataStream {a, QIODevice::WriteOnly}
+ {
+ common_initialization (type, id, schema);
+ }
+
+ void Builder::common_initialization (Type type, QString const& id, quint32 schema)
+ {
+ if (schema <= 1)
+ {
+ setVersion (QDataStream::Qt_5_0); // Qt schema version
+ }
+#if QT_VERSION >= QT_VERSION_CHECK (5, 2, 0)
+ else if (schema <= 2)
+ {
+ setVersion (QDataStream::Qt_5_2); // Qt schema version
+ }
+#endif
+#if QT_VERSION >= QT_VERSION_CHECK (5, 4, 0)
+ else if (schema <= 3)
+ {
+ setVersion (QDataStream::Qt_5_4); // Qt schema version
+ }
+#endif
+ else
+ {
+ throw std::runtime_error {"Unrecognized message schema"};
+ }
+
+ // the following two items assume that the quint32 encoding is
+ // unchanged over QDataStream versions
+ *this << magic;
+ *this << schema;
+
+ *this << static_cast<quint32> (type) << id.toUtf8 ();
+ }
+
+ class Reader::impl
+ {
+ public:
+ void common_initialization (Reader * parent)
+ {
+ quint32 magic;
+ *parent >> magic;
+ if (magic != Builder::magic)
+ {
+ throw std::runtime_error {"Invalid message format"};
+ }
+ *parent >> schema_;
+ if (schema_ > Builder::schema_number)
+ {
+ throw std::runtime_error {"Unrecognized message schema"};
+ }
+ if (schema_ <= 1)
+ {
+ parent->setVersion (QDataStream::Qt_5_0);
+ }
+#if QT_VERSION >= QT_VERSION_CHECK (5, 2, 0)
+ else if (schema_ <= 2)
+ {
+ parent->setVersion (QDataStream::Qt_5_2);
+ }
+#endif
+#if QT_VERSION >= QT_VERSION_CHECK (5, 4, 0)
+ else if (schema_ <= 3)
+ {
+ parent->setVersion (QDataStream::Qt_5_4);
+ }
+#endif
+ quint32 type;
+ *parent >> type >> id_;
+ if (type >= maximum_message_type_)
+ {
+ qDebug () << "Unrecognized message type:" << type << "from id:" << id_;
+ type_ = maximum_message_type_;
+ }
+ else
+ {
+ type_ = static_cast<Type> (type);
+ }
+ }
+
+ quint32 schema_;
+ Type type_;
+ QByteArray id_;
+ };
+
+ Reader::Reader (QIODevice * device)
+ : QDataStream {device}
+ {
+ m_->common_initialization (this);
+ }
+
+ Reader::Reader (QByteArray const& a)
+ : QDataStream {a}
+ {
+ m_->common_initialization (this);
+ }
+
+ Reader::~Reader ()
+ {
+ }
+
+ quint32 Reader::schema () const
+ {
+ return m_->schema_;
+ }
+
+ Type Reader::type () const
+ {
+ return static_cast<Type> (m_->type_);
+ }
+
+ QString Reader::id () const
+ {
+ return QString::fromUtf8 (m_->id_);
+ }
+}