41inline void message_impl(
bool fatal__,
const char* func__,
const char* file__,
int line__, std::string
const& msg__)
50 s <<
" in function \"" << func__ <<
"\" at " << file__ <<
":" << line__ << std::endl;
54 throw std::runtime_error(s.str());
56 std::cout << s.str() << std::endl;
60inline void message_impl(
bool fatal__,
const char* func__,
const char* file__,
int line__, std::stringstream
const& msg__)
62 message_impl(fatal__, func__, file__, line__, msg__.str());
68 std::ostream* out_{
nullptr};
74 ostream(std::ostream& out__, std::string prefix__)
80 : std::ostringstream(std::move(src__))
84 prefix_ = src__.prefix_;
89 auto strings =
split(this->str(),
'\n');
90 for (
size_t i = 0; i < strings.size(); i++) {
91 if (!(i == strings.size() - 1 && strings[i].size() == 0)) {
92 (*out_) <<
"[" << prefix_ <<
"] " << strings[i];
94 if (i != strings.size() - 1) {
102#define FILE_LINE std::string(__FILE__) + ":" + std::to_string(__LINE__)
104#define RTE_THROW(...) \
106 ::sirius::rte::message_impl(true, __func__, __FILE__, __LINE__, __VA_ARGS__);\
109#define RTE_WARNING(...) \
111 ::sirius::rte::message_impl(false, __func__, __FILE__, __LINE__, __VA_ARGS__);\
115#define RTE_ASSERT(condition__)
117#define RTE_ASSERT(condition__) \
119 if (!(condition__)) { \
120 std::stringstream _s; \
121 _s << "Assertion (" << #condition__ << ") failed " \
122 << "at " << __FILE__ << ":" << __LINE__; \
128#define RTE_OUT(_out) rte::ostream(_out, std::string(__func__))
Namespace of the SIRIUS library.
auto split(std::string const str__, char delim__)
Split multi-line string into a list of strings.