blob: 70b79dd0f3a1abe247aa9f9a73acbadbf1507b5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* File: print.hpp
* Purpose: OCL Print library
* Author: Amlal El Mahrouss. (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License. Licensed under the BSL 1.0 license
*/
#ifndef __OCL_CORE_PRINT
#define __OCL_CORE_PRINT
#include <ocl/detail/config.hpp>
#include <ocl/io.hpp>
namespace ocl::io
{
template <typename T>
inline void print(T fmt) noexcept
{
console_io_out << fmt;
}
inline void print() noexcept
{
extern void lf() noexcept;
lf();
}
template <typename... Args>
inline void print(Args... fmt) noexcept
{
print(fmt...);
print();
}
template <typename T, typename... Args>
inline void print(T fmt, Args... other) noexcept
{
console_io_out << fmt;
print(other...);
}
namespace detail
{
inline bool is_stdio_sync = true;
using io_error = std::runtime_error;
inline void throw_option_invalid_type_error(const boost::string_view& loc = BOOST_CURRENT_LOCATION.to_string())
{
throw io_error(loc.to_string());
}
}
inline void enable_stdio_sync(const bool& enable) noexcept
{
detail::is_stdio_sync = enable;
console_io_out.sync_with_stdio(detail::is_stdio_sync);
}
inline const bool& is_stdio_sync()
{
return detail::is_stdio_sync;
}
inline void lf() noexcept
{
#ifdef OCL_USE_CRLF_ENDINGS
print("\r\n");
#else
print("\n");
#endif
}
template <typename... T>
inline void println(T... fmt) noexcept
{
print(fmt...);
lf();
}
} // namespace ocl::io
#endif // ifndef __OCL_CORE_PRINT
|