blob: e6b9a2d3240401c9075bccf9ee7217206f683024 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_ISTREAM_HPP_INCLUDED
#define CATCH_ISTREAM_HPP_INCLUDED
#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_unique_ptr.hpp>
#include <iosfwd>
#include <cstddef>
#include <ostream>
#include <string>
namespace Catch {
class IStream {
public:
virtual ~IStream(); // = default
virtual std::ostream& stream() = 0;
/**
* Best guess on whether the instance is writing to a console (e.g. via stdout/stderr)
*
* This is useful for e.g. Win32 colour support, because the Win32
* API manipulates console directly, unlike POSIX escape codes,
* that can be written anywhere.
*
* Due to variety of ways to change where the stdout/stderr is
* _actually_ being written, users should always assume that
* the answer might be wrong.
*/
virtual bool isConsole() const { return false; }
};
/**
* Creates a stream wrapper that writes to specific file.
*
* Also recognizes 4 special filenames
* * `-` for stdout
* * `%stdout` for stdout
* * `%stderr` for stderr
* * `%debug` for platform specific debugging output
*
* \throws if passed an unrecognized %-prefixed stream
*/
auto makeStream( std::string const& filename ) -> Detail::unique_ptr<IStream>;
}
#endif // CATCH_STREAM_HPP_INCLUDED
|