#define LLVM_SUPPORT_RAW_OSTREAM_H
#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataTypes.h"
+#include <system_error>
namespace llvm {
class format_object_base;
void error_detected() { Error = true; }
public:
- /// raw_fd_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.
- /// This allows optional flags to control how the file will be opened.
+ /// Open the specified file for writing. If an error occurs, information
+ /// about the error is put into EC, and the stream should be immediately
+ /// destroyed;
+ /// \p Flags allows optional flags to control how the file will be opened.
///
/// As a special case, if Filename is "-", then the stream will use
/// STDOUT_FILENO instead of opening a file. Note that it will still consider
/// itself to own the file descriptor. In particular, it will close the
/// file descriptor when it is done (this is necessary to detect
/// output errors).
- raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
+ raw_fd_ostream(StringRef Filename, std::error_code &EC,
sys::fs::OpenFlags Flags);
/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
/// current_pos - Return the current position within the stream, not
/// counting the bytes currently in the buffer.
uint64_t current_pos() const override;
-
-protected:
- // This constructor is specified not to access \p O provided for storage as it
- // may not yet be initialized at construction time.
- explicit raw_svector_ostream(SmallVectorImpl<char> &O, std::nullptr_t)
- : OS(O){};
- void init();
-
public:
/// Construct a new raw_svector_ostream.
///
~raw_null_ostream();
};
-/// string_ostream - A raw_ostream that builds a string. This is a
-/// raw_svector_ostream with storage.
-template <unsigned InternalLen>
-class small_string_ostream : public raw_svector_ostream {
- SmallVector<char, InternalLen> Buffer;
- // There's no need to flush explicitly.
- using raw_svector_ostream::flush;
-
-public:
- small_string_ostream() : raw_svector_ostream(Buffer, nullptr) { init(); }
-
- void clear() {
- flush();
- Buffer.clear();
- }
-};
-
-typedef small_string_ostream<128> string_ostream;
-
} // end llvm namespace
#endif