code: работа с буфером, загруженным по сети
Этот коммит содержится в:
50
main.cpp
50
main.cpp
@@ -7,6 +7,8 @@
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -50,36 +52,36 @@ Input input_data(istream& in, bool prompt)
|
|||||||
return stct;
|
return stct;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
Input
|
||||||
|
download(const string& address)
|
||||||
{
|
{
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
stringstream buffer;
|
||||||
|
|
||||||
if (argc > 1)
|
CURL *curl = curl_easy_init();
|
||||||
|
if(curl)
|
||||||
{
|
{
|
||||||
CURL *curl = curl_easy_init();
|
CURLcode res;
|
||||||
if(curl)
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
if (res != CURLE_OK)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
cerr << curl_easy_strerror(res);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
exit(1);
|
||||||
res = curl_easy_perform(curl);
|
|
||||||
if (res != CURLE_OK){
|
|
||||||
cerr << curl_easy_strerror(res);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
}
|
}
|
||||||
return 0;
|
curl_easy_cleanup(curl);
|
||||||
|
}
|
||||||
|
return input_data(buffer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
auto in = input_data(cin, true);
|
|
||||||
|
|
||||||
//Ñîçäàíèå âåêòîðà bins äëÿ ãèñòîãðàììû
|
|
||||||
vector<size_t> bins = make_histogram(in.Numbers, in.bin_count);
|
|
||||||
|
|
||||||
//Âûâîä ãèñòîãðàììû
|
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins);
|
||||||
//show_histogram_text(bins);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user