Convert everything except wallet/qt to new serialization

This commit is contained in:
Pieter Wuille
2020-03-11 09:35:50 -07:00
parent 2b1f85e8c5
commit 4eb5643e35
17 changed files with 70 additions and 212 deletions

View File

@@ -331,24 +331,26 @@ struct StringContentsSerializer {
}
StringContentsSerializer& operator+=(const StringContentsSerializer& s) { return *this += s.str; }
ADD_SERIALIZE_METHODS;
template<typename Stream>
void Serialize(Stream& s) const
{
for (size_t i = 0; i < str.size(); i++) {
s << str[i];
}
}
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
if (ser_action.ForRead()) {
str.clear();
char c = 0;
while (true) {
try {
READWRITE(c);
str.push_back(c);
} catch (const std::ios_base::failure&) {
break;
}
template<typename Stream>
void Unserialize(Stream& s)
{
str.clear();
char c = 0;
while (true) {
try {
s >> c;
str.push_back(c);
} catch (const std::ios_base::failure&) {
break;
}
} else {
for (size_t i = 0; i < str.size(); i++)
READWRITE(str[i]);
}
}
};