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:53

Member Variables

private llvm::raw_ostream& OS
private llvm::ColorMode Mode
private static llvm::WithColor::AutoDetectFunctionType AutoDetectFunction

Method Overview

  • public WithColor(llvm::raw_ostream & OS, raw_ostream::Colors Color = raw_ostream::SAVEDCOLOR, bool Bold = false, bool BG = false, llvm::ColorMode Mode = ColorMode::Auto)
  • public WithColor(llvm::raw_ostream & OS, llvm::HighlightColor S, llvm::ColorMode Mode = ColorMode::Auto)
  • public llvm::WithColor & changeColor(raw_ostream::Colors Color, bool Bold = false, bool BG = false)
  • public bool colorsEnabled()
  • public static llvm::WithColor::AutoDetectFunctionType defaultAutoDetectFunction()
  • public static void defaultErrorHandler(llvm::Error Err)
  • public static void defaultWarningHandler(llvm::Error Warning)
  • 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 void setAutoDetectFunction(llvm::WithColor::AutoDetectFunctionType NewAutoDetectFunction)
  • public static llvm::raw_ostream & warning(llvm::raw_ostream & OS, llvm::StringRef Prefix = "", bool DisableColors = false)
  • public static llvm::raw_ostream & warning()
  • public ~WithColor()

Methods

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

Description

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

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

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
llvm::ColorMode Mode = ColorMode::Auto
Enable, disable or compute whether to use colors.

WithColor(llvm::raw_ostream& OS,
          llvm::HighlightColor S,
          llvm::ColorMode Mode = ColorMode::Auto)

Description

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

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

Parameters

llvm::raw_ostream& OS
The output stream
llvm::HighlightColor S
Symbolic name for syntax element to color
llvm::ColorMode Mode = ColorMode::Auto
Enable, disable or compute whether to use colors.

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:120

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:113

static llvm::WithColor::AutoDetectFunctionType
defaultAutoDetectFunction()

Description

Retrieve the default color auto detection function.

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

static void defaultErrorHandler(llvm::Error Err)

Description

Implement default handling for Error. Print "error: " to stderr.

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

Parameters

llvm::Error Err

static void defaultWarningHandler(
    llvm::Error Warning)

Description

Implement default handling for Warning. Print "warning: " to stderr.

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

Parameters

llvm::Error Warning

static llvm::raw_ostream& error()

Description

Convenience method for printing "error: " to stderr.

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

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:100

Parameters

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

llvm::raw_ostream& get()

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

static llvm::raw_ostream& note()

Description

Convenience method for printing "note: " to stderr.

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

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:106

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:80

static llvm::raw_ostream& remark()

Description

Convenience method for printing "remark: " to stderr.

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

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:109

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:125

static void setAutoDetectFunction(
    llvm::WithColor::AutoDetectFunctionType
        NewAutoDetectFunction)

Description

Change the global auto detection function.

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

Parameters

llvm::WithColor::AutoDetectFunctionType NewAutoDetectFunction

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:103

Parameters

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

static llvm::raw_ostream& warning()

Description

Convenience method for printing "warning: " to stderr.

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

~WithColor()

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