diff --git a/ssh/node.cpp b/ssh/node.cpp index dd0b9b5..b28a0a0 100644 --- a/ssh/node.cpp +++ b/ssh/node.cpp @@ -83,13 +83,16 @@ namespace ssh { void node::scp_send_file(const std::filesystem::path &from, const std::filesystem::path &to) { std::ifstream input(from, std::ifstream::binary); if (input.is_open()) { - std::string data = dynamic_cast(std::ostringstream{} << input.rdbuf()).str(); + std::ostringstream buffer; + buffer << input.rdbuf(); + std::string data = buffer.str(); input.close(); scp_write_file(to, data); } else { throw std::runtime_error("Cannot find a file"); } - }; + } + void node::scp_download_file(const std::filesystem::path &from, const std::filesystem::path &to) { std::string input = scp_read_file(from); diff --git a/util.cpp b/util.cpp index 07725cc..d06bae4 100644 --- a/util.cpp +++ b/util.cpp @@ -82,17 +82,24 @@ namespace map_reduce { throw std::runtime_error("fail during writing to socket"); } + std::pair, std::unique_ptr> - get_key_value_from_json(const std::string &data, std::unique_ptr &key_factory, - std::unique_ptr &value_factory) { - boost::property_tree::ptree pt{}; - boost::property_tree::json_parser::read_json(dynamic_cast(std::stringstream{} << data), - pt); - if (pt.get(data_end_flag, false)) - throw data_ended_error(); - return {key_factory->create(pt.get("key", "")), - value_factory->create(pt.get("value", ""))}; - } + get_key_value_from_json(const std::string &data, std::unique_ptr &key_factory, + std::unique_ptr &value_factory) { + boost::property_tree::ptree pt{}; + + std::stringstream ss(data); + + boost::property_tree::json_parser::read_json(ss, pt); + + if (pt.get(data_end_flag, false)) + throw data_ended_error(); + + return {key_factory->create(pt.get("key", "")), + value_factory->create(pt.get("value", ""))}; +} + + std::string to_csv(const std::vector, std::unique_ptr>> &key_values,