mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-13 00:00:23 +02:00
Support serialization as another type without casting
This adds a READWRITEAS(type, obj) macro which serializes obj as if it were casted to (const type&) when const, and to (type&) when non-const. This makes it usable in serialization code that uses a single implementation for both serialization and deserializing, which doesn't know the constness of the object involved.
This commit is contained in:
@@ -395,7 +395,7 @@ public:
|
||||
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
|
||||
}
|
||||
|
||||
s << *static_cast<const CMerkleTx*>(this);
|
||||
s << static_cast<const CMerkleTx&>(*this);
|
||||
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
||||
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
Init(nullptr);
|
||||
char fSpent;
|
||||
|
||||
s >> *static_cast<CMerkleTx*>(this);
|
||||
s >> static_cast<CMerkleTx&>(*this);
|
||||
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
||||
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user