mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-21 18:52:36 +10:00
IS_ONE_OF macro to make long chains of conditions more concise and easy to follow (#4860)
* Is one of macro * Moar * Whoops * Trunk * isOneOf function backed macro
This commit is contained in:
+8
-1
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
#include "DebugConfiguration.h"
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <iterator>
|
||||
#include <stdint.h>
|
||||
|
||||
/// C++ v17+ clamp function, limits a given value to a range defined by lo and hi
|
||||
@@ -17,4 +20,8 @@ char *strnstr(const char *s, const char *find, size_t slen);
|
||||
void printBytes(const char *label, const uint8_t *p, size_t numbytes);
|
||||
|
||||
// is the memory region filled with a single character?
|
||||
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes);
|
||||
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes);
|
||||
|
||||
bool isOneOf(int item, int count, ...);
|
||||
|
||||
#define IS_ONE_OF(item, ...) isOneOf(item, sizeof((int[]){__VA_ARGS__}) / sizeof(int), __VA_ARGS__)
|
||||
|
||||
Reference in New Issue
Block a user