Update path-to-regexp to address CVE-2024-45296 (#5895)
[KhronosGroup/SPIRV-Tools.git] / source / print.h
blobf31ba38e70a5a54f4c711eca4fa425c79c655ed9
1 // Copyright (c) 2015-2016 The Khronos Group Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef SOURCE_PRINT_H_
16 #define SOURCE_PRINT_H_
18 #include <iostream>
19 #include <sstream>
21 namespace spvtools {
23 // Wrapper for out stream selection.
24 class out_stream {
25 public:
26 out_stream() : pStream(nullptr) {}
27 explicit out_stream(std::stringstream& stream) : pStream(&stream) {}
29 std::ostream& get() {
30 if (pStream) {
31 return *pStream;
33 return std::cout;
36 private:
37 std::stringstream* pStream;
40 namespace clr {
41 // Resets console color.
42 struct reset {
43 operator const char*();
44 bool isPrint;
46 // Sets console color to grey.
47 struct grey {
48 operator const char*();
49 bool isPrint;
51 // Sets console color to red.
52 struct red {
53 operator const char*();
54 bool isPrint;
56 // Sets console color to green.
57 struct green {
58 operator const char*();
59 bool isPrint;
61 // Sets console color to yellow.
62 struct yellow {
63 operator const char*();
64 bool isPrint;
66 // Sets console color to blue.
67 struct blue {
68 operator const char*();
69 bool isPrint;
71 } // namespace clr
73 } // namespace spvtools
75 #endif // SOURCE_PRINT_H_