From 1a9c503e93547fadc0a7a2dcd6d368f456f47460 Mon Sep 17 00:00:00 2001 From: Ali92hm Date: Mon, 22 May 2017 13:39:38 -0700 Subject: Added createJson method to make writing json easier --- solc/CommandLineInterface.cpp | 5 +++++ solc/CommandLineInterface.h | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'solc') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index e6d8776b..9367a71c 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -508,6 +508,11 @@ void CommandLineInterface::createFile(string const& _fileName, string const& _da BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + pathName)); } +void CommandLineInterface::createJson(string const& _fileName, Json::Value const& _json) +{ + createFile(boost::filesystem::basename(_fileName) + string(".json"), dev::jsonCompactPrint(_json)); +} + bool CommandLineInterface::parseArguments(int _argc, char** _argv) { // Declare the supported options. diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index bf9400e4..97cf2183 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -81,6 +81,11 @@ private: /// @arg _data to be written void createFile(std::string const& _fileName, std::string const& _data); + /// Create a json file in the given directory + /// @arg _fileName the name of the file (the extension will be replaced with .json) + /// @arg _json to be written + void createJson(std::string const& _fileName, Json::Value const& _json); + bool m_error = false; ///< If true, some error occurred. bool m_onlyAssemble = false; -- cgit