LLVM: llvm::WithColor Class Reference (original) (raw)

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

#include "[llvm/Support/WithColor.h](WithColor%5F8h%5Fsource.html)"

Public Member Functions
LLVM_CTOR_NODISCARD LLVM_ABI WithColor (raw_ostream &OS, HighlightColor S, ColorMode Mode=ColorMode::Auto)
To be used like this: WithColor(OS, HighlightColor::String) << "text";.
LLVM_CTOR_NODISCARD WithColor (raw_ostream &OS, raw_ostream::Colors Color=raw_ostream::SAVEDCOLOR, bool Bold=false, bool BG=false, ColorMode Mode=ColorMode::Auto)
To be used like this: WithColor(OS, raw_ostream::BLACK) << "text";.
LLVM_ABI ~WithColor ()
raw_ostream & get ()
operator raw_ostream & ()
template<typename T>
WithColor & operator<< (T &O)
template<typename T>
WithColor & operator<< (const T &O)
LLVM_ABI bool colorsEnabled ()
Determine whether colors are displayed.
LLVM_ABI WithColor & changeColor (raw_ostream::Colors Color, bool Bold=false, bool BG=false)
Change the color of text that will be output from this point forward.
LLVM_ABI WithColor & resetColor ()
Reset the colors to terminal defaults.
Static Public Member Functions
static LLVM_ABI raw_ostream & error ()
Convenience method for printing "error: " to stderr.
static LLVM_ABI raw_ostream & warning ()
Convenience method for printing "warning: " to stderr.
static LLVM_ABI raw_ostream & note ()
Convenience method for printing "note: " to stderr.
static LLVM_ABI raw_ostream & remark ()
Convenience method for printing "remark: " to stderr.
static LLVM_ABI raw_ostream & error (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false)
Convenience method for printing "error: " to the given stream.
static LLVM_ABI raw_ostream & warning (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false)
Convenience method for printing "warning: " to the given stream.
static LLVM_ABI raw_ostream & note (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false)
Convenience method for printing "note: " to the given stream.
static LLVM_ABI raw_ostream & remark (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false)
Convenience method for printing "remark: " to the given stream.
static LLVM_ABI void defaultErrorHandler (Error Err)
Implement default handling for Error.
static LLVM_ABI void defaultWarningHandler (Error Warning)
Implement default handling for Warning.
static LLVM_ABI AutoDetectFunctionType defaultAutoDetectFunction ()
Retrieve the default color auto detection function.
static LLVM_ABI void setAutoDetectFunction (AutoDetectFunctionType NewAutoDetectFunction)
Change the global auto detection function.

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

Definition at line 54 of file WithColor.h.

AutoDetectFunctionType

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

Parameters

OS The output stream
S Symbolic name for syntax element to color
Mode Enable, disable or compute whether to use colors.

Definition at line 44 of file WithColor.cpp.

References llvm::Address, llvm::Attribute, llvm::raw_ostream::BLACK, llvm::raw_ostream::BLUE, colorsEnabled(), llvm::raw_ostream::CYAN, llvm::Enumerator, llvm::Error, llvm::raw_ostream::GREEN, llvm::Macro, llvm::raw_ostream::MAGENTA, llvm::Note, llvm::raw_ostream::RED, llvm::Remark, llvm::String, llvm::Tag, llvm::Warning, and llvm::raw_ostream::YELLOW.

Referenced by changeColor(), error(), note(), operator<<(), operator<<(), remark(), resetColor(), and warning().

WithColor() [2/2]

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

Parameters

OS The output stream
Color ANSI color to use, the special SAVEDCOLOR can be used to change only the bold attribute, and keep colors untouched
Bold Bold/brighter text, default false
BG If true, change the background, default: change foreground
Mode Enable, disable or compute whether to use colors.

Definition at line 71 of file WithColor.h.

References llvm::Auto, changeColor(), LLVM_CTOR_NODISCARD, and llvm::raw_ostream::SAVEDCOLOR.

~WithColor()

WithColor::~WithColor ( )

changeColor()

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

Parameters

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

Definition at line 143 of file WithColor.cpp.

References changeColor(), colorsEnabled(), and WithColor().

Referenced by changeColor(), and WithColor().

colorsEnabled()

bool WithColor::colorsEnabled ( )

defaultAutoDetectFunction()

WithColor::AutoDetectFunctionType WithColor::defaultAutoDetectFunction ( ) static

defaultErrorHandler()

void WithColor::defaultErrorHandler ( Error Err) static

defaultWarningHandler()

void WithColor::defaultWarningHandler ( Error Warning) static

error() [1/2]

error() [2/2]

get()

note() [1/2]

note() [2/2]

operator raw_ostream &()

operator<<() [1/2]

operator<<() [2/2]

template<typename T>

WithColor & llvm::WithColor::operator<< ( T & O) inline

remark() [1/2]

remark() [2/2]

resetColor()

setAutoDetectFunction()

void WithColor::setAutoDetectFunction ( AutoDetectFunctionType NewAutoDetectFunction) static

Change the global auto detection function.

Definition at line 174 of file WithColor.cpp.

warning() [1/2]

warning() [2/2]


The documentation for this class was generated from the following files: