1 //===-- 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 
14 #include <cstdio>
15 
16 namespace lldb {
17 
18 class LLDB_API SBFile {
19   friend class SBInstruction;
20   friend class SBInstructionList;
21   friend class SBDebugger;
22   friend class SBCommandReturnObject;
23   friend class SBProcess;
24 
25 public:
26   SBFile();
27   SBFile(FileSP file_sp);
28 #ifndef SWIG
29   SBFile(const SBFile &rhs);
30   SBFile(FILE *file, bool transfer_ownership);
31 #endif
32   SBFile(int fd, const char *mode, bool transfer_ownership);
33   ~SBFile();
34 
35   SBFile &operator=(const SBFile &rhs);
36 
37   SBError Read(uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
38   SBError Write(const uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
39   SBError Flush();
40   bool IsValid() const;
41   SBError Close();
42 
43   operator bool() const;
44 #ifndef SWIG
45   bool operator!() const;
46 #endif
47 
48   FileSP GetFile() const;
49 
50 private:
51   FileSP m_opaque_sp;
52 };
53 
54 } // namespace lldb
55 
56 #endif // LLDB_API_SBFILE_H
57