CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ConsoleManip.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include <iostream>
11#include <ostream>
12
14
16 struct ColorFlags {
17 enum {
19 Red = (1 << 0),
20
22 Green = (1 << 1),
23
25 Blue = (1 << 2),
26
28 Intens = (1 << 3),
29
31 Black = 0,
32
34 Gray = (Red | Green | Blue),
35
38
41
44
47 };
48 };
49
51 void enable(bool enable);
52
54 bool isEnabled();
55
62 void pushColor(long front, std::ostream& stream = std::cout);
63
72 void pushColor(long front, long back, std::ostream& stream = std::cout);
73
75 void popColor(std::ostream& stream = std::cout);
76
79 private:
80 std::ostream& mStream;
81
82 public:
88 inline explicit ScopedColor(const long front, std::ostream& stream = std::cout) : mStream{stream} { pushColor(front, mStream); }
89
96 inline ScopedColor(const long front, const long back, std::ostream& stream = std::cout) : mStream{stream} { pushColor(front, back, mStream); }
97
101 };
102
103} // namespace CeresEngine::ShaderCompiler::ConsoleManip
Helper class for scoped color stack operations.
Definition ConsoleManip.hpp:78
ScopedColor(const long front, std::ostream &stream=std::cout)
Constructor with output stream and front color flags.
Definition ConsoleManip.hpp:88
ScopedColor(const long front, const long back, std::ostream &stream=std::cout)
Constructor with output stream, and front- and back color flags.
Definition ConsoleManip.hpp:96
std::ostream & mStream
Definition ConsoleManip.hpp:80
~ScopedColor()
Destructor which will reset the previous color from the output stream.
Definition ConsoleManip.hpp:100
Definition ConsoleManip.hpp:13
bool isEnabled()
Returns true if console manipulation is enabled.
void enable(bool enable)
Enables or disables console manipulation. By default enabled.
void pushColor(long front, std::ostream &stream=std::cout)
Pushes the specified front color flags onto the stack.
void popColor(std::ostream &stream=std::cout)
Pops the previous front and back color flags from the stack.
Output stream color flags enumeration.
Definition ConsoleManip.hpp:16
@ Black
Black color flag.
Definition ConsoleManip.hpp:31
@ Blue
Blue color flag.
Definition ConsoleManip.hpp:25
@ Pink
Pink color flag (Red | Blue | Intens).
Definition ConsoleManip.hpp:43
@ Intens
Intensity color flag.
Definition ConsoleManip.hpp:28
@ Cyan
Cyan color flag (Green | Blue | Intens).
Definition ConsoleManip.hpp:46
@ Yellow
Yellow color flag (Red | Green | Intens).
Definition ConsoleManip.hpp:40
@ Green
Green color flag.
Definition ConsoleManip.hpp:22
@ White
White color flag (Gray | Intens).
Definition ConsoleManip.hpp:37
@ Red
Red color flag.
Definition ConsoleManip.hpp:19
@ Gray
Gray color flag (Red | Green | Blue).
Definition ConsoleManip.hpp:34