C++ Utilities  4.11.0
Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
ansiescapecodes.cpp
Go to the documentation of this file.
1 #include "./ansiescapecodes.h"
2 
6 namespace EscapeCodes {
7 
20 bool enabled =
21 #ifdef CPP_UTILITIES_ESCAPE_CODES_ENABLED_BY_DEFAULT
22  true
23 #else
24  false
25 #endif
26  ;
27 
31 std::ostream &operator<<(std::ostream &stream, Phrases phrase)
32 {
33  switch (phrase) {
34  case Phrases::Error:
36  stream << "Error: ";
39  break;
40  case Phrases::Warning:
42  stream << "Warning: ";
45  break;
46  case Phrases::End:
48  stream << '\n';
49  break;
51  stream << " ";
54  break;
57  stream << "==> ";
60  break;
63  stream << " -> ";
66  break;
69  stream << "==> ERROR: ";
72  break;
75  stream << "==> WARNING: ";
78  break;
79  case Phrases::EndFlush:
81  stream << std::endl;
82  break;
83  }
84  return stream;
85 }
86 
87 } // namespace EscapeCodes
Encapsulates functions for formatted terminal output using ANSI escape codes.
Phrases
The Phrases enum contains standard phrases which can be printed to any std::ostream.
void setStyle(std::ostream &stream, TextAttribute displayAttribute=TextAttribute::Reset)
CPP_UTILITIES_EXPORT bool enabled
Controls whether the functions inside the EscapeCodes namespace actually make use of escape codes...
std::ostream & operator<<(std::ostream &stream, TextAttribute displayAttribute)