CommandLineParser: operator << for CompilerOutputs and CombinedJsonRequests

This commit is contained in:
Kamil Śliwak 2021-06-10 15:46:46 +02:00
parent 4b394f0b35
commit 8a7695784c
2 changed files with 23 additions and 0 deletions

View File

@ -176,6 +176,16 @@ bool CompilerOutputs::operator==(CompilerOutputs const& _other) const noexcept
return true; return true;
} }
ostream& operator<<(ostream& _out, CompilerOutputs const& _selection)
{
vector<string> serializedSelection;
for (auto&& [componentName, component]: CompilerOutputs::componentMap())
if (_selection.*component)
serializedSelection.push_back(CompilerOutputs::componentName(component));
return _out << joinHumanReadable(serializedSelection, ",");
}
string const& CompilerOutputs::componentName(bool CompilerOutputs::* _component) string const& CompilerOutputs::componentName(bool CompilerOutputs::* _component)
{ {
solAssert(_component, ""); solAssert(_component, "");
@ -196,6 +206,17 @@ bool CombinedJsonRequests::operator==(CombinedJsonRequests const& _other) const
return true; return true;
} }
ostream& operator<<(ostream& _out, CombinedJsonRequests const& _requests)
{
vector<string> serializedRequests;
for (auto&& [componentName, component]: CombinedJsonRequests::componentMap())
if (_requests.*component)
serializedRequests.push_back(CombinedJsonRequests::componentName(component));
return _out << joinHumanReadable(serializedRequests, ",");
}
string const& CombinedJsonRequests::componentName(bool CombinedJsonRequests::* _component) string const& CombinedJsonRequests::componentName(bool CombinedJsonRequests::* _component)
{ {
solAssert(_component, ""); solAssert(_component, "");

View File

@ -55,6 +55,7 @@ struct CompilerOutputs
{ {
bool operator!=(CompilerOutputs const& _other) const noexcept { return !(*this == _other); } bool operator!=(CompilerOutputs const& _other) const noexcept { return !(*this == _other); }
bool operator==(CompilerOutputs const& _other) const noexcept; bool operator==(CompilerOutputs const& _other) const noexcept;
friend std::ostream& operator<<(std::ostream& _out, CompilerOutputs const& _requests);
static std::string const& componentName(bool CompilerOutputs::* _component); static std::string const& componentName(bool CompilerOutputs::* _component);
static auto const& componentMap() static auto const& componentMap()
@ -100,6 +101,7 @@ struct CombinedJsonRequests
{ {
bool operator!=(CombinedJsonRequests const& _other) const noexcept { return !(*this == _other); } bool operator!=(CombinedJsonRequests const& _other) const noexcept { return !(*this == _other); }
bool operator==(CombinedJsonRequests const& _other) const noexcept; bool operator==(CombinedJsonRequests const& _other) const noexcept;
friend std::ostream& operator<<(std::ostream& _out, CombinedJsonRequests const& _requests);
static std::string const& componentName(bool CombinedJsonRequests::* _component); static std::string const& componentName(bool CombinedJsonRequests::* _component);
static auto const& componentMap() static auto const& componentMap()