From 8a7695784cb1aa1a5083a2f75b057b6282b04ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 10 Jun 2021 15:46:46 +0200 Subject: [PATCH] CommandLineParser: operator << for CompilerOutputs and CombinedJsonRequests --- solc/CommandLineParser.cpp | 21 +++++++++++++++++++++ solc/CommandLineParser.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 2758f1b63..d77636507 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -176,6 +176,16 @@ bool CompilerOutputs::operator==(CompilerOutputs const& _other) const noexcept return true; } +ostream& operator<<(ostream& _out, CompilerOutputs const& _selection) +{ + vector 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) { solAssert(_component, ""); @@ -196,6 +206,17 @@ bool CombinedJsonRequests::operator==(CombinedJsonRequests const& _other) const return true; } + +ostream& operator<<(ostream& _out, CombinedJsonRequests const& _requests) +{ + vector 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) { solAssert(_component, ""); diff --git a/solc/CommandLineParser.h b/solc/CommandLineParser.h index 1c2cd2820..7e1266653 100644 --- a/solc/CommandLineParser.h +++ b/solc/CommandLineParser.h @@ -55,6 +55,7 @@ struct CompilerOutputs { bool operator!=(CompilerOutputs const& _other) const noexcept { return !(*this == _other); } 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 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; + friend std::ostream& operator<<(std::ostream& _out, CombinedJsonRequests const& _requests); static std::string const& componentName(bool CombinedJsonRequests::* _component); static auto const& componentMap()