dinkyecs_sandbox/dbc.hpp

40 lines
751 B
C++
Raw Normal View History

2025-02-13 18:58:58 +03:00
#pragma once
#include <fmt/core.h>
#include <functional>
2025-02-13 19:47:52 +03:00
#include <string>
2025-02-13 18:58:58 +03:00
using std::string;
2025-02-13 19:47:52 +03:00
namespace dbc
{
class Error
{
public:
const string message;
Error(string m) : message{m} {}
Error(const char *m) : message{m} {}
};
2025-02-13 18:58:58 +03:00
2025-02-13 19:47:52 +03:00
class CheckError : public Error
{
};
class SentinelError : public Error
{
};
class PreCondError : public Error
{
};
class PostCondError : public Error
{
};
2025-02-13 18:58:58 +03:00
2025-02-13 19:47:52 +03:00
void log(const string &message);
void sentinel(const string &message);
void pre(const string &message, bool test);
void pre(const string &message, std::function<bool()> tester);
void post(const string &message, bool test);
void post(const string &message, std::function<bool()> tester);
void check(bool test, const string &message);
} // namespace dbc