Convert Qt to new serialization

This commit is contained in:
Pieter Wuille 2020-05-20 10:16:41 -07:00
parent 448bdff263
commit 65c589e45e
2 changed files with 17 additions and 34 deletions

View file

@ -24,19 +24,11 @@ public:
QDateTime date;
SendCoinsRecipient recipient;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
unsigned int nDate = date.toTime_t();
READWRITE(this->nVersion);
READWRITE(id);
READWRITE(nDate);
READWRITE(recipient);
if (ser_action.ForRead())
date = QDateTime::fromTime_t(nDate);
SERIALIZE_METHODS(RecentRequestEntry, obj) {
unsigned int date_timet;
SER_WRITE(obj, date_timet = obj.date.toTime_t());
READWRITE(obj.nVersion, obj.id, date_timet, obj.recipient);
SER_READ(obj, obj.date = QDateTime::fromTime_t(date_timet));
}
};

View file

@ -44,30 +44,21 @@ public:
static const int CURRENT_VERSION = 1;
int nVersion;
ADD_SERIALIZE_METHODS;
SERIALIZE_METHODS(SendCoinsRecipient, obj)
{
std::string address_str, label_str, message_str, auth_merchant_str;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
std::string sAddress = address.toStdString();
std::string sLabel = label.toStdString();
std::string sMessage = message.toStdString();
std::string sAuthenticatedMerchant = authenticatedMerchant.toStdString();
SER_WRITE(obj, address_str = obj.address.toStdString());
SER_WRITE(obj, label_str = obj.label.toStdString());
SER_WRITE(obj, message_str = obj.message.toStdString());
SER_WRITE(obj, auth_merchant_str = obj.authenticatedMerchant.toStdString());
READWRITE(this->nVersion);
READWRITE(sAddress);
READWRITE(sLabel);
READWRITE(amount);
READWRITE(sMessage);
READWRITE(sPaymentRequest);
READWRITE(sAuthenticatedMerchant);
READWRITE(obj.nVersion, address_str, label_str, obj.amount, message_str, obj.sPaymentRequest, auth_merchant_str);
if (ser_action.ForRead())
{
address = QString::fromStdString(sAddress);
label = QString::fromStdString(sLabel);
message = QString::fromStdString(sMessage);
authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant);
}
SER_READ(obj, obj.address = QString::fromStdString(address_str));
SER_READ(obj, obj.label = QString::fromStdString(label_str));
SER_READ(obj, obj.message = QString::fromStdString(message_str));
SER_READ(obj, obj.authenticatedMerchant = QString::fromStdString(auth_merchant_str));
}
};