14 #ifndef LLVM_SUPPORT_RAW_OSTREAM_H
15 #define LLVM_SUPPORT_RAW_OSTREAM_H
19 #include "llvm/Support/DataTypes.h"
23 class format_object_base;
25 class SmallVectorImpl;
54 char *OutBufStart, *OutBufEnd, *OutBufCur;
77 : BufferMode(unbuffered ? Unbuffered : InternalBuffer) {
79 OutBufStart = OutBufEnd = OutBufCur = 0;
99 SetBufferAndMode(
new char[Size], Size, InternalBuffer);
105 if (BufferMode != Unbuffered && OutBufStart == 0)
109 return OutBufEnd - OutBufStart;
118 SetBufferAndMode(0, 0, Unbuffered);
122 return OutBufCur - OutBufStart;
130 if (OutBufCur != OutBufStart)
135 if (OutBufCur >= OutBufEnd)
142 if (OutBufCur >= OutBufEnd)
149 if (OutBufCur >= OutBufEnd)
157 size_t Size = Str.
size();
160 if (OutBufCur+Size > OutBufEnd)
177 return write(Str.data(), Str.length());
186 return this->operator<<(static_cast<unsigned long>(
N));
190 return this->operator<<(static_cast<long>(
N));
261 virtual void write_impl(
const char *Ptr,
size_t Size) = 0;
264 virtual void handle();
268 virtual uint64_t current_pos()
const = 0;
276 SetBufferAndMode(BufferStart, Size, ExternalBuffer);
292 void SetBufferAndMode(
char *BufferStart,
size_t Size, BufferKind Mode);
297 void flush_nonempty();
301 void copy_to_buffer(
const char *Ptr,
size_t Size);
320 bool UseAtomicWrites;
325 virtual void write_impl(
const char *Ptr,
size_t Size)
LLVM_OVERRIDE;
329 virtual uint64_t current_pos()
const LLVM_OVERRIDE {
return pos; }
336 void error_detected() { Error =
true; }
364 uint64_t
seek(uint64_t off);
373 UseAtomicWrites = Value;
384 virtual
bool has_colors() const LLVM_OVERRIDE;
418 raw_ostream &
nulls();
430 virtual void write_impl(
const char *Ptr,
size_t Size)
LLVM_OVERRIDE;
434 virtual uint64_t current_pos()
const LLVM_OVERRIDE {
return OS.size(); }
454 virtual void write_impl(
const char *Ptr,
size_t Size)
LLVM_OVERRIDE;
480 virtual void write_impl(
const char *Ptr,
size_t size)
LLVM_OVERRIDE;
void SetUseAtomicWrites(bool Value)
virtual raw_ostream & resetColor() LLVM_OVERRIDE
const char * getBufferStart() const
size_t size() const
size - Get the string size.
raw_string_ostream(std::string &O)
raw_null_ostream - A raw_ostream that discards all output.
uint64_t seek(uint64_t off)
virtual bool has_colors() const
This function determines if this stream is displayed and supports colors.
virtual raw_ostream & changeColor(enum Colors Color, bool Bold=false, bool BG=false)
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
raw_ostream & operator<<(const std::string &Str)
raw_ostream & operator<<(const char *Str)
raw_ostream & operator<<(int N)
void SetBuffer(char *BufferStart, size_t Size)
raw_svector_ostream(SmallVectorImpl< char > &O)
uint64_t tell() const
tell - Return the current offset with the file.
const char * data() const
raw_ostream & write_hex(unsigned long long N)
write_hex - Output N in hexadecimal, without any prefix or padding.
virtual bool is_displayed() const
raw_ostream & operator<<(char C)
virtual raw_ostream & changeColor(enum Colors colors, bool bold=false, bool bg=false) LLVM_OVERRIDE
raw_fd_ostream(const char *Filename, std::string &ErrorInfo, sys::fs::OpenFlags Flags=sys::fs::F_None)
raw_ostream & operator<<(unsigned char C)
virtual raw_ostream & reverseColor()
Reverses the forground and background colors.
raw_ostream(bool unbuffered=false)
void SetBufferSize(size_t Size)
raw_ostream & write(unsigned char C)
size_t GetBufferSize() const
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
virtual bool has_colors() const LLVM_OVERRIDE
This function determines if this stream is displayed and supports colors.
virtual size_t preferred_buffer_size() const
#define LLVM_DELETED_FUNCTION
raw_ostream & operator<<(unsigned int N)
virtual raw_ostream & reverseColor() LLVM_OVERRIDE
Reverses the forground and background colors.
raw_ostream & operator<<(StringRef Str)
virtual raw_ostream & resetColor()
LLVM Value Representation.
raw_ostream & nulls()
nulls() - This returns a reference to a raw_ostream which discards output.
raw_ostream & operator<<(signed char C)
virtual bool is_displayed() const LLVM_OVERRIDE
size_t GetNumBytesInBuffer() const