7#include "semantic_version.hpp"
8#include "../algorithm/algorithm.hpp"
9#include "../macros.hpp"
13#include <source_location>
15hi_export_module(hikogui.metadata.metadata_application);
17hi_export
namespace 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;
24hi_export [[nodiscard]]
inline std::string const& get_application_name()
28 if (_application_name) {
29 return *_application_name;
31 throw std::logic_error(
"set_application_name() should be called at application startup.");
35hi_export [[nodiscard]]
inline std::string const& get_application_slug()
39 if (_application_slug) {
40 return *_application_slug;
42 throw std::logic_error(
"set_application_name() should be called at application startup.");
46hi_export [[nodiscard]]
inline std::string const& get_application_vendor()
50 if (_application_vendor) {
51 return *_application_vendor;
53 throw std::logic_error(
"set_application_vendor() should be called at application startup.");
57hi_export [[nodiscard]]
inline semantic_version
const& get_application_version()
61 if (_application_version) {
62 return *_application_version;
64 throw std::logic_error(
"set_application_version() should be called at application startup.");
68hi_export
inline void set_application_name(std::string_view name, std::string_view slug)
75 if (name.contains(
'/') or name.contains(
'\\')) {
81 if (not is_slug(slug)) {
82 throw std::invalid_argument(
"application slug must contain only 'a'-'z' '0'-'9' and '-' characters.");
85 _application_name = name;
86 _application_slug = slug;
89hi_export
inline void set_application_name(std::string_view name)
93 return set_application_name(name,
make_slug(name));
96hi_export
inline void set_application_vendor(std::string_view name)
103 if (name.contains(
'/') or name.contains(
'\\')) {
107 _application_vendor = name;
110hi_export
inline void set_application_version(semantic_version version)
noexcept
114 _application_version = version;
117hi_export
inline void set_application_version(
int major,
int minor = 0,
int patch = 0) noexcept
121 return set_application_version(semantic_version{major, minor, patch});
The HikoGUI namespace.
Definition array_generic.hpp:20
void initialize() noexcept
Initialize base functionality of HikoGUI.
Definition initialize.hpp:56
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
constexpr std::string make_slug(std::string_view str) noexcept
Create a slug from a string.
Definition strings.hpp:254