1 /* 2 * Copyright 2012, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // Define a generic interface to a file/memory region that contains 18 // a bitcode file, a wrapped bitcode file, or a data file to wrap. 19 20 #ifndef LLVM_WRAP_WRAPPER_INPUT_H__ 21 #define LLVM_WRAP_WRAPPER_INPUT_H__ 22 23 #include <stdint.h> 24 #include <sys/types.h> 25 26 #include "support_macros.h" 27 28 // The following is a generic interface to a file/memory region that contains 29 // a bitcode file, a wrapped bitcode file, or data file to wrap. 30 class WrapperInput { 31 public: 32 WrapperInput() {} 33 virtual ~WrapperInput() {} 34 // Tries to read the requested number of bytes into the buffer. Returns the 35 // actual number of bytes read. 36 virtual size_t Read(uint8_t* buffer, size_t wanted) = 0; 37 // Returns true if at end of input. Note: May return false until 38 // Read is called, and returns 0. 39 virtual bool AtEof() = 0; 40 // Returns the size of the input (in bytes). 41 virtual off_t Size() = 0; 42 // Moves to the given offset within the input region. Returns false 43 // if unable to move to that position. 44 virtual bool Seek(uint32_t pos) = 0; 45 private: 46 DISALLOW_CLASS_COPY_AND_ASSIGN(WrapperInput); 47 }; 48 49 #endif // LLVM_WRAP_WRAPPER_INPUT_H__ 50