diff options
author | Derek Schuff <dschuff@chromium.org> | 2012-07-03 15:48:25 -0700 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2012-07-03 15:48:25 -0700 |
commit | 4f429c8b4e06d750b5464b6eafdd102af5196bdd (patch) | |
tree | 22a752c4654e3ab9e94c09739f7fb8f9e705433d /include/llvm/Wrap/file_wrapper_output.h | |
parent | e91f926f3b76774aa7ed4c327fbde6a39e42c87f (diff) |
Diff from hg rev 0b098ca44de7
Diffstat (limited to 'include/llvm/Wrap/file_wrapper_output.h')
-rw-r--r-- | include/llvm/Wrap/file_wrapper_output.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/llvm/Wrap/file_wrapper_output.h b/include/llvm/Wrap/file_wrapper_output.h new file mode 100644 index 0000000000..714bd36a75 --- /dev/null +++ b/include/llvm/Wrap/file_wrapper_output.h @@ -0,0 +1,34 @@ +/* Copyright 2012 The Native Client Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can + * be found in the LICENSE file. + */ + +// Defines utility allowing files for bitcode output wrapping. + +#ifndef FILE_WRAPPER_OUTPUT_H__ +#define FILE_WRAPPER_OUTPUT_H__ + +#include "llvm/Support/support_macros.h" +#include "llvm/Wrap/wrapper_output.h" +#include <stdio.h> +#include <string> + +// Define a class to wrap named files. */ +class FileWrapperOutput : public WrapperOutput { + public: + FileWrapperOutput(const std::string& name); + ~FileWrapperOutput(); + // Writes a single byte, returning false if unable to write. + virtual bool Write(uint8_t byte); + // Writes the specified number of bytes in the buffer to + // output. Returns false if unable to write. + virtual bool Write(const uint8_t* buffer, size_t buffer_size); + private: + // The name of the file + std::string _name; + // The corresponding (opened) file. + FILE* _file; + private: + DISALLOW_CLASS_COPY_AND_ASSIGN(FileWrapperOutput); +}; +#endif // FILE_WRAPPER_OUTPUT_H__ |