nomlib
Toggle main menu visibility
Loading...
Searching...
No Matches
include
nomlib
core
ConsoleOutput.hpp
1
/******************************************************************************
2
3
nomlib - C++11 cross-platform game engine
4
5
Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
******************************************************************************/
29
#ifndef NOMLIB_CORE_CONSOLE_OUTPUT_HPP
30
#define NOMLIB_CORE_CONSOLE_OUTPUT_HPP
31
32
#include <memory>
33
34
#include "export.hpp"
35
#include "nomlib/config.hpp"
36
37
namespace
nom {
38
44
class
NOM_EXPORT
ConsoleOutput
45
{
46
public
:
47
enum
Color
48
{
49
FG_WHITE,
50
FG_RED
,
51
FG_GREEN,
52
FG_BLUE,
53
FG_MAGENTA,
54
FG_YELLOW,
55
FG_ORANGE,
56
FG_PURPLE
,
57
};
58
59
enum
: uint32
60
{
62
STYLE_NONE
= 0,
63
STYLE_BOLD = 0x1,
64
STYLE_UNDERLINED = 0x2
65
};
66
69
ConsoleOutput
();
70
74
ConsoleOutput
( std::ostream& os );
75
76
virtual
~ConsoleOutput
();
77
82
ConsoleOutput::Color
color
()
const
;
83
95
bool
use_color
()
const
;
96
97
virtual
void
set_color(
ConsoleOutput::Color
color
);
98
99
virtual
void
set_style( uint32 style );
100
105
virtual
void
endl
();
106
107
protected
:
109
std::ostream&
out_
;
110
115
ConsoleOutput::Color
lcolor_
;
116
117
private
:
122
std::string
env
(
const
std::string& path)
const
;
123
127
std::unique_ptr<ConsoleOutput>
impl_
;
128
};
129
130
}
// namespace nom
131
132
#endif
// include guard defined
nom::ConsoleOutput::out_
std::ostream & out_
The output stream to use; i.e.: std::cout or std::cerr.
Definition
ConsoleOutput.hpp:109
nom::ConsoleOutput::env
std::string env(const std::string &path) const
Get the value of an environment variable.
nom::ConsoleOutput::STYLE_NONE
@ STYLE_NONE
Resets the text colors.
Definition
ConsoleOutput.hpp:62
nom::ConsoleOutput::ConsoleOutput
ConsoleOutput(std::ostream &os)
Construct a console output object with a custom output stream.
nom::ConsoleOutput::impl_
std::unique_ptr< ConsoleOutput > impl_
The platform-dependent implementation to use.
Definition
ConsoleOutput.hpp:127
nom::ConsoleOutput::endl
virtual void endl()
Reset the colors that have been set.
nom::ConsoleOutput::ConsoleOutput
ConsoleOutput()
Default constructor; initializes the output stream to use std::cerr (the standard error stream).
nom::ConsoleOutput::Color
Color
Definition
ConsoleOutput.hpp:48
nom::ConsoleOutput::FG_RED
@ FG_RED
Definition
ConsoleOutput.hpp:50
nom::ConsoleOutput::FG_PURPLE
@ FG_PURPLE
Definition
ConsoleOutput.hpp:56
nom::ConsoleOutput::lcolor_
ConsoleOutput::Color lcolor_
The last color used.
Definition
ConsoleOutput.hpp:115
nom::ConsoleOutput::color
ConsoleOutput::Color color() const
Get the last color that was set.
nom::ConsoleOutput::use_color
bool use_color() const
Get the current use state of colored output logging.
Generated on
for nomlib by
1.18.0