#include <cstddef>
#include <cstdlib>
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cstdarg>
#include <climits>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <stdexcept>
#include <logger.hpp>
Go to the source code of this file.
|
namespace | rack |
| Root namespace for the Rack API.
|
|
|
#define | DEPRECATED __attribute__((deprecated)) |
| Attribute for deprecated functions and symbols. More...
|
|
#define | PRIVATE |
| Attribute for private functions not intended to be called by plugins. More...
|
|
#define | CONCAT_LITERAL(x, y) x ## y |
| Concatenates two literals or two macros Example: More...
|
|
#define | CONCAT(x, y) CONCAT_LITERAL(x, y) |
|
#define | TOSTRING_LITERAL(x) #x |
| Surrounds raw text with quotes Example: More...
|
|
#define | TOSTRING(x) TOSTRING_LITERAL(x) |
|
#define | LENGTHOF(arr) (sizeof(arr) / sizeof((arr)[0])) |
| Produces the length of a static array in number of elements. More...
|
|
#define | ENUMS(name, count) name, name ## _LAST = name + (count) - 1 |
| Reserve space for count enums starting with name . More...
|
|
#define | BINARY(sym) extern char _binary_##sym##_start, _binary_##sym##_end, _binary_##sym##_size |
| References binary files compiled into the program. More...
|
|
#define | BINARY_START(sym) ((const void*) &_binary_##sym##_start) |
|
#define | BINARY_END(sym) ((const void*) &_binary_##sym##_end) |
|
#define | BINARY_SIZE(sym) ((size_t) (&_binary_##sym##_end - &_binary_##sym##_start)) |
|
#define | DEFER(code) auto CONCAT(_defer_, __COUNTER__) = rack::deferWrapper([&]() code) |
|
|
int8_t | operator""_i8 (unsigned long long x) |
| Helpful user-defined literals for specifying exact integer and float types. More...
|
|
int16_t | operator""_i16 (unsigned long long x) |
|
int32_t | operator""_i32 (unsigned long long x) |
|
int64_t | operator""_i64 (unsigned long long x) |
|
uint8_t | operator""_u8 (unsigned long long x) |
|
uint16_t | operator""_u16 (unsigned long long x) |
|
uint32_t | operator""_u32 (unsigned long long x) |
|
uint64_t | operator""_u64 (unsigned long long x) |
|
float | operator""_f32 (long double x) |
|
float | operator""_f32 (unsigned long long x) |
|
double | operator""_f64 (long double x) |
|
double | operator""_f64 (unsigned long long x) |
|
template<typename To , typename From > |
To | rack::bitCast (From from) |
| Casts a primitive, preserving its bits instead of converting. More...
|
|
template<typename T > |
T * | rack::construct () |
| C#-style property constructor Example: More...
|
|
template<typename T , typename F , typename V , typename... Args> |
T * | rack::construct (F f, V v, Args... args) |
|
template<typename F > |
DeferWrapper< F > | rack::deferWrapper (F f) |
|
template<typename C > |
C::mapped_type | rack::get (const C &m, const typename C::key_type &key, const typename C::mapped_type &def=typename C::mapped_type()) |
| Given a std::map, returns the value of the given key, or returns def if the key doesn't exist. More...
|
|
◆ DEPRECATED
#define DEPRECATED __attribute__((deprecated)) |
Attribute for deprecated functions and symbols.
E.g.
DEPRECATED void foo();
◆ PRIVATE
Attribute for private functions not intended to be called by plugins.
When #including rack.hpp, attempting to call PRIVATE functions will result in a compile-time error.
◆ CONCAT_LITERAL
#define CONCAT_LITERAL |
( |
|
x, |
|
|
|
y |
|
) |
| x ## y |
Concatenates two literals or two macros Example:
#define COUNT 42
CONCAT(myVariable, COUNT)
expands to
myVariable42
◆ CONCAT
◆ TOSTRING_LITERAL
#define TOSTRING_LITERAL |
( |
|
x | ) |
#x |
Surrounds raw text with quotes Example:
#define NAME "world"
printf("Hello " TOSTRING(NAME))
expands to
printf("Hello " "world")
and of course the C++ lexer/parser then concatenates the string literals.
◆ TOSTRING
◆ LENGTHOF
#define LENGTHOF |
( |
|
arr | ) |
(sizeof(arr) / sizeof((arr)[0])) |
Produces the length of a static array in number of elements.
◆ ENUMS
#define ENUMS |
( |
|
name, |
|
|
|
count |
|
) |
| name, name ## _LAST = name + (count) - 1 |
Reserve space for count
enums starting with name
.
Example:
enum Foo {
ENUMS(BAR, 14),
BAZ
};
BAR + 0
to BAR + 13
is reserved. BAZ
has a value of 14.
◆ BINARY
#define BINARY |
( |
|
sym | ) |
extern char _binary_##sym##_start, _binary_##sym##_end, _binary_##sym##_size |
References binary files compiled into the program.
For example, to include a file "Test.dat" directly into your program binary, add
BINARIES += Test.dat
to your Makefile and declare
BINARY(Test_dat);
at the root of a .c or .cpp source file. Note that special characters are replaced with "_". Then use
BINARY_START(Test_dat)
BINARY_END(Test_dat)
to reference the data beginning and end as a void* array, and
BINARY_SIZE(Test_dat)
to get its size in bytes.
◆ BINARY_START
#define BINARY_START |
( |
|
sym | ) |
((const void*) &_binary_##sym##_start) |
◆ BINARY_END
#define BINARY_END |
( |
|
sym | ) |
((const void*) &_binary_##sym##_end) |
◆ BINARY_SIZE
#define BINARY_SIZE |
( |
|
sym | ) |
((size_t) (&_binary_##sym##_end - &_binary_##sym##_start)) |
◆ DEFER
◆ operator""_i8()
int8_t operator""_i8 |
( |
unsigned long long |
x | ) |
|
|
inline |
Helpful user-defined literals for specifying exact integer and float types.
Usage examples: 42_i8 -4242_u16 0x4a2b_i32 0b11010111000000_u64 42_f32 4.2e-4_f64
◆ operator""_i16()
int16_t operator""_i16 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_i32()
int32_t operator""_i32 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_i64()
int64_t operator""_i64 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_u8()
uint8_t operator""_u8 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_u16()
uint16_t operator""_u16 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_u32()
uint32_t operator""_u32 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_u64()
uint64_t operator""_u64 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_f32() [1/2]
float operator""_f32 |
( |
long double |
x | ) |
|
|
inline |
◆ operator""_f32() [2/2]
float operator""_f32 |
( |
unsigned long long |
x | ) |
|
|
inline |
◆ operator""_f64() [1/2]
double operator""_f64 |
( |
long double |
x | ) |
|
|
inline |
◆ operator""_f64() [2/2]
double operator""_f64 |
( |
unsigned long long |
x | ) |
|
|
inline |