OpenCPN Partial API docs
Loading...
Searching...
No Matches
Downloader Class Reference

Handle downloading of files from remote urls. More...

#include <downloader.h>

Inheritance diagram for Downloader:
GuiDownloader

Public Member Functions

 Downloader (std::string url)
 
bool download (std::ostream *stream)
 Download url into stream, return false on errors. More...
 
bool download (std::string &path)
 Download url into path. More...
 
int last_errorcode ()
 Last error code, a CURLE return code. More...
 
std::string last_error ()
 Last Curl error message. More...
 
virtual void on_chunk (const char *buff, unsigned bytes)
 Called when given bytes has been transferred from remote. More...
 

Protected Member Functions

long get_filesize ()
 Try to get remote filesize, return 0 on failure. More...
 

Protected Attributes

std::string url
 
std::ostream * stream
 
std::string error_msg
 
int errorcode
 

Detailed Description

Handle downloading of files from remote urls.

Default downloader, usable in a CLI context.

Definition at line 34 of file downloader.h.

Constructor & Destructor Documentation

◆ Downloader()

Downloader::Downloader ( std::string  url)

Definition at line 44 of file downloader.cpp.

Member Function Documentation

◆ download() [1/2]

bool Downloader::download ( std::ostream *  stream)

Download url into stream, return false on errors.

Definition at line 55 of file downloader.cpp.

◆ download() [2/2]

bool Downloader::download ( std::string &  path)

Download url into path.

If path is empty, set it to a temporary filename used. Return false on errors.

Definition at line 83 of file downloader.cpp.

◆ get_filesize()

long Downloader::get_filesize ( )
protected

Try to get remote filesize, return 0 on failure.

Definition at line 99 of file downloader.cpp.

◆ last_error()

std::string Downloader::last_error ( )

Last Curl error message.

Definition at line 49 of file downloader.cpp.

◆ last_errorcode()

int Downloader::last_errorcode ( )

Last error code, a CURLE return code.

Definition at line 47 of file downloader.cpp.

◆ on_chunk()

void Downloader::on_chunk ( const char *  buff,
unsigned  bytes 
)
virtual

Called when given bytes has been transferred from remote.

Reimplemented in GuiDownloader.

Definition at line 51 of file downloader.cpp.

Member Data Documentation

◆ error_msg

std::string Downloader::error_msg
protected

Definition at line 62 of file downloader.h.

◆ errorcode

int Downloader::errorcode
protected

Definition at line 63 of file downloader.h.

◆ stream

std::ostream* Downloader::stream
protected

Definition at line 61 of file downloader.h.

◆ url

std::string Downloader::url
protected

Definition at line 60 of file downloader.h.


The documentation for this class was generated from the following files: