Home | History | Annotate | Download | only in Wrap
      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 // Defines utility allowing files for bitcode output wrapping.
     18 
     19 #ifndef FILE_WRAPPER_OUTPUT_H__
     20 #define FILE_WRAPPER_OUTPUT_H__
     21 
     22 #include <stdio.h>
     23 
     24 #include "bcinfo/Wrap/support_macros.h"
     25 #include "bcinfo/Wrap/wrapper_output.h"
     26 
     27 // Define a class to wrap named files. */
     28 class FileWrapperOutput : public WrapperOutput {
     29  public:
     30   explicit FileWrapperOutput(const char* name);
     31   ~FileWrapperOutput();
     32   // Writes a single byte, returning false if unable to write.
     33   virtual bool Write(uint8_t byte);
     34   // Writes the specified number of bytes in the buffer to
     35   // output. Returns false if unable to write.
     36   virtual bool Write(const uint8_t* buffer, size_t buffer_size);
     37  private:
     38   // The name of the file
     39   const char* _name;
     40   // The corresponding (opened) file.
     41   FILE* _file;
     42  private:
     43   DISALLOW_CLASS_COPY_AND_ASSIGN(FileWrapperOutput);
     44 };
     45 #endif  // FILE_WRAPPER_OUTPUT_H__
     46