morph
0.1.0
Asynchronous bridge between GUI thread and business models
Toggle main menu visibility
Loading...
Searching...
No Matches
version.hpp
1
// SPDX-License-Identifier: Apache-2.0
2
3
#pragma once
4
#include <string_view>
5
6
// The five macros below are the `#if`-testable half of morph's version API, and
7
// being macros is the whole of what they are for. A downstream compiling against
8
// two morph releases writes
9
//
10
// #if MORPH_VERSION >= MORPH_MAKE_VERSION(1, 2, 0)
11
//
12
// which the preprocessor has to answer before any C++ declaration exists. An
13
// enumerator or a `constexpr int` is invisible in a `#if`, and a `constexpr`
14
// function cannot be called from one, so `MORPH_MAKE_VERSION` has to be
15
// function-like for the same reason. The three checks below do not propose a
16
// different spelling of this header; they propose removing the capability it
17
// exists to provide. That is the meaning of "unfixable by construction", and it
18
// is why this is a suppression rather than a deferral -- there is no later
19
// version of this file in which the finding goes away.
20
//
21
// The C++-visible constants the checks ask for do exist: `morph::version::kMajor`
22
// and friends, below, defined *from* these macros so the two cannot drift. Code
23
// that does not need a `#if` should use those, and this header offering both is
24
// the resolution, not a duplication.
25
//
26
// docs/spec/VERSIONING.md is the contract; tests/test_version.cpp pins these
27
// against the top-level `project(morph VERSION ...)`.
28
// NOLINTBEGIN(cppcoreguidelines-macro-to-enum, modernize-macro-to-enum, cppcoreguidelines-macro-usage)
29
30
/// @brief morph's major version component (semantic-versioning MAJOR:
31
/// incremented for a breaking source change to the stable public surface —
32
/// see docs/spec/VERSIONING.md).
33
#define MORPH_VERSION_MAJOR 0
34
35
/// @brief morph's minor version component (semantic-versioning MINOR:
36
/// incremented for additive, source-compatible changes).
37
#define MORPH_VERSION_MINOR 1
38
39
/// @brief morph's patch version component (semantic-versioning PATCH: bug
40
/// fixes and doc corrections that change neither the stable surface nor its
41
/// documented behavior).
42
#define MORPH_VERSION_PATCH 0
43
44
/// @brief Packs (major, minor, patch) into one comparable integer
45
/// (`major * 10000 + minor * 100 + patch`), for `#if`-testable feature
46
/// checks against a specific morph release, e.g.
47
/// `#if MORPH_VERSION >= MORPH_MAKE_VERSION(1, 2, 0)`.
48
/// @param major Major version component.
49
/// @param minor Minor version component.
50
/// @param patch Patch version component.
51
#define MORPH_MAKE_VERSION(major, minor, patch) ((major) * 10000 + (minor) * 100 + (patch))
52
53
/// @brief morph's current release, packed via `MORPH_MAKE_VERSION`. Mirrors
54
/// the `VERSION` field of the top-level `project(morph VERSION ...)` in
55
/// `CMakeLists.txt` — the two are cross-checked by `tests/test_version.cpp`.
56
#define MORPH_VERSION MORPH_MAKE_VERSION(MORPH_VERSION_MAJOR, MORPH_VERSION_MINOR, MORPH_VERSION_PATCH)
57
58
// NOLINTEND(cppcoreguidelines-macro-to-enum, modernize-macro-to-enum, cppcoreguidelines-macro-usage)
59
60
namespace
morph::version {
61
62
/// @brief morph's major version component, as a compile-time constant. See `MORPH_VERSION_MAJOR`.
63
inline
constexpr
int
kMajor = MORPH_VERSION_MAJOR;
64
65
/// @brief morph's minor version component, as a compile-time constant. See `MORPH_VERSION_MINOR`.
66
inline
constexpr
int
kMinor = MORPH_VERSION_MINOR;
67
68
/// @brief morph's patch version component, as a compile-time constant. See `MORPH_VERSION_PATCH`.
69
inline
constexpr
int
kPatch = MORPH_VERSION_PATCH;
70
71
/// @brief morph's current release as a dotted string, e.g. `"0.1.0"`.
72
inline
constexpr
std::string_view kString =
"0.1.0"
;
73
74
}
// namespace morph::version
morph
version.hpp
Generated by
1.17.0