|
From: Tapio V. <aa...@us...> - 2011-01-17 09:19:17
|
Module: editor
Branch: master
Commit: 674793c6bf7429ccd0467a75c4a1c3eb3c147cdc
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 17 10:37:29 2011 +0200
Use Qt's list serialization instead of own.
---
operation.cc | 18 ++----------------
operation.hh | 1 +
2 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/operation.cc b/operation.cc
index e8f80a9..e9099bd 100644
--- a/operation.cc
+++ b/operation.cc
@@ -1,28 +1,14 @@
#include "operation.hh"
-#include <stdexcept>
-namespace {
- static const int MAX_PARAMS = 10;
-}
QDataStream& operator<<(QDataStream& stream, const Operation& op)
{
- if (op.m_params.size() > MAX_PARAMS)
- throw std::runtime_error("Operation has too many parameters");
- int i = 0;
- for (i; i < op.m_params.size(); ++i)
- stream << op.m_params[i];
- for (i; i < MAX_PARAMS; ++i)
- stream << QVariant(0);
+ stream << op.m_params;
return stream;
}
QDataStream& operator>>(QDataStream& stream, Operation& op)
{
- for (int i = 0; i < MAX_PARAMS; ++i ) {
- QVariant qv;
- stream >> qv;
- op << qv;
- }
+ stream >> op.m_params;
return stream;
}
diff --git a/operation.hh b/operation.hh
index 4bcf05b..7b25ff5 100644
--- a/operation.hh
+++ b/operation.hh
@@ -53,6 +53,7 @@ struct Operation
}
friend QDataStream& operator<<(QDataStream&, const Operation&);
+ friend QDataStream& operator>>(QDataStream& stream, Operation& op);
private:
QList<QVariant> m_params;
|