работа с буфером, загруженным по сети

master
Yaroslav Spesivtsev 5 дней назад
Родитель dce3a5e3ea
Сommit c3dfd48d9c

@ -1,10 +1,12 @@
#include <iostream>
#include <vector>
#include "histogram.h"
#include "text.h"
#include <string>
#include <sstream>
#include <curl/curl.h>
#include <cstdlib>
#include "histogram.h"
#include "text.h"
struct Input{
std::vector<double> numbers;
size_t bin_count{};
@ -36,32 +38,39 @@ Input input_data(std::istream& in, bool prompt) {
return result;
};
Input download(const std::string&address){
std::stringstream buffer;
CURL* curl = curl_easy_init();
if(curl) {
using namespace std;
int main(int argc, char* argv[]) {
curl_global_init(CURL_GLOBAL_ALL);
if (argc>1){
CURL *curl = curl_easy_init();
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
if(curl) {
TODO:
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
res = curl_easy_perform(curl);
if (res != CURLE_OK){
cerr << curl_easy_strerror(res);
std::cerr << curl_easy_strerror(res);
curl_easy_cleanup(curl);
exit(1);
}
curl_easy_cleanup(curl);
}
return 0;
return input_data(buffer, false);
}
using namespace std;
int main(int argc, char* argv[]) {
curl_global_init(CURL_GLOBAL_ALL);
Input input;
if (argc > 1) {
input = download(argv[1]);
} else {
input = input_data(cin, true);
}
Input in = input_data(std::cin, true);
auto bins = make_histogram(in.numbers, in.bin_count);
const auto bins = make_histogram(input.numbers, input.bin_count);
show_histogram_svg(bins);
return 0;
}

Загрузка…
Отмена
Сохранить