|  |  | @ -1,12 +1,12 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <iostream> |  |  |  | #include <iostream> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <vector> |  |  |  | #include <vector> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <string> |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <sstream> |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <curl/curl.h> |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <cstdlib> |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "histogram.h" |  |  |  | #include "histogram.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "text.h" |  |  |  | #include "text.h" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #include "svg.h" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #include <curl/curl.h> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #include <sstream> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #include <string> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | struct Input{ |  |  |  | struct Input{ | 
			
		
	
		
		
			
				
					
					|  |  |  |     std::vector<double> numbers; |  |  |  |     std::vector<double> numbers; | 
			
		
	
		
		
			
				
					
					|  |  |  |     size_t bin_count{}; |  |  |  |     size_t bin_count{}; | 
			
		
	
	
		
		
			
				
					|  |  | @ -37,7 +37,13 @@ Input input_data(std::istream& in, bool prompt) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     return result; |  |  |  |     return result; | 
			
		
	
		
		
			
				
					
					|  |  |  | }; |  |  |  | }; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | size_t write_data(void*items,size_t item_size, size_t item_count, void* ctx){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     size_t data_size = item_size * item_count; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     std::stringstream* buffer = static_cast<std::stringstream*>(ctx); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      buffer->write(static_cast<char*>(items), data_size); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     return data_size; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | Input download(const std::string&address){ |  |  |  | Input download(const std::string&address){ | 
			
		
	
		
		
			
				
					
					|  |  |  |     std::stringstream buffer; |  |  |  |     std::stringstream buffer; | 
			
		
	
		
		
			
				
					
					|  |  |  |     CURL* curl = curl_easy_init(); |  |  |  |     CURL* curl = curl_easy_init(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -45,9 +51,8 @@ Input download(const std::string&address){ | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             CURLcode res; |  |  |  |             CURLcode res; | 
			
		
	
		
		
			
				
					
					|  |  |  |             curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); |  |  |  |             curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |             curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             TODO: |  |  |  |             curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             res = curl_easy_perform(curl); |  |  |  |             res = curl_easy_perform(curl); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (res != CURLE_OK){ |  |  |  |             if (res != CURLE_OK){ | 
			
		
	
	
		
		
			
				
					|  |  | @ -59,10 +64,10 @@ Input download(const std::string&address){ | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     return input_data(buffer, false); |  |  |  |     return input_data(buffer, false); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | using namespace std; |  |  |  | using namespace std; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | int main(int argc, char* argv[]) { |  |  |  | int main(int argc, char* argv[]) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     curl_global_init(CURL_GLOBAL_ALL); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     Input input; |  |  |  |     Input input; | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (argc > 1) { |  |  |  |     if (argc > 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         input = download(argv[1]); |  |  |  |         input = download(argv[1]); | 
			
		
	
	
		
		
			
				
					|  |  | @ -70,7 +75,7 @@ int main(int argc, char* argv[]) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         input = input_data(cin, true); |  |  |  |         input = input_data(cin, true); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     const auto bins = make_histogram(input.numbers, input.bin_count); |  |  |  |     auto bins = make_histogram(input.numbers, input.bin_count); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     show_histogram_svg(bins); |  |  |  |     show_histogram_svg(bins); | 
			
		
	
		
		
			
				
					
					|  |  |  |     return 0; |  |  |  |     return 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |