class raw_ostream
Declaration
class raw_ostream { /* full declaration omitted */ };
Description
This class implements an extremely fast bulk output stream that can *only* output to a stream. It does not support seeking, reopening, rewinding, line buffered disciplines etc. It is a simple buffer that outputs a chunk at a time.
Declared at: llvm/include/llvm/Support/raw_ostream.h:54
Member Variables
- private llvm::raw_ostream::OStreamKind Kind
- private char* OutBufStart
- If a subclass installs an external buffer using SetBuffer then it can wait for a
- private char* OutBufEnd
- If a subclass installs an external buffer using SetBuffer then it can wait for a
- private char* OutBufCur
- If a subclass installs an external buffer using SetBuffer then it can wait for a
- private bool ColorEnabled = false
- private llvm::raw_ostream* TiedStream = nullptr
- Optional stream this stream is tied to. If this stream is written to, the tied-to stream will be flushed first.
- private enum BufferKind BufferMode
- public static const llvm::raw_ostream::Colors BLACK = Colors::BLACK
- public static const llvm::raw_ostream::Colors RED = Colors::RED
- public static const llvm::raw_ostream::Colors GREEN = Colors::GREEN
- public static const llvm::raw_ostream::Colors YELLOW = Colors::YELLOW
- public static const llvm::raw_ostream::Colors BLUE = Colors::BLUE
- public static const llvm::raw_ostream::Colors MAGENTA = Colors::MAGENTA
- public static const llvm::raw_ostream::Colors CYAN = Colors::CYAN
- public static const llvm::raw_ostream::Colors WHITE = Colors::WHITE
- public static const llvm::raw_ostream::Colors SAVEDCOLOR = Colors::SAVEDCOLOR
- public static const llvm::raw_ostream::Colors RESET = Colors::RESET
Method Overview
- public size_t GetBufferSize() const
- public size_t GetNumBytesInBuffer() const
- protected void SetBuffer(char * BufferStart, size_t Size)
- private void SetBufferAndMode(char * BufferStart, size_t Size, llvm::raw_ostream::BufferKind Mode)
- public void SetBufferSize(size_t Size)
- public void SetBuffered()
- public void SetUnbuffered()
- private virtual void anchor()
- public virtual llvm::raw_ostream & changeColor(enum Colors Color, bool Bold = false, bool BG = false)
- public bool colors_enabled() const
- private void copy_to_buffer(const char * Ptr, size_t Size)
- private virtual uint64_t current_pos() const
- public virtual void enable_colors(bool enable)
- public void flush()
- private void flush_nonempty()
- private void flush_tied_then_write(const char * Ptr, size_t Size)
- protected const char * getBufferStart() const
- public llvm::raw_ostream::OStreamKind get_kind() const
- public virtual bool has_colors() const
- public llvm::raw_ostream & indent(unsigned int NumSpaces)
- public virtual bool is_displayed() const
- protected virtual size_t preferred_buffer_size() const
- private bool prepare_colors()
- public raw_ostream(bool unbuffered = false, llvm::raw_ostream::OStreamKind K = OStreamKind::OK_OStream)
- public raw_ostream(const llvm::raw_ostream &)
- public virtual void reserveExtraSpace(uint64_t ExtraSize)
- public virtual llvm::raw_ostream & resetColor()
- public virtual llvm::raw_ostream & reverseColor()
- public uint64_t tell() const
- public void tie(llvm::raw_ostream * TieTo)
- public llvm::raw_ostream & write(const char * Ptr, size_t Size)
- public llvm::raw_ostream & write(unsigned char C)
- public llvm::raw_ostream & write_escaped(llvm::StringRef Str, bool UseHexEscapes = false)
- public llvm::raw_ostream & write_hex(unsigned long long N)
- private virtual void write_impl(const char * Ptr, size_t Size)
- public llvm::raw_ostream & write_uuid(const uint8_t * UUID)
- public llvm::raw_ostream & write_zeros(unsigned int NumZeros)
- public virtual ~raw_ostream()
Methods
¶size_t GetBufferSize() const
size_t GetBufferSize() const
Declared at: llvm/include/llvm/Support/raw_ostream.h:161
¶size_t GetNumBytesInBuffer() const
size_t GetNumBytesInBuffer() const
Declared at: llvm/include/llvm/Support/raw_ostream.h:179
¶void SetBuffer(char* BufferStart, size_t Size)
void SetBuffer(char* BufferStart, size_t Size)
Description
Use the provided buffer as the raw_ostream buffer. This is intended for use only by subclasses which can arrange for the output to go directly into the desired output buffer, instead of being copied on each flush.
Declared at: llvm/include/llvm/Support/raw_ostream.h:368
Parameters
- char* BufferStart
- size_t Size
¶void SetBufferAndMode(
char* BufferStart,
size_t Size,
llvm::raw_ostream::BufferKind Mode)
void SetBufferAndMode(
char* BufferStart,
size_t Size,
llvm::raw_ostream::BufferKind Mode)
Description
Install the given buffer and mode.
Declared at: llvm/include/llvm/Support/raw_ostream.h:384
Parameters
- char* BufferStart
- size_t Size
- llvm::raw_ostream::BufferKind Mode
¶void SetBufferSize(size_t Size)
void SetBufferSize(size_t Size)
Description
Set the stream to be buffered, using the specified buffer size.
Declared at: llvm/include/llvm/Support/raw_ostream.h:156
Parameters
- size_t Size
¶void SetBuffered()
void SetBuffered()
Description
Set the stream to be buffered, with an automatically determined buffer size.
Declared at: llvm/include/llvm/Support/raw_ostream.h:153
¶void SetUnbuffered()
void SetUnbuffered()
Description
Set the stream to be unbuffered. When unbuffered, the stream will flush after every write. This routine will also flush the buffer immediately when the stream is being set to unbuffered.
Declared at: llvm/include/llvm/Support/raw_ostream.h:174
¶virtual void anchor()
virtual void anchor()
Declared at: llvm/include/llvm/Support/raw_ostream.h:401
¶virtual llvm::raw_ostream& changeColor(
enum Colors Color,
bool Bold = false,
bool BG = false)
virtual llvm::raw_ostream& changeColor(
enum Colors Color,
bool Bold = false,
bool BG = false)
Description
Changes the foreground color of text that will be output from this point forward.
Declared at: llvm/include/llvm/Support/raw_ostream.h:311
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 = false
- bold/brighter text, default false
- bool BG = false
- if true change the background, default: change foreground
Returns
itself so it can be used within < < invocations
¶bool colors_enabled() const
bool colors_enabled() const
Declared at: llvm/include/llvm/Support/raw_ostream.h:334
¶void copy_to_buffer(const char* Ptr, size_t Size)
void copy_to_buffer(const char* Ptr, size_t Size)
Description
Copy data into the buffer. Size must not be greater than the number of unused bytes in the buffer.
Declared at: llvm/include/llvm/Support/raw_ostream.h:392
Parameters
- const char* Ptr
- size_t Size
¶virtual uint64_t current_pos() const
virtual uint64_t current_pos() const
Description
Return the current position within the stream, not counting the bytes currently in the buffer.
Declared at: llvm/include/llvm/Support/raw_ostream.h:362
¶virtual void enable_colors(bool enable)
virtual void enable_colors(bool enable)
Declared at: llvm/include/llvm/Support/raw_ostream.h:332
Parameters
- bool enable
¶void flush()
void flush()
Declared at: llvm/include/llvm/Support/raw_ostream.h:187
¶void flush_nonempty()
void flush_nonempty()
Description
Flush the current buffer, which is known to be non-empty. This outputs the currently buffered data and resets the buffer to empty.
Declared at: llvm/include/llvm/Support/raw_ostream.h:388
¶void flush_tied_then_write(const char* Ptr,
size_t Size)
void flush_tied_then_write(const char* Ptr,
size_t Size)
Description
Flush the tied-to stream (if present) and then write the required data.
Declared at: llvm/include/llvm/Support/raw_ostream.h:399
Parameters
- const char* Ptr
- size_t Size
¶const char* getBufferStart() const
const char* getBufferStart() const
Description
Return the beginning of the current stream buffer, or 0 if the stream is unbuffered.
Declared at: llvm/include/llvm/Support/raw_ostream.h:377
¶llvm::raw_ostream::OStreamKind get_kind() const
llvm::raw_ostream::OStreamKind get_kind() const
Declared at: llvm/include/llvm/Support/raw_ostream.h:138
¶virtual bool has_colors() const
virtual bool has_colors() const
Description
This function determines if this stream is displayed and supports colors. The result is unaffected by calls to enable_color().
Declared at: llvm/include/llvm/Support/raw_ostream.h:328
¶llvm::raw_ostream& indent(unsigned int NumSpaces)
llvm::raw_ostream& indent(unsigned int NumSpaces)
Description
indent - Insert 'NumSpaces' spaces.
Declared at: llvm/include/llvm/Support/raw_ostream.h:299
Parameters
- unsigned int NumSpaces
¶virtual bool is_displayed() const
virtual 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/raw_ostream.h:324
¶virtual size_t preferred_buffer_size() const
virtual size_t preferred_buffer_size() const
Description
Return an efficient buffer size for the underlying output mechanism.
Declared at: llvm/include/llvm/Support/raw_ostream.h:373
¶bool prepare_colors()
bool prepare_colors()
Description
Compute whether colors should be used and do the necessary work such as flushing. The result is affected by calls to enable_color().
Declared at: llvm/include/llvm/Support/raw_ostream.h:396
¶raw_ostream(bool unbuffered = false,
llvm::raw_ostream::OStreamKind K =
OStreamKind::OK_OStream)
raw_ostream(bool unbuffered = false,
llvm::raw_ostream::OStreamKind K =
OStreamKind::OK_OStream)
Declared at: llvm/include/llvm/Support/raw_ostream.h:122
Parameters
- bool unbuffered = false
- llvm::raw_ostream::OStreamKind K = OStreamKind::OK_OStream
¶raw_ostream(const llvm::raw_ostream&)
raw_ostream(const llvm::raw_ostream&)
Declared at: llvm/include/llvm/Support/raw_ostream.h:130
Parameters
- const llvm::raw_ostream&
¶virtual void reserveExtraSpace(uint64_t ExtraSize)
virtual void reserveExtraSpace(uint64_t ExtraSize)
Description
If possible, pre-allocate \p ExtraSize bytes for stream data. i.e. it extends internal buffers to keep additional ExtraSize bytes. So that the stream could keep at least tell() + ExtraSize bytes without re-allocations. reserveExtraSpace() does not change the size/data of the stream.
Declared at: llvm/include/llvm/Support/raw_ostream.h:149
Parameters
- uint64_t ExtraSize
¶virtual llvm::raw_ostream& resetColor()
virtual 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/raw_ostream.h:316
¶virtual llvm::raw_ostream& reverseColor()
virtual llvm::raw_ostream& reverseColor()
Description
Reverses the foreground and background colors.
Declared at: llvm/include/llvm/Support/raw_ostream.h:319
¶uint64_t tell() const
uint64_t tell() const
Description
tell - Return the current offset with the file.
Declared at: llvm/include/llvm/Support/raw_ostream.h:136
¶void tie(llvm::raw_ostream* TieTo)
void tie(llvm::raw_ostream* TieTo)
Description
Tie this stream to the specified stream. Replaces any existing tied-to stream. Specifying a nullptr unties the stream.
Declared at: llvm/include/llvm/Support/raw_ostream.h:338
Parameters
- llvm::raw_ostream* TieTo
¶llvm::raw_ostream& write(const char* Ptr,
size_t Size)
llvm::raw_ostream& write(const char* Ptr,
size_t Size)
Declared at: llvm/include/llvm/Support/raw_ostream.h:281
Parameters
- const char* Ptr
- size_t Size
¶llvm::raw_ostream& write(unsigned char C)
llvm::raw_ostream& write(unsigned char C)
Declared at: llvm/include/llvm/Support/raw_ostream.h:280
Parameters
- unsigned char C
¶llvm::raw_ostream& write_escaped(
llvm::StringRef Str,
bool UseHexEscapes = false)
llvm::raw_ostream& write_escaped(
llvm::StringRef Str,
bool UseHexEscapes = false)
Description
Output \p Str, turning ' \ ', '\t', '\n', '"', and anything that doesn't satisfy llvm::isPrint into an escape sequence.
Declared at: llvm/include/llvm/Support/raw_ostream.h:278
Parameters
- llvm::StringRef Str
- bool UseHexEscapes = false
¶llvm::raw_ostream& write_hex(unsigned long long N)
llvm::raw_ostream& write_hex(unsigned long long N)
Description
Output \p N in hexadecimal, without any prefix or padding.
Declared at: llvm/include/llvm/Support/raw_ostream.h:267
Parameters
- unsigned long long N
¶virtual void write_impl(const char* Ptr,
size_t Size)
virtual 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/raw_ostream.h:358
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.
¶llvm::raw_ostream& write_uuid(const uint8_t* UUID)
llvm::raw_ostream& write_uuid(const uint8_t* UUID)
Declared at: llvm/include/llvm/Support/raw_ostream.h:274
Parameters
- const uint8_t* UUID
¶llvm::raw_ostream& write_zeros(
unsigned int NumZeros)
llvm::raw_ostream& write_zeros(
unsigned int NumZeros)
Description
write_zeros - Insert 'NumZeros' nulls.
Declared at: llvm/include/llvm/Support/raw_ostream.h:302
Parameters
- unsigned int NumZeros
¶virtual ~raw_ostream()
virtual ~raw_ostream()
Declared at: llvm/include/llvm/Support/raw_ostream.h:133