raw_ostream.h revision 533eae20118036f425f27bf0536ef0ccbb090b65
1//===- raw_ostream.h ------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_SUPPORT_RAWOSTREAM_H 10#define MCLD_SUPPORT_RAWOSTREAM_H 11#include <string> 12#include <llvm/Support/raw_ostream.h> 13 14namespace mcld { 15 16class raw_fd_ostream : public llvm::raw_fd_ostream 17{ 18public: 19 /// raw_fd_ostream - Open the specified file for writing. If an error occurs, 20 /// information about the error is put into ErrorInfo, and the stream should 21 /// be immediately destroyed; the string will be empty if no error occurred. 22 /// This allows optional flags to control how the file will be opened. 23 /// 24 /// As a special case, if Filename is "-", then the stream will use 25 /// STDOUT_FILENO instead of opening a file. Note that it will still consider 26 /// itself to own the file descriptor. In particular, it will close the 27 /// file descriptor when it is done (this is necessary to detect 28 /// output errors). 29 raw_fd_ostream(const char *pFilename, 30 std::string &pErrorInfo, 31 llvm::sys::fs::OpenFlags pFlags = llvm::sys::fs::F_None); 32 33 /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If 34 /// ShouldClose is true, this closes the file when the stream is destroyed. 35 raw_fd_ostream(int pFD, bool pShouldClose, bool pUnbuffered=false); 36 37 virtual ~raw_fd_ostream(); 38 39 void setColor(bool pEnable = true); 40 41 42 llvm::raw_ostream &changeColor(enum llvm::raw_ostream::Colors pColors, 43 bool pBold=false, 44 bool pBackground=false); 45 46 llvm::raw_ostream &resetColor(); 47 48 llvm::raw_ostream &reverseColor(); 49 50 bool is_displayed() const; 51 52private: 53 bool m_bConfigColor : 1; 54 bool m_bSetColor : 1; 55 56}; 57 58/// outs() - This returns a reference to a raw_ostream for standard output. 59/// Use it like: outs() << "foo" << "bar"; 60mcld::raw_fd_ostream &outs(); 61 62/// errs() - This returns a reference to a raw_ostream for standard error. 63/// Use it like: errs() << "foo" << "bar"; 64mcld::raw_fd_ostream &errs(); 65 66} // namespace of mcld 67 68#endif 69 70