OGLplus  (0.59.0) a C++ wrapper for rendering APIs

build_info.hpp
Go to the documentation of this file.
1 #ifndef EAGINE_BUILD_INFO_HPP
9 #define EAGINE_BUILD_INFO_HPP
10 
11 #include "serialize/fwd.hpp"
12 #include "tribool.hpp"
13 #include "valid_if/nonnegative.hpp"
14 #include <tuple>
15 
16 namespace eagine {
17 
20 class build_info {
21  friend struct serializer<build_info>;
22  friend struct deserializer<build_info>;
23 
24  using _data_tuple = std::tuple<std::tuple<int, int, int, int>>;
25 
26 public:
27  constexpr build_info() noexcept(
28  std::is_nothrow_default_constructible_v<_data_tuple>) = default;
29 
30  static auto query() noexcept -> build_info;
31 
37  auto version_tuple() const noexcept
38  -> const std::tuple<int, int, int, int>& {
39  return std::get<0>(_data);
40  }
41 
47  auto version_major() const noexcept -> valid_if_nonnegative<int> {
48  return {std::get<0>(version_tuple())};
49  }
50 
56  auto version_minor() const noexcept -> valid_if_nonnegative<int> {
57  return {std::get<1>(version_tuple())};
58  }
59 
65  auto version_patch() const noexcept -> valid_if_nonnegative<int> {
66  return {std::get<2>(version_tuple())};
67  }
68 
74  auto version_commit() const noexcept -> valid_if_nonnegative<int> {
75  return {std::get<3>(version_tuple())};
76  }
77 
81  auto has_version() const noexcept -> bool {
82  return version_major() && version_minor();
83  }
84 
86  auto version_at_least(int major, int minor) const -> tribool;
87 
89  auto version_at_least(int major, int minor, int patch) const -> tribool;
90 
92  auto version_at_least(int major, int minor, int patch, int commit) const
93  -> tribool;
94 
95 private:
96  build_info(_data_tuple data) noexcept
97  : _data{std::move(data)} {}
98 
99  _data_tuple _data{{-1, -1, -1, -1}};
100 };
101 
102 } // namespace eagine
103 
104 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
105 #include <eagine/build_info.inl>
106 #endif
107 
108 #endif
Common code is placed in this namespace.
Definition: eagine.hpp:21
Primary template for conditionally valid values.
Definition: decl.hpp:49
auto version_patch() const noexcept -> valid_if_nonnegative< int >
Returns the project patch number.
Definition: build_info.hpp:65
auto version_at_least(int major, int minor) const -> tribool
Checks if the project build version is at least as specified.
auto version_commit() const noexcept -> valid_if_nonnegative< int >
Returns the project commit number.
Definition: build_info.hpp:74
Tri-state boolean value.
Definition: tribool.hpp:61
auto version_major() const noexcept -> valid_if_nonnegative< int >
Returns the project major version number.
Definition: build_info.hpp:47
auto version_minor() const noexcept -> valid_if_nonnegative< int >
Returns the project minor version number.
Definition: build_info.hpp:56
Class providing basic system information.
Definition: build_info.hpp:20
auto version_tuple() const noexcept -> const std::tuple< int, int, int, int > &
Returns the project version numbers in a single tuple.
Definition: build_info.hpp:37
auto has_version() const noexcept -> bool
Indicates if major and minor version numbers are known.
Definition: build_info.hpp:81

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).