1/*
2 * Debug.h -- OMP debug
3 */
4
5//===----------------------------------------------------------------------===//
6//
7// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8// See https://llvm.org/LICENSE.txt for license information.
9// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10//
11//===----------------------------------------------------------------------===//
12
13#include <iostream>
14#include <ostream>
15
16#ifndef GDB_DEBUG_H_
17#define GDB_DEBUG_H_
18
19namespace GdbColor {
20enum Code {
21 FG_RED = 31,
22 FG_GREEN = 32,
23 FG_BLUE = 34,
24 FG_DEFAULT = 39,
25 BG_RED = 41,
26 BG_GREEN = 42,
27 BG_BLUE = 44,
28 BG_DEFAULT = 49
29};
30inline std::ostream &operator<<(std::ostream &os, Code code) {
31 return os << "\033[" << static_cast<int>(code) << "m";
32}
33} // namespace GdbColor
34
35class ColorOut {
36private:
37 std::ostream &out;
38 GdbColor::Code color;
39
40public:
41 ColorOut(std::ostream &_out, GdbColor::Code _color)
42 : out(_out), color(_color) {}
43 template <typename T> const ColorOut &operator<<(const T &val) const {
44 out << color << val << GdbColor::FG_DEFAULT;
45 return *this;
46 }
47 const ColorOut &operator<<(std::ostream &(*pf)(std::ostream &)) const {
48 out << color << pf << GdbColor::FG_DEFAULT;
49 return *this;
50 }
51};
52
53static ColorOut dout(std::cout, GdbColor::FG_RED);
54static ColorOut sout(std::cout, GdbColor::FG_GREEN);
55static ColorOut hout(std::cout, GdbColor::FG_BLUE);
56
57#endif /*GDB_DEBUG_H_*/
58

source code of openmp/libompd/src/Debug.h