aboutsummaryrefslogtreecommitdiff
path: root/include/oboe/Version.h
blob: a410f0f4572e127122acefbe8706f4c2865a03d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OBOE_VERSIONINFO_H
#define OBOE_VERSIONINFO_H

#include <cstdint>

/**
 * A note on use of preprocessor defines:
 *
 * This is one of the few times when it's suitable to use preprocessor defines rather than constexpr
 * Why? Because C++11 requires a lot of boilerplate code to convert integers into compile-time
 * string literals. The preprocessor, despite it's lack of type checking, is more suited to the task
 *
 * See: https://stackoverflow.com/questions/6713420/c-convert-integer-to-string-at-compile-time/26824971#26824971
 *
 */

// Type: 8-bit unsigned int. Min value: 0 Max value: 255. See below for description.
#define OBOE_VERSION_MAJOR 1

// Type: 8-bit unsigned int. Min value: 0 Max value: 255. See below for description.
#define OBOE_VERSION_MINOR 8

// Type: 16-bit unsigned int. Min value: 0 Max value: 65535. See below for description.
#define OBOE_VERSION_PATCH 2

#define OBOE_STRINGIFY(x) #x
#define OBOE_TOSTRING(x) OBOE_STRINGIFY(x)

// Type: String literal. See below for description.
#define OBOE_VERSION_TEXT \
        OBOE_TOSTRING(OBOE_VERSION_MAJOR) "." \
        OBOE_TOSTRING(OBOE_VERSION_MINOR) "." \
        OBOE_TOSTRING(OBOE_VERSION_PATCH)

// Type: 32-bit unsigned int. See below for description.
#define OBOE_VERSION_NUMBER ((OBOE_VERSION_MAJOR << 24) | (OBOE_VERSION_MINOR << 16) | OBOE_VERSION_PATCH)

namespace oboe {

const char * getVersionText();

/**
 * Oboe versioning object
 */
struct Version {
    /**
     * This is incremented when we make breaking API changes. Based loosely on https://semver.org/.
     */
    static constexpr uint8_t Major = OBOE_VERSION_MAJOR;

    /**
     * This is incremented when we add backwards compatible functionality. Or set to zero when MAJOR is
     * incremented.
     */
    static constexpr uint8_t Minor = OBOE_VERSION_MINOR;

    /**
     * This is incremented when we make backwards compatible bug fixes. Or set to zero when MINOR is
     * incremented.
     */
    static constexpr uint16_t Patch = OBOE_VERSION_PATCH;

    /**
     * Version string in the form MAJOR.MINOR.PATCH.
     */
    static constexpr const char * Text = OBOE_VERSION_TEXT;

    /**
     * Integer representation of the current Oboe library version. This will always increase when the
     * version number changes so can be compared using integer comparison.
     */
    static constexpr uint32_t Number = OBOE_VERSION_NUMBER;
};

} // namespace oboe
#endif //OBOE_VERSIONINFO_H