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
104#define BINARY(sym) extern "C" {extern const unsigned char sym[]; extern const unsigned int sym##_len;}
105#define BINARY_START(sym) (sym)
106#define BINARY_END(sym) (sym + sym##_len)
107#define BINARY_SIZE(sym) (sym##_len)
119inline int8_t
operator"" _i8(
unsigned long long x) {
return x;}
120inline int16_t
operator"" _i16(
unsigned long long x) {
return x;}
121inline int32_t
operator"" _i32(
unsigned long long x) {
return x;}
122inline int64_t
operator"" _i64(
unsigned long long x) {
return x;}
123inline uint8_t
operator"" _u8(
unsigned long long x) {
return x;}
124inline uint16_t
operator"" _u16(
unsigned long long x) {
return x;}
125inline uint32_t
operator"" _u32(
unsigned long long x) {
return x;}
126inline uint64_t
operator"" _u64(
unsigned long long x) {
return x;}
127inline float operator"" _f32(
long double x) {
return x;}
128inline float operator"" _f32(
unsigned long long x) {
return x;}
129inline double operator"" _f64(
long double x) {
return x;}
130inline double operator"" _f64(
unsigned long long x) {
return x;}
135static_assert(
sizeof(wchar_t) == 2);
138#define fopen fopen_u8
141FILE* fopen_u8(
const char* filename,
const char* mode);
155template <
typename To,
typename From>
157 static_assert(
sizeof(From) ==
sizeof(To),
"Types must be the same size");
160 std::memcpy(&to, &from,
sizeof(From));
175template <
typename T,
typename F,
typename V,
typename... Args>
207#define DEFER(code) auto CONCAT(_defer_, __COUNTER__) = rack::deferWrapper([&]() code)
220 const char*
what() const noexcept
override {
220 const char*
what() const noexcept
override {
…}
240const typename C::mapped_type&
get(
const C& c,
const typename C::key_type& key,
const typename C::mapped_type& def =
typename C::mapped_type()) {
241 typename C::const_iterator it = c.find(key);
240const typename C::mapped_type&
get(
const C& c,
const typename C::key_type& key,
const typename C::mapped_type& def =
typename C::mapped_type()) {
…}
251const typename C::value_type&
get(
const C& c,
typename C::size_type i,
const typename C::value_type& def =
typename C::value_type()) {
251const typename C::value_type&
get(
const C& c,
typename C::size_type i,
const typename C::value_type& def =
typename C::value_type()) {
…}
265extern const std::string
APP_OS;
267extern const std::string
APP_CPU;
269extern 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:171
const std::string APP_NAME
To bitCast(From from)
Casts a primitive, preserving its bits instead of converting.
Definition common.hpp:156
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:203
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:240
Defers running code until the scope is destructed.
Definition common.hpp:194
~DeferWrapper()
Definition common.hpp:197
DeferWrapper(F f)
Definition common.hpp:196
F f
Definition common.hpp:195
__attribute__((format(printf, 2, 3))) Exception(const char *format
Exception(const std::string &msg)
Definition common.hpp:219
std::string msg
Definition common.hpp:214
const char * what() const noexcept override
Definition common.hpp:220