|
|
@ -5,6 +5,7 @@
|
|
|
|
#include "svg.h"
|
|
|
|
#include "svg.h"
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
@ -16,50 +17,61 @@ struct Input {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Input
|
|
|
|
Input
|
|
|
|
input_data(istream& Newcin){
|
|
|
|
input_data(istream& Newcin, bool prompt){
|
|
|
|
size_t number_count;
|
|
|
|
size_t number_count;
|
|
|
|
cerr << "Enter number count: ";
|
|
|
|
cerr << "Enter number count: ";
|
|
|
|
Newcin >> number_count;
|
|
|
|
cin >> number_count;
|
|
|
|
bool prompt;
|
|
|
|
|
|
|
|
cerr << "Do you want any prompts? Enter 'true' if yes, 'false' if no: ";
|
|
|
|
|
|
|
|
Newcin >> prompt;
|
|
|
|
|
|
|
|
if (prompt){
|
|
|
|
if (prompt){
|
|
|
|
cerr << "Prompt";
|
|
|
|
cerr << "Prompt" << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Input in;
|
|
|
|
Input in;
|
|
|
|
in.numbers.resize(number_count);
|
|
|
|
in.numbers.resize(number_count);
|
|
|
|
cerr << "Enter numbers: ";
|
|
|
|
cerr << "Enter numbers: ";
|
|
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
|
|
Newcin >> in.numbers[i];
|
|
|
|
cin >> in.numbers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cerr << "Enter bin count: ";
|
|
|
|
cerr << "Enter bin count: ";
|
|
|
|
Newcin >> in.bin_count;
|
|
|
|
cin >> in.bin_count;
|
|
|
|
cerr << "Enter stroke in format RGB: ";
|
|
|
|
cerr << "Enter stroke in format RGB: ";
|
|
|
|
Newcin >> in.stroke;
|
|
|
|
cin >> in.stroke;
|
|
|
|
cerr << "Enter fill in format RGB: ";
|
|
|
|
cerr << "Enter fill in format RGB: ";
|
|
|
|
Newcin >> in.fill;
|
|
|
|
cin >> in.fill;
|
|
|
|
return in;
|
|
|
|
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
|
|
|
|
int
|
|
|
|
main(int argc, char* argv[]) {
|
|
|
|
main(int argc, char* argv[]) {
|
|
|
|
|
|
|
|
Input input;
|
|
|
|
if (argc > 1) {
|
|
|
|
if (argc > 1) {
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
input = download(argv[1]);
|
|
|
|
if(curl) {
|
|
|
|
} else {
|
|
|
|
CURLcode res;
|
|
|
|
input = input_data(cin, true);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
|
|
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
|
|
|
if (res != 0){
|
|
|
|
|
|
|
|
cout << curl_easy_strerror(res);
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
|
|
|
|
|
|
auto in = input_data(cin);
|
|
|
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
show_histogram_svg(bins, in.stroke, in.fill);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|