Sayonara Player
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Utils
globals.h
1
/* globals.h */
2
3
/* Copyright (C) 2012 Michael Lugmair (Lucio Carreras)
4
*
5
* This file is part of sayonara player
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
#ifndef GLOBALS_H_
22
#define GLOBALS_H_
23
24
#include <type_traits>
25
26
#ifndef CAST_MACROS
27
#define scast(x, y) static_cast<x>(y)
28
#define dcast(x, y) dynamic_cast<x>(y)
29
#define rcast(x, y) reinterpret_cast<x>(y)
30
#define CAST_MACROS
31
#endif
32
33
#define DARK_BLUE(x) QString("<font color=#0000FF>") + x + QString("</font>")
34
#define LIGHT_BLUE(x) QString("<font color=#8888FF>") + x + QString("</font>")
35
36
#define CAR_RET QString("<br />")
37
#define BOLD(x) QString("<b>") + x + QString("</b>")
38
#define BLACK(x) QString("<font color=#000000>") + x + QString("</font>")
39
40
41
// name, target, dark, string
42
#define LINK(n, t, d, s) if(d) s=QString("<a href=\"t\">)") + LIGHT_BLUE(n) + QString("</a>"); \
43
else s=QString("<a href=\"t\">)") + DARK_BLUE(n) + QString("</a>");
44
45
#define SAYONARA_ORANGE_STR QString("#e8841a")
46
#define SAYONARA_ORANGE_COL QColor(232, 132, 26)
47
48
namespace
Util
49
{
50
template
<
typename
TINT,
typename
T>
51
typename
std::enable_if<std::is_pointer<T>::value,
bool
>::type
52
between(TINT idx,
const
T& cont)
53
{
54
return
(idx >= 0 && idx <
static_cast<
TINT
>
(cont->size()));
55
}
56
57
template
<
typename
TINT,
typename
T>
58
typename
std::enable_if<std::is_class<T>::value,
bool
>::type
59
between(TINT idx,
const
T& cont)
60
{
61
return
(idx >= 0 && idx <
static_cast<
TINT
>
(cont.size()));
62
}
63
64
template
<
typename
TINT>
65
typename
std::enable_if<std::is_integral<TINT>::value,
bool
>::type
66
between(TINT idx, TINT max)
67
{
68
return
(idx >= 0 && idx < max);
69
}
70
71
enum
SaveAsAnswer
72
{
73
Success,
74
InvalidName,
75
NotStorable,
76
NameAlreadyThere,
77
InvalidObject,
78
OtherError
79
};
80
}
81
82
template
<
typename
T>
83
typename
std::enable_if<std::is_enum<T>::value,
typename
std::underlying_type<T>::type>::type
84
constexpr
operator+(T enumValue)
85
{
86
return
static_cast<
typename std::underlying_type<T>::type
>
(enumValue);
87
}
88
89
#endif
/* GLOBALS_H_ */
Util
Helper functions.
Definition
MetaTypeRegistry.h:25
Generated on
for Sayonara Player by
1.17.0