libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Network::Web Namespace Reference

Functions

bool getWebsiteExists (const std::string &url)
 Gets whether or not a url points to a valid website.
 
boost::json::value fetchJson (const std::string &url)
 Fetches a json string from a url.
 
bool downloadFile (const std::string &url, const std::filesystem::path &path, const CurlProgressFunction &progress={}, bool overwrite=true)
 Downloads a file to disk.
 

Function Documentation

◆ downloadFile()

bool Nickvision::Network::Web::downloadFile ( const std::string & url,
const std::filesystem::path & path,
const CurlProgressFunction & progress = {},
bool overwrite = true )

Downloads a file to disk.

Parameters
urlThe url of the file to download
pathThe path on disk to save the file
progressAn optional function to receive progress on the download
std::function<int(curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)>
dltotal - The total number of bytes to be downloaded
dlnow - The total number of bytes currently downloaded
ultotal - The total number of bytes to be uploaded (will always be 0)
ulnow - The total number of bytes currently uploaded (will always be 0)
overwriteWhether or not to overwrite existing files on disk

◆ fetchJson()

boost::json::value Nickvision::Network::Web::fetchJson ( const std::string & url)

Fetches a json string from a url.

Parameters
urlThe url of the json string
Returns
The fetched json value

◆ getWebsiteExists()

bool Nickvision::Network::Web::getWebsiteExists ( const std::string & url)

Gets whether or not a url points to a valid website.

Parameters
urlThe url to check
Returns
True if valid website, else false