7#include "semantic_version.hpp"
8#include "../algorithm/module.hpp"
9#include "../macros.hpp"
13hi_export_module(hikogui.metadata.metadata_application);
17inline std::optional<std::string> _application_name = std::nullopt;
18inline std::optional<std::string> _application_slug = std::nullopt;
19inline std::optional<std::string> _application_vendor = std::nullopt;
20inline std::optional<semantic_version> _application_version = std::nullopt;
24 if (_application_name) {
25 return *_application_name;
27 throw std::logic_error(
"set_application_name() should be called at application startup.");
33 if (_application_slug) {
34 return *_application_slug;
36 throw std::logic_error(
"set_application_name() should be called at application startup.");
42 if (_application_vendor) {
43 return *_application_vendor;
45 throw std::logic_error(
"set_application_vendor() should be called at application startup.");
49[[
nodiscard]]
inline semantic_version
const& get_application_version()
51 if (_application_version) {
52 return *_application_version;
54 throw std::logic_error(
"set_application_version() should be called at application startup.");
58inline void set_application_name(std::string_view name, std::string_view
slug)
63 if (name.contains(
'/')
or name.contains(
'\\')) {
70 throw std::invalid_argument(
"application slug must contain only 'a'-'z' '0'-'9' and '-' characters.");
73 _application_name = name;
74 _application_slug =
slug;
77inline void set_application_name(std::string_view name)
79 return set_application_name(name,
make_slug(name));
82inline void set_application_vendor(std::string_view name)
87 if (name.contains(
'/')
or name.contains(
'\\')) {
91 _application_vendor = name;
94inline void set_application_version(semantic_version version)
noexcept
96 _application_version = version;
99inline void set_application_version(
int major,
int minor = 0,
int patch = 0)
noexcept
101 return set_application_version(semantic_version{major, minor, patch});
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr std::string make_slug(std::string_view str) noexcept
Create a slug from a string.
Definition strings.hpp:254
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377