- raw_ostream &operator<<(double N) {
- return this->operator<<(ftostr(N));
- }
-
-
- raw_ostream &write(const char *Ptr, unsigned Size) {
- if (OutBufCur+Size > OutBufEnd)
- flush_impl();
-
- // Handle short strings specially, memcpy isn't very good at very short
- // strings.
- switch (Size) {
- case 4: OutBufCur[3] = Ptr[3]; // FALL THROUGH
- case 3: OutBufCur[2] = Ptr[2]; // FALL THROUGH
- case 2: OutBufCur[1] = Ptr[1]; // FALL THROUGH
- case 1: OutBufCur[0] = Ptr[0]; // FALL THROUGH
- case 0: break;
- default:
- // Normally the string to emit is shorter than the buffer.
- if (Size <= unsigned(OutBufEnd-OutBufStart)) {
- memcpy(OutBufCur, Ptr, Size);
- break;
- }
-
- // If emitting a string larger than our buffer, emit in chunks. In this
- // case we know that we just flushed the buffer.
- while (Size) {
- unsigned NumToEmit = OutBufEnd-OutBufStart;
- if (Size < NumToEmit) NumToEmit = Size;
- assert(OutBufCur == OutBufStart);
- memcpy(OutBufStart, Ptr, NumToEmit);
- Ptr += NumToEmit;
- OutBufCur = OutBufStart + NumToEmit;
- flush_impl();
- }
- break;
- }
- OutBufCur += Size;
- return *this;
- }
-
+ raw_ostream &operator<<(double N);
+
+ /// write_hex - Output \arg N in hexadecimal, without any prefix or padding.
+ raw_ostream &write_hex(unsigned long long N);
+
+ /// write_escaped - Output \arg Str, turning '\\', '\t', '\n', '"', and
+ /// anything that doesn't satisfy std::isprint into an escape sequence.
+ raw_ostream &write_escaped(StringRef Str, bool UseHexEscapes = false);
+
+ raw_ostream &write(unsigned char C);
+ raw_ostream &write(const char *Ptr, size_t Size);
+
+ // Formatted output, see the format() function in Support/Format.h.
+ raw_ostream &operator<<(const format_object_base &Fmt);
+
+ /// indent - Insert 'NumSpaces' spaces.
+ raw_ostream &indent(unsigned NumSpaces);
+
+
+ /// Changes the foreground color of text that will be output from this point
+ /// forward.
+ /// @param colors ANSI color to use, the special SAVEDCOLOR can be used to
+ /// change only the bold attribute, and keep colors untouched
+ /// @param bold bold/brighter text, default false
+ /// @param bg if true change the background, default: change foreground
+ /// @returns itself so it can be used within << invocations
+ virtual raw_ostream &changeColor(enum Colors, bool = false, bool = false) {
+ return *this; }
+
+ /// Resets the colors to terminal defaults. Call this when you are done
+ /// outputting colored text, or before program exit.
+ virtual raw_ostream &resetColor() { return *this; }
+
+ /// Reverses the forground and background colors.
+ virtual raw_ostream &reverseColor() { return *this; }
+
+ /// 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.
+ virtual bool is_displayed() const { return false; }
+
+ /// This function determines if this stream is displayed and supports colors.
+ virtual bool has_colors() const { return is_displayed(); }
+