1 | // [Blend2D] |
2 | // 2D Vector Graphics Powered by a JIT Compiler. |
3 | // |
4 | // [License] |
5 | // Zlib - See LICENSE.md file in the package. |
6 | |
7 | #ifndef BLEND2D_BLTRACE_P_H |
8 | #define BLEND2D_BLTRACE_P_H |
9 | |
10 | #include "./blapi-internal_p.h" |
11 | |
12 | //! \cond INTERNAL |
13 | //! \addtogroup blend2d_internal |
14 | //! \{ |
15 | |
16 | // ============================================================================ |
17 | // [BLDummyTrace] |
18 | // ============================================================================ |
19 | |
20 | //! Dummy trace - no tracing, no runtime overhead. |
21 | class BLDummyTrace { |
22 | public: |
23 | BL_INLINE bool enabled() const noexcept { return false; }; |
24 | BL_INLINE void indent() noexcept {} |
25 | BL_INLINE void deindent() noexcept {} |
26 | |
27 | template<typename... Args> |
28 | BL_INLINE void out(Args&&...) noexcept {} |
29 | |
30 | template<typename... Args> |
31 | BL_INLINE void info(Args&&...) noexcept {} |
32 | |
33 | template<typename... Args> |
34 | BL_INLINE bool warn(Args&&...) noexcept { return false; } |
35 | |
36 | template<typename... Args> |
37 | BL_INLINE bool fail(Args&&...) noexcept { return false; } |
38 | }; |
39 | |
40 | // ============================================================================ |
41 | // [BLDebugTrace] |
42 | // ============================================================================ |
43 | |
44 | //! Debug trace - active / enabled trace that can be useful during debugging. |
45 | class BLDebugTrace { |
46 | public: |
47 | BL_INLINE BLDebugTrace() noexcept |
48 | : indentation(0) {} |
49 | BL_INLINE BLDebugTrace(const BLDebugTrace& other) noexcept |
50 | : indentation(other.indentation) {} |
51 | |
52 | BL_INLINE bool enabled() const noexcept { return true; }; |
53 | BL_INLINE void indent() noexcept { indentation++; } |
54 | BL_INLINE void deindent() noexcept { indentation--; } |
55 | |
56 | template<typename... Args> |
57 | BL_INLINE void out(Args&&... args) noexcept { log(0, 0xFFFFFFFFu, std::forward<Args>(args)...); } |
58 | |
59 | template<typename... Args> |
60 | BL_INLINE void info(Args&&... args) noexcept { log(0, indentation, std::forward<Args>(args)...); } |
61 | |
62 | template<typename... Args> |
63 | BL_INLINE bool warn(Args&&... args) noexcept { log(1, indentation, std::forward<Args>(args)...); return false; } |
64 | |
65 | template<typename... Args> |
66 | BL_INLINE bool fail(Args&&... args) noexcept { log(2, indentation, std::forward<Args>(args)...); return false; } |
67 | |
68 | BL_HIDDEN static void log(uint32_t severity, uint32_t indentation, const char* fmt, ...) noexcept; |
69 | |
70 | int indentation; |
71 | }; |
72 | |
73 | //! \} |
74 | //! \endcond |
75 | |
76 | #endif // BLEND2D_BLTRACE_P_H |
77 | |