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 
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;
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
Definition: trigger_flags.h:49
Base module implements mcr_base - Libmacro first module.