7#include "semantic_version.hpp"
8#include "../algorithm/module.hpp"
9#include "../macros.hpp"
13#include <source_location>
15hi_export_module(hikogui.metadata.metadata_application);
17namespace hi {
inline namespace v1 {
19inline std::optional<std::string> _application_name = std::nullopt;
20inline std::optional<std::string> _application_slug = std::nullopt;
21inline std::optional<std::string> _application_vendor = std::nullopt;
22inline std::optional<semantic_version> _application_version = std::nullopt;
26 if (_application_name) {
27 return *_application_name;
29 throw std::logic_error(
"set_application_name() should be called at application startup.");
35 if (_application_slug) {
36 return *_application_slug;
38 throw std::logic_error(
"set_application_name() should be called at application startup.");
44 if (_application_vendor) {
45 return *_application_vendor;
47 throw std::logic_error(
"set_application_vendor() should be called at application startup.");
51hi_export [[
nodiscard]]
inline semantic_version
const& get_application_version()
53 if (_application_version) {
54 return *_application_version;
56 throw std::logic_error(
"set_application_version() should be called at application startup.");
60hi_export
inline void set_application_name(std::string_view name, std::string_view
slug)
65 if (name.contains(
'/')
or name.contains(
'\\')) {
72 throw std::invalid_argument(
"application slug must contain only 'a'-'z' '0'-'9' and '-' characters.");
75 _application_name = name;
76 _application_slug =
slug;
79hi_export
inline void set_application_name(std::string_view name)
81 return set_application_name(name,
make_slug(name));
84hi_export
inline void set_application_vendor(std::string_view name)
89 if (name.contains(
'/')
or name.contains(
'\\')) {
93 _application_vendor = name;
96hi_export
inline void set_application_version(semantic_version version)
noexcept
98 _application_version = version;
101hi_export
inline void set_application_version(
int major,
int minor = 0,
int patch = 0)
noexcept
103 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
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377