class WithColor

Declaration

class WithColor { /* full declaration omitted */ };

Description

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

Declared at: llvm/include/llvm/Support/WithColor.h:37

Method Overview

  • public WithColor(llvm::raw_ostream & OS, llvm::HighlightColor S, bool DisableColors = false)
  • public WithColor(llvm::raw_ostream & OS, raw_ostream::Colors Color = raw_ostream::SAVEDCOLOR, bool Bold = false, bool BG = false, bool DisableColors = false)
  • public llvm::WithColor & changeColor(raw_ostream::Colors Color, bool Bold = false, bool BG = false)
  • public bool colorsEnabled()
  • public static llvm::raw_ostream & error()
  • public static llvm::raw_ostream & error(llvm::raw_ostream & OS, llvm::StringRef Prefix = "", bool DisableColors = false)
  • public llvm::raw_ostream & get()
  • public static llvm::raw_ostream & note()
  • public static llvm::raw_ostream & note(llvm::raw_ostream & OS, llvm::StringRef Prefix = "", bool DisableColors = false)
  • public llvm::raw_ostream & operator llvm::raw_ostream &()
  • public static llvm::raw_ostream & remark()
  • public static llvm::raw_ostream & remark(llvm::raw_ostream & OS, llvm::StringRef Prefix = "", bool DisableColors = false)
  • public llvm::WithColor & resetColor()
  • public static llvm::raw_ostream & warning()
  • public static llvm::raw_ostream & warning(llvm::raw_ostream & OS, llvm::StringRef Prefix = "", bool DisableColors = false)
  • public ~WithColor()

Methods

WithColor(llvm::raw_ostream& OS,
          llvm::HighlightColor S,
          bool DisableColors = false)

Description

To be used like this: WithColor(OS, HighlightColor::String) < < "text";

Declared at: llvm/include/llvm/Support/WithColor.h:47

Parameters

llvm::raw_ostream& OS
The output stream
llvm::HighlightColor S
Symbolic name for syntax element to color
bool DisableColors = false
Whether to ignore color changes regardless of -color and support in OS

WithColor(llvm::raw_ostream& OS,
          raw_ostream::Colors Color =
              raw_ostream::SAVEDCOLOR,
          bool Bold = false,
          bool BG = false,
          bool DisableColors = false)

Description

To be used like this: WithColor(OS, raw_ostream::Black) < < "text";

Declared at: llvm/include/llvm/Support/WithColor.h:56

Parameters

llvm::raw_ostream& OS
The output stream
raw_ostream::Colors Color = raw_ostream::SAVEDCOLOR
ANSI color to use, the special SAVEDCOLOR can be used to change only the bold attribute, and keep colors untouched
bool Bold = false
Bold/brighter text, default false
bool BG = false
If true, change the background, default: change foreground
bool DisableColors = false
Whether to ignore color changes regardless of -color and support in OS

llvm::WithColor& changeColor(
    raw_ostream::Colors Color,
    bool Bold = false,
    bool BG = false)

Description

Change the color of text that will be output from this point forward.

Declared at: llvm/include/llvm/Support/WithColor.h:105

Parameters

raw_ostream::Colors Color
ANSI color to use, the special SAVEDCOLOR can be used to change only the bold attribute, and keep colors untouched
bool Bold = false
Bold/brighter text, default false
bool BG = false
If true, change the background, default: change foreground

bool colorsEnabled()

Description

Determine whether colors are displayed.

Declared at: llvm/include/llvm/Support/WithColor.h:98

static llvm::raw_ostream& error()

Description

Convenience method for printing "error: " to stderr.

Declared at: llvm/include/llvm/Support/WithColor.h:76

static llvm::raw_ostream& error(
    llvm::raw_ostream& OS,
    llvm::StringRef Prefix = "",
    bool DisableColors = false)

Description

Convenience method for printing "error: " to the given stream.

Declared at: llvm/include/llvm/Support/WithColor.h:85

Parameters

llvm::raw_ostream& OS
llvm::StringRef Prefix = ""
bool DisableColors = false

llvm::raw_ostream& get()

Declared at: llvm/include/llvm/Support/WithColor.h:64

static llvm::raw_ostream& note()

Description

Convenience method for printing "note: " to stderr.

Declared at: llvm/include/llvm/Support/WithColor.h:80

static llvm::raw_ostream& note(
    llvm::raw_ostream& OS,
    llvm::StringRef Prefix = "",
    bool DisableColors = false)

Description

Convenience method for printing "note: " to the given stream.

Declared at: llvm/include/llvm/Support/WithColor.h:91

Parameters

llvm::raw_ostream& OS
llvm::StringRef Prefix = ""
bool DisableColors = false

llvm::raw_ostream& operator llvm::raw_ostream&()

Declared at: llvm/include/llvm/Support/WithColor.h:65

static llvm::raw_ostream& remark()

Description

Convenience method for printing "remark: " to stderr.

Declared at: llvm/include/llvm/Support/WithColor.h:82

static llvm::raw_ostream& remark(
    llvm::raw_ostream& OS,
    llvm::StringRef Prefix = "",
    bool DisableColors = false)

Description

Convenience method for printing "remark: " to the given stream.

Declared at: llvm/include/llvm/Support/WithColor.h:94

Parameters

llvm::raw_ostream& OS
llvm::StringRef Prefix = ""
bool DisableColors = false

llvm::WithColor& resetColor()

Description

Reset the colors to terminal defaults. Call this when you are done outputting colored text, or before program exit.

Declared at: llvm/include/llvm/Support/WithColor.h:110

static llvm::raw_ostream& warning()

Description

Convenience method for printing "warning: " to stderr.

Declared at: llvm/include/llvm/Support/WithColor.h:78

static llvm::raw_ostream& warning(
    llvm::raw_ostream& OS,
    llvm::StringRef Prefix = "",
    bool DisableColors = false)

Description

Convenience method for printing "warning: " to the given stream.

Declared at: llvm/include/llvm/Support/WithColor.h:88

Parameters

llvm::raw_ostream& OS
llvm::StringRef Prefix = ""
bool DisableColors = false

~WithColor()

Declared at: llvm/include/llvm/Support/WithColor.h:62