| 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. |
| 14 |
|
| 15 |
#ifndef SOURCE_PRINT_H_ |
| 16 |
#define SOURCE_PRINT_H_ |
| 17 |
|
| 18 |
#include <iostream> |
| 19 |
#include <sstream> |
| 20 |
|
| 21 |
namespace spvtools { |
| 22 |
|
| 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) {} |
| 28 |
|
| 29 |
std::ostream& get() { |
| 30 |
if (pStream) { |
| 31 |
return *pStream; |
| 32 |
} |
| 33 |
return std::cout; |
| 34 |
} |
| 35 |
|
| 36 |
private: |
| 37 |
std::stringstream* pStream; |
| 38 |
}; |
| 39 |
|
| 40 |
namespace clr { |
| 41 |
// Resets console color. |
| 42 |
struct reset { |
| 43 |
operator const char*(); |
| 44 |
bool isPrint; |
| 45 |
}; |
| 46 |
// Sets console color to grey. |
| 47 |
struct grey { |
| 48 |
operator const char*(); |
| 49 |
bool isPrint; |
| 50 |
}; |
| 51 |
// Sets console color to red. |
| 52 |
struct red { |
| 53 |
operator const char*(); |
| 54 |
bool isPrint; |
| 55 |
}; |
| 56 |
// Sets console color to green. |
| 57 |
struct green { |
| 58 |
operator const char*(); |
| 59 |
bool isPrint; |
| 60 |
}; |
| 61 |
// Sets console color to yellow. |
| 62 |
struct yellow { |
| 63 |
operator const char*(); |
| 64 |
bool isPrint; |
| 65 |
}; |
| 66 |
// Sets console color to blue. |
| 67 |
struct blue { |
| 68 |
operator const char*(); |
| 69 |
bool isPrint; |
| 70 |
}; |
| 71 |
} // namespace clr |
| 72 |
|
| 73 |
} // namespace spvtools |
| 74 |
|
| 75 |
#endif // SOURCE_PRINT_H_ |