Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:57

0001 //===-- IOObject.h ----------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_UTILITY_IOOBJECT_H
0010 #define LLDB_UTILITY_IOOBJECT_H
0011 
0012 #include <cstdarg>
0013 #include <cstdio>
0014 #include <sys/types.h>
0015 
0016 #include "lldb/lldb-private.h"
0017 
0018 namespace lldb_private {
0019 
0020 class IOObject {
0021 public:
0022   enum FDType {
0023     eFDTypeFile,   // Other FD requiring read/write
0024     eFDTypeSocket, // Socket requiring send/recv
0025   };
0026 
0027   // TODO: On Windows this should be a HANDLE, and wait should use
0028   // WaitForMultipleObjects
0029   typedef int WaitableHandle;
0030   static const WaitableHandle kInvalidHandleValue;
0031 
0032   IOObject(FDType type) : m_fd_type(type) {}
0033   virtual ~IOObject();
0034 
0035   virtual Status Read(void *buf, size_t &num_bytes) = 0;
0036   virtual Status Write(const void *buf, size_t &num_bytes) = 0;
0037   virtual bool IsValid() const = 0;
0038   virtual Status Close() = 0;
0039 
0040   FDType GetFdType() const { return m_fd_type; }
0041 
0042   virtual WaitableHandle GetWaitableHandle() = 0;
0043 
0044 protected:
0045   FDType m_fd_type;
0046 
0047 private:
0048   IOObject(const IOObject &) = delete;
0049   const IOObject &operator=(const IOObject &) = delete;
0050 };
0051 } // namespace lldb_private
0052 
0053 #endif