nomlib
Loading...
Searching...
No Matches
ConsoleOutput.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. 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
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON 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
26SOFTWARE, 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 "nomlib/config.hpp"
35
36namespace nom {
37
44{
45 public:
46 enum Color
47 {
48 FG_WHITE,
50 FG_GREEN,
51 FG_BLUE,
52 FG_MAGENTA,
53 FG_YELLOW,
54 FG_ORANGE,
56 };
57
58 enum: uint32
59 {
62 STYLE_BOLD = 0x1,
63 STYLE_UNDERLINED = 0x2
64 };
65
69
73 ConsoleOutput( std::ostream& os );
74
75 virtual ~ConsoleOutput();
76
82
94 bool use_color() const;
95
96 virtual void set_color( ConsoleOutput::Color color );
97
98 virtual void set_style( uint32 style );
99
104 virtual void endl();
105
106 protected:
108 std::ostream& out_;
109
115
116 private:
121 std::string env(const std::string& path) const;
122
126 std::unique_ptr<ConsoleOutput> impl_;
127};
128
129} // namespace nom
130
131#endif // include guard defined
std::ostream & out_
The output stream to use; i.e.: std::cout or std::cerr.
std::string env(const std::string &path) const
Get the value of an environment variable.
@ STYLE_NONE
Resets the text colors.
ConsoleOutput(std::ostream &os)
Construct a console output object with a custom output stream.
std::unique_ptr< ConsoleOutput > impl_
The platform-dependent implementation to use.
virtual void endl()
Reset the colors that have been set.
ConsoleOutput()
Default constructor; initializes the output stream to use std::cerr (the standard error stream).
ConsoleOutput::Color lcolor_
The last color used.
ConsoleOutput::Color color() const
Get the last color that was set.
bool use_color() const
Get the current use state of colored output logging.