#include #include #include "histogram.h" #include "text.h" #include "svg.h" #include #include #include using namespace std; struct Input { vector numbers; size_t bin_count{}; string stroke; string fill; }; Input input_data(istream& Newcin, bool prompt){ size_t number_count; cerr << "Enter number count: "; cin >> number_count; if (prompt){ cerr << "Prompt" << endl; } Input in; in.numbers.resize(number_count); cerr << "Enter numbers: "; for (size_t i = 0; i < number_count; i++) { cin >> in.numbers[i]; } cerr << "Enter bin count: "; cin >> in.bin_count; cerr << "Enter stroke in format RGB: "; cin >> in.stroke; cerr << "Enter fill in format RGB: "; cin >> in.fill; return in; } Input download(const string& address) { curl_global_init(CURL_GLOBAL_ALL); stringstream buffer; CURL *curl = curl_easy_init(); if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, address); res = curl_easy_perform(curl); if (res != 0){ cout << curl_easy_strerror(res); exit(1); } } curl_easy_cleanup(curl); return input_data(buffer, false); } size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx) { return 0; } int main(int argc, char* argv[]) { Input input; if (argc > 1) { input = download(argv[1]); } else { input = input_data(cin, true); } const auto bins = make_histogram(input.numbers, input.bin_count); show_histogram_svg(bins); }