ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos_colored_text.h
Go to the documentation of this file.
1 
12 #ifndef ARGOS_COLORED_TEXT_H
13 #define ARGOS_COLORED_TEXT_H
14 
15 #include <argos3/core/utility/datatypes/datatypes.h>
16 
17 namespace argos {
18 
30  };
31 
44  };
45 
49  struct SLogColor {
58 
69  EARGoSLogColors e_foreground_color) :
70  Attribute(e_attribute),
71  Foreground(e_foreground_color) {}
72  };
73 
78  inline std::ostream& operator<<(std::ostream& c_os, const SLogColor& s_log_color)
79  {
80  c_os << "\033["
81  << s_log_color.Attribute << ";"
82  << (s_log_color.Foreground + 30) << "m";
83  return c_os;
84  }
85 
89 #define DEFINE_ARGOS_STREAM_COLOR_HELPER(lc_color, uc_color) \
90  inline std::ostream& lc_color(std::ostream& c_os) { \
91  c_os << SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_ ## uc_color); \
92  return c_os; \
93  }
94 
102  DEFINE_ARGOS_STREAM_COLOR_HELPER(green, GREEN);
106  DEFINE_ARGOS_STREAM_COLOR_HELPER(yellow, YELLOW);
114  DEFINE_ARGOS_STREAM_COLOR_HELPER(magenta, MAGENTA);
122  DEFINE_ARGOS_STREAM_COLOR_HELPER(white, WHITE);
123 
128  inline std::ostream& reset(std::ostream& c_os) {
129  c_os << "\033["
131  << "m";
132  return c_os;
133  }
134 
135 }
136 
137 #endif
argos::ARGOS_LOG_COLOR_BLACK
@ ARGOS_LOG_COLOR_BLACK
Definition: argos_colored_text.h:36
argos::ARGOS_LOG_ATTRIBUTE_HIDDEN
@ ARGOS_LOG_ATTRIBUTE_HIDDEN
Definition: argos_colored_text.h:29
argos::reset
std::ostream & reset(std::ostream &c_os)
Resets the text to the default settings.
Definition: argos_colored_text.h:128
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::ARGOS_LOG_ATTRIBUTE_UNDERSCORE
@ ARGOS_LOG_ATTRIBUTE_UNDERSCORE
Definition: argos_colored_text.h:26
argos::ARGOS_LOG_ATTRIBUTE_RESET
@ ARGOS_LOG_ATTRIBUTE_RESET
Definition: argos_colored_text.h:23
argos::SLogColor::SLogColor
SLogColor(EARGoSLogAttributes e_attribute, EARGoSLogColors e_foreground_color)
Constructor with custom settings.
Definition: argos_colored_text.h:68
argos::SLogColor
Stream modifier to set attribute and color of the subsequent text.
Definition: argos_colored_text.h:49
argos::SLogColor::Foreground
UInt8 Foreground
The foreground color.
Definition: argos_colored_text.h:57
argos::ARGOS_LOG_ATTRIBUTE_BLINK
@ ARGOS_LOG_ATTRIBUTE_BLINK
Definition: argos_colored_text.h:27
argos::ARGOS_LOG_COLOR_GREEN
@ ARGOS_LOG_COLOR_GREEN
Definition: argos_colored_text.h:38
argos::EARGoSLogColors
EARGoSLogColors
The possible colors of the logged text.
Definition: argos_colored_text.h:35
argos::ARGOS_LOG_COLOR_RED
@ ARGOS_LOG_COLOR_RED
Definition: argos_colored_text.h:37
argos::ARGOS_LOG_COLOR_CYAN
@ ARGOS_LOG_COLOR_CYAN
Definition: argos_colored_text.h:42
argos::ARGOS_LOG_ATTRIBUTE_DIM
@ ARGOS_LOG_ATTRIBUTE_DIM
Definition: argos_colored_text.h:25
argos::operator<<
std::ostream & operator<<(std::ostream &c_os, const CByteArray &c_byte_array)
Definition: byte_array.cpp:530
argos::EARGoSLogAttributes
EARGoSLogAttributes
The possible attributes of the logged text.
Definition: argos_colored_text.h:22
argos::DEFINE_ARGOS_STREAM_COLOR_HELPER
DEFINE_ARGOS_STREAM_COLOR_HELPER(red, RED)
Bright red text modifier.
UInt8
unsigned char UInt8
8-bit unsigned integer.
Definition: datatypes.h:60
argos::ARGOS_LOG_COLOR_MAGENTA
@ ARGOS_LOG_COLOR_MAGENTA
Definition: argos_colored_text.h:41
argos::ARGOS_LOG_COLOR_WHITE
@ ARGOS_LOG_COLOR_WHITE
Definition: argos_colored_text.h:43
argos::SLogColor::Attribute
UInt8 Attribute
The text attribute.
Definition: argos_colored_text.h:53
argos::SLogColor::SLogColor
SLogColor()
Constructor with standard settings.
Definition: argos_colored_text.h:62
argos::ARGOS_LOG_ATTRIBUTE_REVERSE
@ ARGOS_LOG_ATTRIBUTE_REVERSE
Definition: argos_colored_text.h:28
argos::ARGOS_LOG_COLOR_YELLOW
@ ARGOS_LOG_COLOR_YELLOW
Definition: argos_colored_text.h:39
argos::ARGOS_LOG_COLOR_BLUE
@ ARGOS_LOG_COLOR_BLUE
Definition: argos_colored_text.h:40
argos::ARGOS_LOG_ATTRIBUTE_BRIGHT
@ ARGOS_LOG_ATTRIBUTE_BRIGHT
Definition: argos_colored_text.h:24