LLVM 24.0.0git
llvm::CachedFileStream Class Reference

This class wraps an output stream for a file. More...

#include "llvm/Support/Caching.h"

Public Member Functions

 CachedFileStream (std::unique_ptr< raw_pwrite_stream > OS, std::string OSPath="")
virtual Error commit ()
 Must be called after the writes to OS have been completed successfully but before the CachedFileStream object is destroyed.
virtual Error commit (std::unique_ptr< MemoryBuffer > MemBuf)
virtual Error abort ()
 Must be called if the file was not committed before its destroyed (for example if some writes didn't complete).
virtual ~CachedFileStream ()

Public Attributes

bool Committed = false
bool Aborted = false
std::unique_ptr< raw_pwrite_stream > OS
std::string ObjectPathName

Detailed Description

This class wraps an output stream for a file.

Most clients should just be able to return an instance of this base class from the stream callback, but if a client needs to perform some action after the stream is written to, that can be done by deriving from this class and overriding the destructor or the commit() method. Before destruction of this class, either commit() or abort() must be called.

Definition at line 30 of file Caching.h.

Constructor & Destructor Documentation

◆ CachedFileStream()

llvm::CachedFileStream::CachedFileStream ( std::unique_ptr< raw_pwrite_stream > OS,
std::string OSPath = "" )
inline

Definition at line 32 of file Caching.h.

References llvm::move(), ObjectPathName, and OS.

Referenced by llvm::localCache().

◆ ~CachedFileStream()

virtual llvm::CachedFileStream::~CachedFileStream ( )
inlinevirtual

Definition at line 70 of file Caching.h.

References Aborted, Committed, and llvm::report_fatal_error().

Member Function Documentation

◆ abort()

virtual Error llvm::CachedFileStream::abort ( )
inlinevirtual

Must be called if the file was not committed before its destroyed (for example if some writes didn't complete).

Definition at line 56 of file Caching.h.

References Aborted, Committed, llvm::createStringError(), llvm::make_error_code(), OS, and llvm::Error::success().

Referenced by llvm::localCache().

◆ commit() [1/2]

virtual Error llvm::CachedFileStream::commit ( )
inlinevirtual

Must be called after the writes to OS have been completed successfully but before the CachedFileStream object is destroyed.

Definition at line 38 of file Caching.h.

References Aborted, Committed, llvm::createStringError(), llvm::make_error_code(), and llvm::Error::success().

Referenced by commit(), and llvm::localCache().

◆ commit() [2/2]

virtual Error llvm::CachedFileStream::commit ( std::unique_ptr< MemoryBuffer > MemBuf)
inlinevirtual

Definition at line 50 of file Caching.h.

References commit().

Member Data Documentation

◆ Aborted

bool llvm::CachedFileStream::Aborted = false

Definition at line 67 of file Caching.h.

Referenced by abort(), commit(), and ~CachedFileStream().

◆ Committed

bool llvm::CachedFileStream::Committed = false

Definition at line 66 of file Caching.h.

Referenced by abort(), commit(), and ~CachedFileStream().

◆ ObjectPathName

std::string llvm::CachedFileStream::ObjectPathName

Definition at line 69 of file Caching.h.

Referenced by CachedFileStream().

◆ OS

std::unique_ptr<raw_pwrite_stream> llvm::CachedFileStream::OS

Definition at line 68 of file Caching.h.

Referenced by abort(), and CachedFileStream().


The documentation for this class was generated from the following file: