@@ -602,48 +602,49 @@ class CAccountingEntry
602
602
nEntryNo = 0 ;
603
603
}
604
604
605
- ADD_SERIALIZE_METHODS;
606
-
607
- template <typename Stream, typename Operation>
608
- inline void SerializationOp (Stream& s, Operation ser_action) {
605
+ template <typename Stream>
606
+ void Serialize (Stream& s) const {
609
607
int nVersion = s.GetVersion ();
610
- if (!(s.GetType () & SER_GETHASH))
611
- READWRITE (nVersion);
608
+ if (!(s.GetType () & SER_GETHASH)) {
609
+ s << nVersion;
610
+ }
612
611
// ! Note: strAccount is serialized as part of the key, not here.
613
- READWRITE (nCreditDebit);
614
- READWRITE (nTime);
615
- READWRITE (LIMITED_STRING (strOtherAccount, 65536 ));
612
+ s << nCreditDebit << nTime << strOtherAccount;
616
613
617
- if (!ser_action.ForRead ())
618
- {
619
- WriteOrderPos (nOrderPos, mapValue);
620
-
621
- if (!(mapValue.empty () && _ssExtra.empty ()))
622
- {
623
- CDataStream ss (s.GetType (), s.GetVersion ());
624
- ss.insert (ss.begin (), ' \0 ' );
625
- ss << mapValue;
626
- ss.insert (ss.end (), _ssExtra.begin (), _ssExtra.end ());
627
- strComment.append (ss.str ());
628
- }
614
+ mapValue_t mapValueCopy = mapValue;
615
+ WriteOrderPos (nOrderPos, mapValueCopy);
616
+
617
+ std::string strCommentCopy = strComment;
618
+ if (!mapValueCopy.empty () || !_ssExtra.empty ()) {
619
+ CDataStream ss (s.GetType (), s.GetVersion ());
620
+ ss.insert (ss.begin (), ' \0 ' );
621
+ ss << mapValueCopy;
622
+ ss.insert (ss.end (), _ssExtra.begin (), _ssExtra.end ());
623
+ strCommentCopy.append (ss.str ());
629
624
}
625
+ s << strCommentCopy;
626
+ }
630
627
631
- READWRITE (LIMITED_STRING (strComment, 65536 ));
628
+ template <typename Stream>
629
+ void Unserialize (Stream& s) {
630
+ int nVersion = s.GetVersion ();
631
+ if (!(s.GetType () & SER_GETHASH)) {
632
+ s >> nVersion;
633
+ }
634
+ // ! Note: strAccount is serialized as part of the key, not here.
635
+ s >> nCreditDebit >> nTime >> LIMITED_STRING (strOtherAccount, 65536 ) >> LIMITED_STRING (strComment, 65536 );
632
636
633
637
size_t nSepPos = strComment.find (" \0 " , 0 , 1 );
634
- if (ser_action.ForRead ())
635
- {
636
- mapValue.clear ();
637
- if (std::string::npos != nSepPos)
638
- {
639
- CDataStream ss (std::vector<char >(strComment.begin () + nSepPos + 1 , strComment.end ()), s.GetType (), s.GetVersion ());
640
- ss >> mapValue;
641
- _ssExtra = std::vector<char >(ss.begin (), ss.end ());
642
- }
643
- ReadOrderPos (nOrderPos, mapValue);
638
+ mapValue.clear ();
639
+ if (std::string::npos != nSepPos) {
640
+ CDataStream ss (std::vector<char >(strComment.begin () + nSepPos + 1 , strComment.end ()), s.GetType (), s.GetVersion ());
641
+ ss >> mapValue;
642
+ _ssExtra = std::vector<char >(ss.begin (), ss.end ());
644
643
}
645
- if (std::string::npos != nSepPos)
644
+ ReadOrderPos (nOrderPos, mapValue);
645
+ if (std::string::npos != nSepPos) {
646
646
strComment.erase (nSepPos);
647
+ }
647
648
648
649
mapValue.erase (" n" );
649
650
}
0 commit comments