Libmacro
0.2
Libmacro is an extensible macro and hotkey library.
trigger_flags.h
Go to the documentation of this file.
1
/* Libmacro - A multi-platform, extendable macro and hotkey C library
2
Copyright (C) 2013 Jonathan Pelletier, New Paradigm Software
3
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
8
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
13
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
23
#ifndef MCR_STANDARD_TRIGGER_FLAGS_H_
24
#define MCR_STANDARD_TRIGGER_FLAGS_H_
25
26
#include "
mcr/base/base.h
"
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
31
49
enum
mcr_TriggerFlags
{
51
MCR_TF_UNDEFINED
= 0,
53
MCR_TF_NONE
= 1,
55
MCR_TF_SOME
=
MCR_TF_NONE
<< 1,
57
MCR_TF_INEQUAL
=
MCR_TF_NONE
|
MCR_TF_SOME
,
59
MCR_TF_ALL
=
MCR_TF_SOME
<< 1,
61
MCR_TF_ALL_OR_NOTHING
=
MCR_TF_NONE
|
MCR_TF_ALL
,
63
MCR_TF_MATCH
=
MCR_TF_SOME
|
MCR_TF_ALL
,
65
MCR_TF_ANY
=
MCR_TF_NONE
|
MCR_TF_SOME
|
MCR_TF_ALL
,
67
MCR_TF_USER
=
MCR_TF_ALL
<< 1
68
};
70
#define MCR_TF_MASK(number) (MCR_TF_ANY & (number))
71
75
#define MCR_TF_USER_MASK(number) ((number) & (~MCR_TF_ANY))
76
84
static
MCR_INLINE
bool
mcr_TriggerFlags_match(
unsigned
int
triggerFlags,
unsigned
int
lhsFlags,
85
unsigned
int
rhsFlags)
86
{
87
switch
(triggerFlags) {
88
case
MCR_TF_NONE
:
89
return
!(lhsFlags & rhsFlags);
90
break
;
91
case
MCR_TF_SOME
:
92
return
lhsFlags != rhsFlags && (lhsFlags & rhsFlags);
93
break
;
94
case
MCR_TF_INEQUAL
:
95
return
lhsFlags != rhsFlags;
96
break
;
97
case
MCR_TF_ALL
:
98
return
lhsFlags == rhsFlags;
99
break
;
100
case
MCR_TF_ALL_OR_NOTHING
:
101
return
lhsFlags == rhsFlags || !(lhsFlags & rhsFlags);
102
break
;
103
case
MCR_TF_MATCH
:
104
return
!!(lhsFlags & rhsFlags);
105
break
;
106
case
MCR_TF_ANY
:
107
return
true
;
108
break
;
109
default
:
110
// mcr_dmsg;
111
// fprintf(stderr, "Error: Invalid "
112
// MCR_STR(enum mcr_TriggerFlags) "%u\n", triggerFlags);
113
break
;
114
}
115
return
false
;
116
}
117
118
#ifdef __cplusplus
119
}
120
#endif
121
122
#endif
mcr_TriggerFlags
mcr_TriggerFlags
Definition:
trigger_flags.h:49
MCR_TF_MATCH
Definition:
trigger_flags.h:63
MCR_TF_UNDEFINED
Definition:
trigger_flags.h:51
MCR_TF_NONE
Definition:
trigger_flags.h:53
MCR_TF_SOME
Definition:
trigger_flags.h:55
MCR_TF_USER
Definition:
trigger_flags.h:67
base.h
Base module implements mcr_base - Libmacro first module.
MCR_TF_ALL_OR_NOTHING
Definition:
trigger_flags.h:61
MCR_TF_ANY
Definition:
trigger_flags.h:65
MCR_TF_ALL
Definition:
trigger_flags.h:59
MCR_TF_INEQUAL
Definition:
trigger_flags.h:57
mcr
standard
trigger_flags.h
Generated on Sun Sep 27 2020 01:58:03 for Libmacro by
1.8.12