26#define DEPRECATED __attribute__((deprecated))
46#define CONCAT_LITERAL(x, y) x ## y
47#define CONCAT(x, y) CONCAT_LITERAL(x, y)
62#define TOSTRING_LITERAL(x) #x
63#define TOSTRING(x) TOSTRING_LITERAL(x)
67#define LENGTHOF(arr) (sizeof(arr) / sizeof((arr)[0]))
80#define ENUMS(name, count) name, name ## _LAST = name + (count) - 1
105 #define BINARY(sym) extern unsigned char sym[]; extern unsigned int sym##_len
106 #define BINARY_START(sym) ((const void*) sym)
107 #define BINARY_END(sym) ((const void*) sym + sym##_len)
108 #define BINARY_SIZE(sym) (sym##_len)
110 #define BINARY(sym) extern char _binary_##sym##_start, _binary_##sym##_end, _binary_##sym##_size
111 #define BINARY_START(sym) ((const void*) &_binary_##sym##_start)
112 #define BINARY_END(sym) ((const void*) &_binary_##sym##_end)
114 #define BINARY_SIZE(sym) ((size_t) (&_binary_##sym##_end - &_binary_##sym##_start))
127inline int8_t
operator"" _i8(
unsigned long long x) {
return x;}
128inline int16_t
operator"" _i16(
unsigned long long x) {
return x;}
129inline int32_t
operator"" _i32(
unsigned long long x) {
return x;}
130inline int64_t
operator"" _i64(
unsigned long long x) {
return x;}
131inline uint8_t
operator"" _u8(
unsigned long long x) {
return x;}
132inline uint16_t
operator"" _u16(
unsigned long long x) {
return x;}
133inline uint32_t
operator"" _u32(
unsigned long long x) {
return x;}
134inline uint64_t
operator"" _u64(
unsigned long long x) {
return x;}
135inline float operator"" _f32(
long double x) {
return x;}
136inline float operator"" _f32(
unsigned long long x) {
return x;}
137inline double operator"" _f64(
long double x) {
return x;}
138inline double operator"" _f64(
unsigned long long x) {
return x;}
143static_assert(
sizeof(wchar_t) == 2);
146#define fopen fopen_u8
149FILE* fopen_u8(
const char* filename,
const char* mode);
163template <
typename To,
typename From>
165 static_assert(
sizeof(From) ==
sizeof(To),
"Types must be the same size");
168 std::memcpy(&to, &from,
sizeof(From));
183template <
typename T,
typename F,
typename V,
typename... Args>
215#define DEFER(code) auto CONCAT(_defer_, __COUNTER__) = rack::deferWrapper([&]() code)
228 const char*
what() const noexcept
override {
248const typename C::mapped_type&
get(
const C& c,
const typename C::key_type& key,
const typename C::mapped_type& def =
typename C::mapped_type()) {
249 typename C::const_iterator it = c.find(key);
259const typename C::value_type&
get(
const C& c,
typename C::size_type i,
const typename C::value_type& def =
typename C::value_type()) {
273extern const std::string
APP_OS;
275extern const std::string
APP_CPU;
277extern const std::string
API_URL;
const char int const char const char * format
Definition logger.hpp:41
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
T * construct()
C#-style property constructor Example:
Definition common.hpp:179
const std::string APP_NAME
To bitCast(From from)
Casts a primitive, preserving its bits instead of converting.
Definition common.hpp:164
const std::string APP_OS_NAME
const std::string API_URL
const std::string APP_VERSION_MAJOR
const std::string APP_CPU
const std::string APP_VERSION
const std::string APP_EDITION
const std::string APP_EDITION_NAME
DeferWrapper< F > deferWrapper(F f)
Definition common.hpp:211
const std::string APP_CPU_NAME
const C::mapped_type & get(const C &c, const typename C::key_type &key, const typename C::mapped_type &def=typename C::mapped_type())
Given a std::map c, returns the value of the given key, or returns def if the key doesn't exist.
Definition common.hpp:248
Defers running code until the scope is destructed.
Definition common.hpp:202
~DeferWrapper()
Definition common.hpp:205
DeferWrapper(F f)
Definition common.hpp:204
F f
Definition common.hpp:203
An exception explicitly thrown by Rack or a Rack plugin.
Definition common.hpp:221
__attribute__((format(printf, 2, 3))) Exception(const char *format
std::string msg
Definition common.hpp:222
const char * what() const noexcept override
Definition common.hpp:228