LLDB  mainline
StreamFile.h
Go to the documentation of this file.
1 //===-- StreamFile.h --------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_CORE_STREAMFILE_H
10 #define LLDB_CORE_STREAMFILE_H
11 
12 #include "lldb/Host/File.h"
13 #include "lldb/Utility/Stream.h"
14 #include "lldb/lldb-defines.h"
15 #include "lldb/lldb-enumerations.h"
16 
17 #include <cstdint>
18 #include <cstdio>
19 
20 namespace lldb_private {
21 
22 class StreamFile : public Stream {
23 public:
24  StreamFile(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
25 
26  StreamFile(int fd, bool transfer_ownership);
27 
28  StreamFile(const char *path, File::OpenOptions options,
29  uint32_t permissions = lldb::eFilePermissionsFileDefault);
30 
31  StreamFile(FILE *fh, bool transfer_ownership);
32 
33  StreamFile(std::shared_ptr<File> file) : m_file_sp(file) { assert(file); };
34 
35  ~StreamFile() override;
36 
37  File &GetFile() { return *m_file_sp; }
38 
39  const File &GetFile() const { return *m_file_sp; }
40 
41  std::shared_ptr<File> GetFileSP() { return m_file_sp; }
42 
43  void Flush() override;
44 
45 protected:
46  // Classes that inherit from StreamFile can see and modify these
47  std::shared_ptr<File> m_file_sp; // never NULL
48  size_t WriteImpl(const void *s, size_t length) override;
49 
50 private:
51  StreamFile(const StreamFile &) = delete;
52  const StreamFile &operator=(const StreamFile &) = delete;
53 };
54 
55 } // namespace lldb_private
56 
57 #endif // LLDB_CORE_STREAMFILE_H
lldb_private::StreamFile::WriteImpl
size_t WriteImpl(const void *s, size_t length) override
Output character bytes to the stream.
Definition: StreamFile.cpp:50
lldb_private::StreamFile::GetFile
const File & GetFile() const
Definition: StreamFile.h:39
lldb_private::File::OpenOptions
OpenOptions
Definition: File.h:46
lldb_private::StreamFile::GetFileSP
std::shared_ptr< File > GetFileSP()
Definition: StreamFile.h:41
lldb-defines.h
lldb_private::Stream
Definition: Stream.h:28
lldb_private::StreamFile::operator=
const StreamFile & operator=(const StreamFile &)=delete
lldb-enumerations.h
lldb_private::File
Definition: File.h:34
lldb_private::StreamFile::~StreamFile
~StreamFile() override
lldb_private::StreamFile::StreamFile
StreamFile(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order)
Definition: StreamFile.cpp:18
lldb_private::StreamFile::GetFile
File & GetFile()
Definition: StreamFile.h:37
lldb_private::StreamFile::StreamFile
StreamFile(std::shared_ptr< File > file)
Definition: StreamFile.h:33
uint32_t
lldb_private::StreamFile::m_file_sp
std::shared_ptr< File > m_file_sp
Definition: StreamFile.h:47
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::StreamFile::Flush
void Flush() override
Flush the stream.
Definition: StreamFile.cpp:48
lldb_private::StreamFile
Definition: StreamFile.h:22
Stream.h
File.h
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138