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_HOST_STREAMFILE_H
10#define LLDB_HOST_STREAMFILE_H
11
12#include "lldb/Host/File.h"
13#include "lldb/Utility/Stream.h"
14#include "lldb/lldb-defines.h"
16
17#include <cstdint>
18#include <cstdio>
19
20namespace lldb_private {
21
22class StreamFile : public Stream {
23public:
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
45protected:
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
50private:
51 StreamFile(const StreamFile &) = delete;
52 const StreamFile &operator=(const StreamFile &) = delete;
53};
54
55} // namespace lldb_private
56
57#endif // LLDB_HOST_STREAMFILE_H
An abstract base class for files.
Definition: File.h:36
const StreamFile & operator=(const StreamFile &)=delete
const File & GetFile() const
Definition: StreamFile.h:39
StreamFile(std::shared_ptr< File > file)
Definition: StreamFile.h:33
std::shared_ptr< File > m_file_sp
Definition: StreamFile.h:47
void Flush() override
Flush the stream.
Definition: StreamFile.cpp:49
StreamFile(const StreamFile &)=delete
size_t WriteImpl(const void *s, size_t length) override
Output character bytes to the stream.
Definition: StreamFile.cpp:51
std::shared_ptr< File > GetFileSP()
Definition: StreamFile.h:41
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
ByteOrder
Byte ordering definitions.