blob: a8b16520332d3c12070dcfe68b4443e43ad7706d [file] [log] [blame]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001//===-- SBFile.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_API_SBFILE_H
10#define LLDB_API_SBFILE_H
11
12#include "lldb/API/SBDefines.h"
13
14namespace lldb {
15
16class LLDB_API SBFile {
17 friend class SBInstruction;
18 friend class SBInstructionList;
19 friend class SBDebugger;
20 friend class SBCommandReturnObject;
21 friend class SBProcess;
22
23public:
24 SBFile();
25 SBFile(FileSP file_sp);
26 SBFile(const SBFile &rhs);
27 SBFile(FILE *file, bool transfer_ownership);
28 SBFile(int fd, const char *mode, bool transfer_ownership);
29 ~SBFile();
30
31 SBFile &operator=(const SBFile &rhs);
32
33 SBError Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read);
34 SBError Write(const uint8_t *buf, size_t num_bytes, size_t *bytes_written);
35 SBError Flush();
36 bool IsValid() const;
37 SBError Close();
38
39 operator bool() const;
40 bool operator!() const;
41
42 FileSP GetFile() const;
43
44private:
45 FileSP m_opaque_sp;
46};
47
48} // namespace lldb
49
50#endif // LLDB_API_SBFILE_H