First cut of pulling out the relevant parts of my original game to make a little framework.
This commit is contained in:
commit
6a0c9e8d46
177 changed files with 18197 additions and 0 deletions
53
src/dbc.hpp
Normal file
53
src/dbc.hpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <fmt/core.h>
|
||||
#include <functional>
|
||||
#include <source_location>
|
||||
|
||||
// AKA the Fuckit macro
|
||||
#define $F(FMT, ...) fmt::format(FMT, ##__VA_ARGS__)
|
||||
|
||||
namespace dbc {
|
||||
using std::string;
|
||||
|
||||
class Error {
|
||||
public:
|
||||
const string message;
|
||||
Error(string m) : message{m} {}
|
||||
Error(const char *m) : message{m} {}
|
||||
};
|
||||
|
||||
class CheckError : public Error {};
|
||||
class SentinelError : public Error {};
|
||||
class PreCondError : public Error {};
|
||||
class PostCondError : public Error {};
|
||||
|
||||
void log(const string &message,
|
||||
const std::source_location location =
|
||||
std::source_location::current());
|
||||
|
||||
[[noreturn]] void sentinel(const string &message,
|
||||
const std::source_location location =
|
||||
std::source_location::current());
|
||||
|
||||
void pre(const string &message, bool test,
|
||||
const std::source_location location =
|
||||
std::source_location::current());
|
||||
|
||||
void pre(const string &message, std::function<bool()> tester,
|
||||
const std::source_location location =
|
||||
std::source_location::current());
|
||||
|
||||
void post(const string &message, bool test,
|
||||
const std::source_location location =
|
||||
std::source_location::current());
|
||||
|
||||
void post(const string &message, std::function<bool()> tester,
|
||||
const std::source_location location =
|
||||
std::source_location::current());
|
||||
|
||||
void check(bool test, const string &message,
|
||||
const std::source_location location =
|
||||
std::source_location::current());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue