raw_os_ostream.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- raw_os_ostream.h - std::ostream adaptor for raw_ostream --*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the raw_os_ostream class.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_SUPPORT_RAW_OS_OSTREAM_H
  18. #define LLVM_SUPPORT_RAW_OS_OSTREAM_H
  19. #include "llvm/Support/raw_ostream.h"
  20. #include <iosfwd>
  21. namespace llvm {
  22. /// raw_os_ostream - A raw_ostream that writes to an std::ostream. This is a
  23. /// simple adaptor class. It does not check for output errors; clients should
  24. /// use the underlying stream to detect errors.
  25. class raw_os_ostream : public raw_ostream {
  26. std::ostream &OS;
  27. /// write_impl - See raw_ostream::write_impl.
  28. void write_impl(const char *Ptr, size_t Size) override;
  29. /// current_pos - Return the current position within the stream, not
  30. /// counting the bytes currently in the buffer.
  31. uint64_t current_pos() const override;
  32. public:
  33. raw_os_ostream(std::ostream &O) : OS(O) {}
  34. ~raw_os_ostream() override;
  35. };
  36. } // end llvm namespace
  37. #endif
  38. #ifdef __GNUC__
  39. #pragma GCC diagnostic pop
  40. #endif