class formatted_raw_ostream
Declaration
class formatted_raw_ostream : public raw_ostream { /* full declaration omitted */ };
Description
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column position, allowing padding out to specific column boundaries and querying the number of lines written to the stream. This assumes that the contents of the stream is valid UTF-8 encoded text. This doesn't attempt to handle everything Unicode can do (combining characters, right-to-left markers, etc), but should cover the cases likely to appear in source code or diagnostic messages.
Declared at: llvm/include/llvm/Support/FormattedStream.h:30
Inherits from: raw_ostream
Member Variables
- private llvm::raw_ostream* TheStream
- TheStream - The real stream we output to. We set it to be unbuffered, since we're already doing our own buffering.
- private std::pair<unsigned int, unsigned int> Position
- Position - The current output column and line of the data that's been flushed and the portion of the buffer that's been scanned. The line and column scheme is zero-based.
- private const char* Scanned
- Scanned - This points to one past the last character in the buffer we've scanned.
- private SmallString<4> PartialUTF8Char
- PartialUTF8Char - Either empty or a prefix of a UTF-8 code unit sequence for a Unicode scalar value which should be prepended to the buffer for the next call to ComputePosition. This is needed when the buffer is flushed when it ends part-way through the UTF-8 encoding of a Unicode scalar value, so that we can compute the display width of the character once we have the rest of it.
Inherited from raw_ostream:
- public static BLACK = Colors::BLACK
- public static RED = Colors::RED
- public static GREEN = Colors::GREEN
- public static YELLOW = Colors::YELLOW
- public static BLUE = Colors::BLUE
- public static MAGENTA = Colors::MAGENTA
- public static CYAN = Colors::CYAN
- public static WHITE = Colors::WHITE
- public static SAVEDCOLOR = Colors::SAVEDCOLOR
- public static RESET = Colors::RESET
Method Overview
- private void ComputePosition(const char * Ptr, size_t size)
- public llvm::formatted_raw_ostream & PadToColumn(unsigned int NewCol)
- private void UpdatePosition(const char * Ptr, size_t Size)
- public llvm::raw_ostream & changeColor(enum Colors Color, bool Bold, bool BG)
- private uint64_t current_pos() const
- public formatted_raw_ostream(llvm::raw_ostream & Stream)
- public formatted_raw_ostream()
- public unsigned int getColumn()
- public unsigned int getLine()
- public bool is_displayed() const
- private void releaseStream()
- public llvm::raw_ostream & resetColor()
- public llvm::raw_ostream & reverseColor()
- private void setStream(llvm::raw_ostream & Stream)
- private void write_impl(const char * Ptr, size_t Size)
- public ~formatted_raw_ostream()
Inherited from raw_ostream:
- public GetBufferSize
- public GetNumBytesInBuffer
- protected SetBuffer
- public SetBufferSize
- public SetBuffered
- public SetUnbuffered
- public changeColor
- public colors_enabled
- public enable_colors
- public flush
- protected getBufferStart
- public get_kind
- public has_colors
- public indent
- public is_displayed
- protected preferred_buffer_size
- public reserveExtraSpace
- public resetColor
- public reverseColor
- public tell
- public tie
- public write
- public write
- public write_escaped
- public write_hex
- public write_uuid
- public write_zeros
Methods
¶void ComputePosition(const char* Ptr, size_t size)
void ComputePosition(const char* Ptr, size_t size)
Description
ComputePosition - Examine the given output buffer and figure out the new position after output. This is safe to call multiple times on the same buffer, as it records the most recently scanned character and resumes from there when the buffer has not been flushed.
Declared at: llvm/include/llvm/Support/FormattedStream.h:70
Parameters
- const char* Ptr
- size_t size
¶llvm::formatted_raw_ostream& PadToColumn(
unsigned int NewCol)
llvm::formatted_raw_ostream& PadToColumn(
unsigned int NewCol)
Description
PadToColumn - Align the output to some column number. If the current column is already equal to or more than NewCol, PadToColumn inserts one space.
Declared at: llvm/include/llvm/Support/FormattedStream.h:124
Parameters
- unsigned int NewCol
- - The column to move to.
¶void UpdatePosition(const char* Ptr, size_t Size)
void UpdatePosition(const char* Ptr, size_t Size)
Description
UpdatePosition - scan the characters in [Ptr, Ptr+Size), and update the line and column numbers. Unlike ComputePosition, this must be called exactly once on each region of the buffer.
Declared at: llvm/include/llvm/Support/FormattedStream.h:75
Parameters
- const char* Ptr
- size_t Size
¶llvm::raw_ostream& changeColor(enum Colors Color,
bool Bold,
bool BG)
llvm::raw_ostream& changeColor(enum Colors Color,
bool Bold,
bool BG)
Description
Changes the foreground color of text that will be output from this point forward.
Declared at: llvm/include/llvm/Support/FormattedStream.h:148
Parameters
- enum Colors Color
- ANSI color to use, the special SAVEDCOLOR can be used to change only the bold attribute, and keep colors untouched
- bool Bold
- bold/brighter text, default false
- bool BG
- if true change the background, default: change foreground
Returns
itself so it can be used within < < invocations
¶uint64_t current_pos() const
uint64_t current_pos() const
Description
current_pos - Return the current position within the stream, not counting the bytes currently in the buffer.
Declared at: llvm/include/llvm/Support/FormattedStream.h:59
¶formatted_raw_ostream(llvm::raw_ostream& Stream)
formatted_raw_ostream(llvm::raw_ostream& Stream)
Description
formatted_raw_ostream - Open the specified file for writing. If an error occurs, information about the error is put into ErrorInfo, and the stream should be immediately destroyed; the string will be empty if no error occurred. As a side effect, the given Stream is set to be Unbuffered. This is because formatted_raw_ostream does its own buffering, so it doesn't want another layer of buffering to be happening underneath it.
Declared at: llvm/include/llvm/Support/FormattedStream.h:106
Parameters
- llvm::raw_ostream& Stream
¶formatted_raw_ostream()
formatted_raw_ostream()
Declared at: llvm/include/llvm/Support/FormattedStream.h:110
¶unsigned int getColumn()
unsigned int getColumn()
Declared at: llvm/include/llvm/Support/FormattedStream.h:126
¶unsigned int getLine()
unsigned int getLine()
Declared at: llvm/include/llvm/Support/FormattedStream.h:132
¶bool is_displayed() const
bool is_displayed() const
Description
This function determines if this stream is connected to a "tty" or "console" window. That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.
Declared at: llvm/include/llvm/Support/FormattedStream.h:153
¶void releaseStream()
void releaseStream()
Declared at: llvm/include/llvm/Support/FormattedStream.h:158
¶llvm::raw_ostream& resetColor()
llvm::raw_ostream& resetColor()
Description
Resets the colors to terminal defaults. Call this when you are done outputting colored text, or before program exit.
Declared at: llvm/include/llvm/Support/FormattedStream.h:138
¶llvm::raw_ostream& reverseColor()
llvm::raw_ostream& reverseColor()
Description
Reverses the foreground and background colors.
Declared at: llvm/include/llvm/Support/FormattedStream.h:143
¶void setStream(llvm::raw_ostream& Stream)
void setStream(llvm::raw_ostream& Stream)
Declared at: llvm/include/llvm/Support/FormattedStream.h:77
Parameters
- llvm::raw_ostream& Stream
¶void write_impl(const char* Ptr, size_t Size)
void write_impl(const char* Ptr, size_t Size)
Description
The is the piece of the class that is implemented by subclasses. This writes the \p Size bytes starting at\p Ptr to the underlying stream. This function is guaranteed to only be called at a point at which it is safe for the subclass to install a new buffer via SetBuffer.
Declared at: llvm/include/llvm/Support/FormattedStream.h:55
Parameters
- const char* Ptr
- The start of the data to be written. For buffered streams this is guaranteed to be the start of the buffer.
- size_t Size
- The number of bytes to be written.
¶~formatted_raw_ostream()
~formatted_raw_ostream()
Declared at: llvm/include/llvm/Support/FormattedStream.h:114