Merge pull request #256 from vvakame/impl-ts
[jackhill/mal.git] / cpp / Validation.h
1 #ifndef INCLUDE_VALIDATION_H
2 #define INCLUDE_VALIDATION_H
3
4 #include "String.h"
5
6 #define MAL_CHECK(condition, ...) \
7 if (!(condition)) { throw STRF(__VA_ARGS__); } else { }
8
9 #define MAL_FAIL(...) MAL_CHECK(false, __VA_ARGS__)
10
11 extern int checkArgsIs(const char* name, int expected, int got);
12 extern int checkArgsBetween(const char* name, int min, int max, int got);
13 extern int checkArgsAtLeast(const char* name, int min, int got);
14 extern int checkArgsEven(const char* name, int got);
15
16 #endif // INCLUDE_VALIDATION_H