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

Default downloader, usable in a CLI context. More...

#include "model/downloader.h"

Inheritance diagram for Downloader:
GuiDownloader

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Default downloader, usable in a CLI context.

Definition at line 35 of file downloader.h.

Constructor & Destructor Documentation

◆ Downloader()

Downloader::Downloader ( std::string url)
explicit

Definition at line 55 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 66 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 94 of file downloader.cpp.

◆ get_filesize()

long Downloader::get_filesize ( )
protected

Try to get remote filesize, return 0 on failure.

Definition at line 110 of file downloader.cpp.

◆ last_error()

std::string Downloader::last_error ( )

Last Curl error message.

Definition at line 60 of file downloader.cpp.

◆ last_errorcode()

int Downloader::last_errorcode ( )

Last error code, a CURLE return code.

Definition at line 58 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 62 of file downloader.cpp.

Member Data Documentation

◆ error_msg

std::string Downloader::error_msg
protected

Definition at line 68 of file downloader.h.

◆ errorcode

int Downloader::errorcode
protected

Definition at line 69 of file downloader.h.

◆ stream

std::ostream* Downloader::stream
protected

Definition at line 67 of file downloader.h.

◆ url

std::string Downloader::url
protected

Definition at line 66 of file downloader.h.


The documentation for this class was generated from the following files:
  • /home/runner/work/main/main/opencpn/model/include/model/downloader.h
  • /home/runner/work/main/main/opencpn/model/src/downloader.cpp