mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-30 09:40:16 +02:00
refactor: split off subscript logic from ToStringHelper
This will allow subclasses to overwrite the serialization of subscript arguments without needing to reimplement all the rest of the ToString logic.
This commit is contained in:
parent
6ba5dda0c9
commit
17e006ff8d
@ -525,6 +525,18 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool ToStringSubScriptHelper(const SigningProvider* arg, std::string& ret, bool priv, bool normalized) const
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
for (const auto& scriptarg : m_subdescriptor_args) {
|
||||||
|
if (pos++) ret += ",";
|
||||||
|
std::string tmp;
|
||||||
|
if (!scriptarg->ToStringHelper(arg, tmp, priv, normalized)) return false;
|
||||||
|
ret += std::move(tmp);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ToStringHelper(const SigningProvider* arg, std::string& out, bool priv, bool normalized) const
|
bool ToStringHelper(const SigningProvider* arg, std::string& out, bool priv, bool normalized) const
|
||||||
{
|
{
|
||||||
std::string extra = ToStringExtra();
|
std::string extra = ToStringExtra();
|
||||||
@ -542,13 +554,10 @@ public:
|
|||||||
}
|
}
|
||||||
ret += std::move(tmp);
|
ret += std::move(tmp);
|
||||||
}
|
}
|
||||||
for (const auto& scriptarg : m_subdescriptor_args) {
|
std::string subscript;
|
||||||
if (pos++) ret += ",";
|
if (!ToStringSubScriptHelper(arg, subscript, priv, normalized)) return false;
|
||||||
std::string tmp;
|
if (pos && subscript.size()) ret += ',';
|
||||||
if (!scriptarg->ToStringHelper(arg, tmp, priv, normalized)) return false;
|
out = std::move(ret) + std::move(subscript) + ")";
|
||||||
ret += std::move(tmp);
|
|
||||||
}
|
|
||||||
out = std::move(ret) + ")";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user