kDB: Knowledge DataBase
Loading...
Searching...
No Matches
Formatter.h
1#pragma once
2
3#include <clog_format>
4#include <clog_qt>
5
6#include "Global.h"
7
8namespace knowCore
9{
10 template<typename _TYPE_>
11 struct printable_formatter : public std::formatter<QString>
12 {
13 template<typename FormatContext>
14 auto format(_TYPE_ const& p, FormatContext& ctx) const
15 {
16 auto const [success, value, message] = p.printable();
17 if(success)
18 {
19 return std::formatter<QString>::format(value.value(), ctx);
20 }
21 else
22 {
23 return std::format_to(ctx.out(), "error: '{}'", message.value());
24 }
25 }
26 };
27} // namespace knowCore
28
29#define KNOWCORE_CORE_DECLARE_FORMATTER_PRINTABLE(_TYPE_) \
30 template<> \
31 struct std::formatter<_TYPE_> : public knowCore::printable_formatter<_TYPE_> \
32 { \
33 }
Definition Formatter.h:12