modm API documentation
std_colour.hpp
1 /*
2  * Copyright (c) 2009, Martin Rosekeit
3  * Copyright (c) 2010, Fabian Greif
4  * Copyright (c) 2012, Niklas Hauser
5  *
6  * This file is part of the modm project.
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11  */
12 // ----------------------------------------------------------------------------
13 
14 #ifndef MODM_LOG_STD_COLOUR_HPP
15 #define MODM_LOG_STD_COLOUR_HPP
16 
17 #include "../style.hpp"
18 
19 namespace modm
20 {
21  namespace log
22  {
23  enum Colour
24  {
25  BLACK,
26  RED,
27  GREEN,
28  YELLOW,
29  BLUE,
30  MAGENTA,
31  TURQUOISE,
32  WHITE,
33  NONE
34  };
35 
36  /**
37  * \class StdColour
38  * \brief This style colours the given stream in the color given by the
39  * template argument.
40  *
41  * \see http://mathias-kettner.de/lw_farbige_ausgabe_auf_der_konsole.html
42  *
43  * \ingroup modm_debug
44  * \author Martin Rosekeit <martin.rosekeit@rwth-aachen.de>
45  */
46  template <Colour TEXT, Colour BACKGROUND, typename STYLE = DefaultStyle >
47  class StdColour : public Style<STYLE>
48  {
49  public:
50  StdColour(STYLE style);
51 
52  StdColour(IODevice &device);
53 
54  inline void
55  parseArg( int argc, char * argv);
56 
57  ~StdColour();
58 
59  /// Write one char to the sink.
60  void
61  write( char c );
62 
63  /// Write a string that terminates with \c '\\0' to the sink.
64  void
65  write( const char* s );
66 
67  /// The message is complete and can be written/send/displayed.
68  void
69  flush();
70 
71  private:
72  inline const char*
73  getTextColour();
74 
75  inline const char*
76  getBackgroundColour();
77  };
78  }
79 }
80 
81 #include "std_colour_impl.hpp"
82 
83 #endif // MODM_LOG_STD_COLOUR_HPP
void flush()
The message is complete and can be written/send/displayed.
void write(char c)
Write one char to the sink.
Definition: modm/src/modm/io/iodevice.hpp:26
This is the interface to all style-classes of the logger.
Definition: style.hpp:78
This style colours the given stream in the color given by the template argument.
Definition: std_colour.hpp:47