Сравнить коммиты

...

12 Коммитов

Автор SHA1 Сообщение Дата
ba3805c7cd code: общее задание 4 2024-05-18 22:01:25 +03:00
438cacfdb1 code: почти работает 2024-05-18 20:29:57 +03:00
ed361dae03 code: ошибки curl 2024-05-18 15:06:31 +03:00
b9ccc72d62 code: easy_init 2024-05-18 14:54:36 +03:00
9e1fbe8dbe code: arg 2024-05-18 14:07:43 +03:00
54d52ef37d lib: подключение библиотек 2024-05-18 13:08:00 +03:00
d866ad8079 code: prompt 2024-05-18 12:24:44 +03:00
0bdf67a606 merging 2024-05-18 12:09:27 +03:00
97036095fa code: параметр in 2024-05-18 12:00:44 +03:00
0eb008b27e lib: подключение curl 2024-05-18 11:21:13 +03:00
5bd52d8465 code: prompt 2024-05-06 14:37:31 +03:00
87617b312f code: параметр in 2024-05-06 14:30:29 +03:00
3 изменённых файлов: 56 добавлений и 20 удалений

Просмотреть файл

@@ -33,12 +33,12 @@
<Add option="-fexceptions" /> <Add option="-fexceptions" />
</Compiler> </Compiler>
<Unit filename="histogram.cpp" /> <Unit filename="histogram.cpp" />
<Unit filename="histogram.h" />
<Unit filename="main.cpp" /> <Unit filename="main.cpp" />
<Unit filename="svg.cpp" /> <Unit filename="svg.cpp" />
<Unit filename="svg.h"> <Unit filename="svg.h" />
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="text.cpp" /> <Unit filename="text.cpp" />
<Unit filename="text.h" />
<Extensions> <Extensions>
<lib_finder disable_auto="1" /> <lib_finder disable_auto="1" />
</Extensions> </Extensions>

Просмотреть файл

@@ -1,4 +1,7 @@
#include <curl/curl.h>
#include <vector> #include <vector>
#include <sstream>
#include <string>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "histogram.h" #include "histogram.h"
@@ -11,31 +14,64 @@ struct Input {
}; };
Input Input
input_data() { input_data(istream& in, bool prompt) {
size_t number_count; size_t number_count;
cerr << "Enter number count: "; if (prompt) {cerr << "Enter number count: ";};
cin >> number_count; in >> number_count;
Input in; Input in1;
in.numbers.resize(number_count); in1.numbers.resize(number_count);
cerr << "Enter numbers: "; if (prompt) {cerr << "Enter numbers: ";};
for (size_t i = 0; i < number_count; i++) { for (size_t i = 0; i < number_count; i++) {
cin >> in.numbers[i]; in >> in1.numbers[i];
} }
cerr << "Enter bin count: ";
cin >> in.bin_count;
return in; if (prompt) {cerr << "Enter bin count: ";};
in >> in1.bin_count;
return in1;
} }
int main() static size_t
write_data(void* items, size_t item_size, size_t item_count, void* ctx){
size_t data_size = item_size * item_count;
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
buffer->write(reinterpret_cast<const char*>(items), data_size);
return data_size;
}
Input
download(const string& address){
stringstream buffer;
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
exit(1);
}
curl_easy_cleanup(curl);
}
return input_data(buffer, false);
}
int
main(int argc, char* argv[])
{ {
const size_t SCREEN_WIDTH = 80; #include <curl/curl.h>
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; curl_global_init(CURL_GLOBAL_ALL);
Input input;
auto in = input_data(); if (argc > 1) {
auto bins = make_histogram(in.numbers, in.bin_count); input = download(argv[1]);
show_histogram_svg(bins); } else {
return 0; input = input_data(cin, true);
}
const auto bins = make_histogram(input.numbers, input.bin_count);
show_histogram_svg(bins);
} }

Просмотреть файл

@@ -31,7 +31,7 @@
<Compiler> <Compiler>
<Add option="-Wall" /> <Add option="-Wall" />
</Compiler> </Compiler>
<Unit filename="histogram.cpp" /> <Unit filename="doctest.h" />
<Unit filename="unittest.cpp" /> <Unit filename="unittest.cpp" />
<Extensions> <Extensions>
<lib_finder disable_auto="1" /> <lib_finder disable_auto="1" />