1.10
utils.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_UTILS_H
7#define EGT_UTILS_H
8
14#include <egt/detail/meta.h>
15#include <string>
16
17namespace egt
18{
19inline namespace v1
20{
21
25EGT_API std::string egt_version();
26
30EGT_API std::string egt_git_version();
31
35template<class T>
36struct Ratio
37{
42 constexpr Ratio(T value, int ratio) noexcept
43 : m_value(value),
44 m_ratio(ratio)
45 {
46 }
47
51 // NOLINTNEXTLINE(hicpp-explicit-conversions)
52 constexpr operator T() const
53 {
54 return static_cast<double>(m_value) *
55 (static_cast<double>(m_ratio) / 100.);
56 }
57
58protected:
63};
64
65
66namespace detail
67{
69template <class T, std::size_t N>
70constexpr std::size_t size(const T(&)[N]) noexcept
71{
72 return N;
73}
74}
75
76}
77}
78
79#endif
constexpr std::size_t size(const T(&)[N]) noexcept
Return the size of an array (c++17's std::size()).
Definition utils.h:70
EGT_API std::string egt_version()
Get the version of the EGT library.
EGT_API std::string egt_git_version()
Get the git version of the EGT library.
EGT framework namespace.
Definition animation.h:24
Creates and stores a simple ratio value.
Definition utils.h:37
int m_ratio
Ratio.
Definition utils.h:62
constexpr Ratio(T value, int ratio) noexcept
Definition utils.h:42
T m_value
Value.
Definition utils.h:60