Develop Biology
The language of life
SanitizeMacros.h
Go to the documentation of this file.
1
/*
2
* This file is a part of the Biology project by eons LLC.
3
* Biology (aka Develop Biology) is a framework for approaching software
4
* development from a natural sciences perspective.
5
*
6
* Copyright (C) 2022 Séon O'Shannon & eons LLC
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Affero General Public License as
10
* published by the Free Software Foundation, either version 3 of the
11
* License, or (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
17
*
18
* You should have received a copy of the GNU Affero General Public License
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
*/
21
22
#pragma once
23
24
#include "
CacheMacros.h
"
25
26
43
#define BIO_SANITIZE_AT_SAFETY_LEVEL_0(test, success, failure) \
44
{ \
45
success; \
46
}
47
48
#define BIO_SANITIZE_AT_SAFETY_LEVEL_1(test, success, failure) \
49
{ \
50
BIO_ASSERT(test); \
51
success; \
52
}
53
54
#define BIO_SANITIZE_AT_SAFETY_LEVEL_2(test, success, failure) \
55
if (test) \
56
{ \
57
success; \
58
} \
59
else \
60
{ \
61
failure; \
62
}
63
64
//@formatter:off
65
#if defined(BIO_SAFETY_LEVEL) && BIO_SAFETY_LEVEL == 0
66
#define BIO_SANITIZE(test, success, failure) BIO_SANITIZE_AT_SAFETY_LEVEL_0(test, BIO_SINGLE_ARG(success), BIO_SINGLE_ARG(failure))
67
#elif defined(BIO_SAFETY_LEVEL) && BIO_SAFETY_LEVEL == 1
68
#define BIO_SANITIZE(test, success, failure) BIO_SANITIZE_AT_SAFETY_LEVEL_1(test, BIO_SINGLE_ARG(success), BIO_SINGLE_ARG(failure))
69
#else
70
#define BIO_SANITIZE(test, success, failure) BIO_SANITIZE_AT_SAFETY_LEVEL_2(test, BIO_SINGLE_ARG(success), BIO_SINGLE_ARG(failure))
71
#endif
72
//@formatter:on
73
94
#define BIO_SANITIZE_WITH_CACHE(test, success, failure) \
95
{ \
96
BIO_CACHE(test) \
97
BIO_SANITIZE( \
98
RESULT, \
99
BIO_SINGLE_ARG(success), \
100
BIO_SINGLE_ARG(failure)) \
101
}
102
103
#define BIO_SANITIZE_WITH_CACHE_AT_SAFETY_LEVEL_0(test, success, failure) \
104
{ \
105
BIO_CACHE(test) \
106
BIO_SANITIZE_AT_SAFETY_LEVEL_0( \
107
RESULT, \
108
BIO_SINGLE_ARG(success), \
109
BIO_SINGLE_ARG(failure)) \
110
}
111
112
#define BIO_SANITIZE_WITH_CACHE_AT_SAFETY_LEVEL_1(test, success, failure) \
113
{ \
114
BIO_CACHE(test) \
115
BIO_SANITIZE_AT_SAFETY_LEVEL_1( \
116
RESULT, \
117
BIO_SINGLE_ARG(success), \
118
BIO_SINGLE_ARG(failure)) \
119
}
120
121
#define BIO_SANITIZE_WITH_CACHE_AT_SAFETY_LEVEL_2(test, success, failure) \
122
{ \
123
BIO_CACHE(test) \
124
BIO_SANITIZE_AT_SAFETY_LEVEL_2( \
125
RESULT, \
126
BIO_SINGLE_ARG(success), \
127
BIO_SINGLE_ARG(failure)) \
128
}
CacheMacros.h
inc
bio
common
macros
SanitizeMacros.h
Generated by
1.9.4