karazeh
A cross-platform software updating library.
kzh::version_manifest Class Reference

#include <version_manifest.hpp>

Public Member Functions

 version_manifest (config_t const &)
 
virtual ~version_manifest ()
 
vector< string_tget_available_updates (const string_t &current_version) const
 
string_t get_current_version () const
 
release_manifest const * get_release (const string_t &) const
 
int get_release_count () const
 
int get_release_count (string_t const &identity) const
 
void load_from_string (string_t const &raw_json)
 
void load_from_uri (string_t const &uri)
 
void load_release_from_string (string_t const &raw_json)
 
void load_release_from_uri (string_t const &)
 
void parse (JSON const &)
 
void parse_release (JSON const &)
 

Constructor & Destructor Documentation

kzh::version_manifest::version_manifest ( config_t const &  config)
explicit
kzh::version_manifest::~version_manifest ( )
virtual

Member Function Documentation

string_t kzh::version_manifest::get_current_version ( ) const

Attempt to identify the current application version.

Returns
A string representing the release "id", and an empty one if the version could not be identified.
Exceptions
std::domain_error
  • if an identity file is unreadable
  • if an identity file could not be checksummed

References kzh::hasher::digest_rc::digest, kzh::KARAZEH_EXPORT::file_manager, kzh::KARAZEH_EXPORT::hasher, kzh::hasher::hex_digest(), and kzh::file_manager::is_readable().

Referenced by TEST_CASE().

const release_manifest * kzh::version_manifest::get_release ( const string_t id) const

If no such release could be found, the behavior is undefined.

Referenced by TEST_CASE().

int kzh::version_manifest::get_release_count ( ) const
Returns
The number of tracked releases for all identities.

Referenced by TEST_CASE().

int kzh::version_manifest::get_release_count ( string_t const &  identity) const
Returns
The number of tracked releases for a certain identity.
void kzh::version_manifest::load_from_string ( string_t const &  raw_json)

A convenience method for parsing a JSON manifest from a string. This implicitly calls parse().

This function is equivalent to manually parsing JSON into an object and feeding it to parse.

Exceptions
kzh::invalid_manifestIf the supplied JSON string is malformed or could not be parsed for some reason.

References parse().

Referenced by load_from_uri(), and TEST_CASE().

void kzh::version_manifest::load_from_uri ( string_t const &  uri)

A convenience method for downloading a JSON manifest from a remote server and parsing it. This implicitly calls load_from_string() and parse().

Exceptions
kzh::invalid_resourceIf the resource at the supplied URI could not be downloaded.

References kzh::KARAZEH_EXPORT::downloader, kzh::downloader::fetch(), and load_from_string().

Referenced by TEST_CASE().

void kzh::version_manifest::load_release_from_string ( string_t const &  raw_json)

A convenience method for parsing a JSON release manifest from a string. This implicitly calls parse_release().

Exceptions
kzh::invalid_manifestIf the supplied JSON string is malformed or could not be parsed for some reason.

References parse_release().

Referenced by load_release_from_uri().

void kzh::version_manifest::load_release_from_uri ( string_t const &  uri)

A convenience method for downloading a JSON release manifest from a remote server and then parsing it. This implicitly calls load_release_from_string() and parse_release().

Exceptions
kzh::invalid_manifestIf the supplied JSON string is malformed or could not be parsed for some reason.

References kzh::KARAZEH_EXPORT::downloader, kzh::downloader::fetch(), and load_release_from_string().

Referenced by TEST_CASE().

void kzh::version_manifest::parse ( JSON const &  manifest)

Populate the version manifest object from a JSON manifest.

This method tracks the identity lists defined in the manifest as well as the release definitions.

Exceptions
kzh::invalid_manifest
  • if the manifest could not be parsed
  • if the manifest has no identity lists
  • if the manifest has no releases
  • if an identity list construct has no "name"
  • if an identity list construct has no "files" or an empty "files" list
  • if a release construct is missing the "id" attribute
  • if a release construct is missing the "identity" attribute
  • if a release construct's "identity" attribute points to an undefined identity list
std::domain_error
  • if an identity file is unreadable

This function is NOT idempotent. This function has implicit side-effects on the tracked identity list and release containers.

References kzh::KARAZEH_EXPORT::file_manager, kzh::file_manager::is_readable(), kzh::KARAZEH_EXPORT::root_path, and kzh::validate_schema.

Referenced by load_from_string().

void kzh::version_manifest::parse_release ( JSON const &  manifest)

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