1 //===-- StreamWrapper.h -----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_UTILS_TESTUTILS_STREAMWRAPPER_H
10 #define LLVM_LIBC_UTILS_TESTUTILS_STREAMWRAPPER_H
11 
12 namespace __llvm_libc {
13 namespace testutils {
14 
15 // StreamWrapper is necessary because llvm/Support/raw_ostream.h includes
16 // standard headers so we must provide streams through indirection to not
17 // expose the system libc headers.
18 class StreamWrapper {
19 protected:
20   void *os;
21 
22 public:
StreamWrapper(void * OS)23   StreamWrapper(void *OS) : os(OS) {}
24 
25   template <typename T> StreamWrapper &operator<<(T t);
26 };
27 
28 StreamWrapper outs();
29 
30 class OutputFileStream : public StreamWrapper {
31 public:
32   explicit OutputFileStream(const char *FN);
33   ~OutputFileStream();
34 };
35 
36 } // namespace testutils
37 } // namespace __llvm_libc
38 
39 #endif // LLVM_LIBC_UTILS_TESTUTILS_STREAMWRAPPER_H
40