MCPcopy Create free account
hub / github.com/ablab/spades / WithColor

Class WithColor

ext/include/llvm/Support/WithColor.h:35–117  ·  view source on GitHub ↗

An RAII object that temporarily switches an output stream to a specific color.

Source from the content-addressed store, hash-verified

33/// An RAII object that temporarily switches an output stream to a specific
34/// color.
35class WithColor {
36 raw_ostream &OS;
37 bool DisableColors;
38
39public:
40 /// To be used like this: WithColor(OS, HighlightColor::String) << "text";
41 /// @param OS The output stream
42 /// @param S Symbolic name for syntax element to color
43 /// @param DisableColors Whether to ignore color changes regardless of -color
44 /// and support in OS
45 WithColor(raw_ostream &OS, HighlightColor S, bool DisableColors = false);
46 /// To be used like this: WithColor(OS, raw_ostream::Black) << "text";
47 /// @param OS The output stream
48 /// @param Color ANSI color to use, the special SAVEDCOLOR can be used to
49 /// change only the bold attribute, and keep colors untouched
50 /// @param Bold Bold/brighter text, default false
51 /// @param BG If true, change the background, default: change foreground
52 /// @param DisableColors Whether to ignore color changes regardless of -color
53 /// and support in OS
54 WithColor(raw_ostream &OS,
55 raw_ostream::Colors Color = raw_ostream::SAVEDCOLOR,
56 bool Bold = false, bool BG = false, bool DisableColors = false)
57 : OS(OS), DisableColors(DisableColors) {
58 changeColor(Color, Bold, BG);
59 }
60 ~WithColor();
61
62 raw_ostream &get() { return OS; }
63 operator raw_ostream &() { return OS; }
64 template <typename T> WithColor &operator<<(T &O) {
65 OS << O;
66 return *this;
67 }
68 template <typename T> WithColor &operator<<(const T &O) {
69 OS << O;
70 return *this;
71 }
72
73 /// Convenience method for printing "error: " to stderr.
74 static raw_ostream &error();
75 /// Convenience method for printing "warning: " to stderr.
76 static raw_ostream &warning();
77 /// Convenience method for printing "note: " to stderr.
78 static raw_ostream &note();
79 /// Convenience method for printing "remark: " to stderr.
80 static raw_ostream &remark();
81
82 /// Convenience method for printing "error: " to the given stream.
83 static raw_ostream &error(raw_ostream &OS, StringRef Prefix = "",
84 bool DisableColors = false);
85 /// Convenience method for printing "warning: " to the given stream.
86 static raw_ostream &warning(raw_ostream &OS, StringRef Prefix = "",
87 bool DisableColors = false);
88 /// Convenience method for printing "note: " to the given stream.
89 static raw_ostream &note(raw_ostream &OS, StringRef Prefix = "",
90 bool DisableColors = false);
91 /// Convenience method for printing "remark: " to the given stream.
92 static raw_ostream &remark(raw_ostream &OS, StringRef Prefix = "",

Callers 2

printMethod · 0.85
WithColor.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected