OpenCPN Partial API docs
Loading...
Searching...
No Matches
downloader.h
1/******************************************************************************
2 *
3 * Project: OpenCPN
4 *
5 ***************************************************************************
6 * Copyright (C) 2019 Alec Leamas *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 ***************************************************************************
23 */
24
27#ifndef DOWNLOADER_H__
28#define DOWNLOADER_H__
29
30#include <string>
31#include <ostream>
32
35public:
36 Downloader(std::string url);
37
39 bool download(std::ostream* stream);
40
45 bool download(std::string& path);
46
48 int last_errorcode();
49
51 std::string last_error();
52
54 virtual void on_chunk(const char* buff, unsigned bytes);
55
56protected:
58 long get_filesize();
59
60 std::string url;
61 std::ostream* stream;
62 std::string error_msg;
63 int errorcode;
64};
65
66#endif // DOWNLOADER_H__
Handle downloading of files from remote urls.
Definition: downloader.h:34
bool download(std::ostream *stream)
Download url into stream, return false on errors.
Definition: downloader.cpp:55
long get_filesize()
Try to get remote filesize, return 0 on failure.
Definition: downloader.cpp:99
std::string last_error()
Last Curl error message.
Definition: downloader.cpp:49
virtual void on_chunk(const char *buff, unsigned bytes)
Called when given bytes has been transferred from remote.
Definition: downloader.cpp:51
int last_errorcode()
Last error code, a CURLE return code.
Definition: downloader.cpp:47