libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Update::Updater Class Reference

An object to check for and download new releases through GitHub. More...

#include <updater.h>

Public Member Functions

 Updater (std::string githubRepoUrl)
 Constructs an Updater.
 
 Updater (const Updater &u) noexcept
 Constructs an Updater via copy.
 
 Updater (Updater &&u) noexcept
 Constructs an Updater via move.
 
Version fetchCurrentVersion (VersionType versionType) noexcept
 Gets the latest version of the provided type from the GitHub repo.
 
bool downloadUpdate (VersionType versionType, const std::filesystem::path &path, const std::string &assetName, bool exactMatch=true, const cpr::ProgressCallback &progress={}) noexcept
 Downloads an update for the application.
 
bool windowsUpdate (VersionType versionType, const cpr::ProgressCallback &progress={}) noexcept
 Downloads and installs an application update for Windows.
 
Updateroperator= (const Updater &u) noexcept
 Copies an Updater.
 
Updateroperator= (Updater &&u) noexcept
 Moves an Updater.
 

Detailed Description

An object to check for and download new releases through GitHub.

Constructor & Destructor Documentation

◆ Updater() [1/3]

Nickvision::Update::Updater::Updater ( std::string githubRepoUrl)

Constructs an Updater.

Parameters
githubRepoUrlThe url of the GitHub repo to fetch updates for
Exceptions
std::invalid_argumentThrown if the GitHub url is not of valid format

◆ Updater() [2/3]

Nickvision::Update::Updater::Updater ( const Updater & u)
noexcept

Constructs an Updater via copy.

Parameters
uThe object to copy

◆ Updater() [3/3]

Nickvision::Update::Updater::Updater ( Updater && u)
noexcept

Constructs an Updater via move.

Parameters
uThe object to move

Member Function Documentation

◆ downloadUpdate()

bool Nickvision::Update::Updater::downloadUpdate ( VersionType versionType,
const std::filesystem::path & path,
const std::string & assetName,
bool exactMatch = true,
const cpr::ProgressCallback & progress = {} )
noexcept

Downloads an update for the application.

fetchCurrentVersion should be called first before running this method.

Parameters
versionTypeThe type of version update to download
pathThe path to save the downloaded file
assetNameThe name of the asset to download
exactMatchIf true, the asset name must match exactly, else it can be a substring
progressAn optional cpr::ProgressCallback to track the downloading update
Returns
True if successful, else false

◆ fetchCurrentVersion()

Version Nickvision::Update::Updater::fetchCurrentVersion ( VersionType versionType)
noexcept

Gets the latest version of the provided type from the GitHub repo.

This method looks for tags in the format major.minor.build-dev or major.minor.build.dev for preview versions and major.minor.build for stable versions.

Parameters
versionTypeThe type of the version to get
Returns
The current version of the provided type if available, else empty Version

◆ operator=() [1/2]

Updater & Nickvision::Update::Updater::operator= ( const Updater & u)
noexcept

Copies an Updater.

Parameters
uThe Updater to copy
Returns
this

◆ operator=() [2/2]

Updater & Nickvision::Update::Updater::operator= ( Updater && u)
noexcept

Moves an Updater.

Parameters
uThe Updater to move
Returns
this

◆ windowsUpdate()

bool Nickvision::Update::Updater::windowsUpdate ( VersionType versionType,
const cpr::ProgressCallback & progress = {} )
noexcept

Downloads and installs an application update for Windows.

fetchCurrentVersion should be called first before running this method.

This method will download the asset that contains "setup.exe" in its name and run it.

Parameters
versionTypeThe type of version update to install
progressAn optional cpr::ProgressCallback to track the downloading update
Returns
True if successful, else false

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