Macros
console.h File Reference
#include <corbo-core/text_style.h>
#include <string>
#include <iostream>
Include dependency graph for console.h:

Go to the source code of this file.

Macros

#define corbo_FUNCTION_NAME   __FUNCTION__
 
#define corbo_FUNCTION_NAME_FORMATTED   "[" << corbo_FUNCTION_NAME << "] "
 
#define DEFAULT_COLOR   corbo::TextColorCode::FG_DEFAULT
 
#define ERROR_COLOR   corbo::TextColorCode::FG_LIGHT_RED
 
#define INPUT_STREAM(variable, default_val)   std::cin >> variable
 
#define INPUT_STREAM_DEFAULT(variable, default_val)
 
#define INPUT_STREAM_DEFAULT_MSG(msg, variable, default_val)
 
#define INPUT_STREAM_MSG(msg, variable, default_val)
 
#define PRINT_DEBUG(msg)   std::cout << "Debug: " << msg << std::endl;
 Print msg-stream only if project is compiled in Debug-mode. More...
 
#define PRINT_DEBUG_COND(cond, msg)   if (cond) std::cout << "Debug: " << msg << std::endl;
 Print msg-stream only if cond == true and only if project is compiled in Debug-mode. More...
 
#define PRINT_DEBUG_COND_NAMED(cond, msg)   PRINT_DEBUG_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_DEBUG_COND_ONCE(cond, msg)
 Print msg-stream only if cond == true, only once and only if project is compiled in Debug-mode. More...
 
#define PRINT_DEBUG_COND_ONCE_NAMED(cond, msg)   PRINT_DEBUG_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_DEBUG_NAMED(msg)   PRINT_DEBUG(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_DEBUG_ONCE(msg)
 Print msg-stream only once and only if project is compiled in Debug-mode. More...
 
#define PRINT_DEBUG_ONCE_NAMED(msg)   PRINT_DEBUG_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_DEBUG_WARN(msg)   PRINT_DEBUG(WARNING_COLOR << msg << DEFAULT_COLOR)
 Print message in debug mode with warning-color-code. More...
 
#define PRINT_ERROR(msg)   std::cerr << ERROR_COLOR << "Error: " << msg << DEFAULT_COLOR << std::endl
 Print msg-stream as error msg. More...
 
#define PRINT_ERROR_COND(cond, msg)   if (cond) std::cerr << ERROR_COLOR << "Error: " << msg << DEFAULT_COLOR << std::endl
 Print msg-stream only if cond == true. More...
 
#define PRINT_ERROR_COND_NAMED(cond, msg)   PRINT_ERROR_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_ERROR_COND_ONCE(cond, msg)
 Print msg-stream only if cond == true, only once. More...
 
#define PRINT_ERROR_COND_ONCE_NAMED(cond, msg)   PRINT_ERROR_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_ERROR_NAMED(msg)   PRINT_ERROR(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_ERROR_ONCE(msg)
 Print msg-stream only once. More...
 
#define PRINT_ERROR_ONCE_NAMED(msg)   PRINT_ERROR_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_FATAL(msg)
 Print msg-stream as fatal error msg and exit program execution. More...
 
#define PRINT_FATAL_NAMED(msg)   PRINT_FATAL(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_INFO(msg)   std::cout << "Info: " << msg << std::endl
 Print msg-stream. More...
 
#define PRINT_INFO_COND(cond, msg)   if (cond) std::cout << "Info: " << msg << std::endl
 Print msg-stream only if cond == true. More...
 
#define PRINT_INFO_COND_NAMED(cond, msg)   PRINT_INFO_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_INFO_COND_ONCE(cond, msg)
 Print msg-stream only if cond == true, only once. More...
 
#define PRINT_INFO_COND_ONCE_NAMED(cond, msg)   PRINT_INFO_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_INFO_NAMED(msg)   PRINT_INFO(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_INFO_ONCE(msg)
 Print msg-stream only once. More...
 
#define PRINT_INFO_ONCE_NAMED(msg)   PRINT_INFO_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_WARNING(msg)   std::cout << WARNING_COLOR << "Warning: " << msg << DEFAULT_COLOR << std::endl
 Print msg-stream. More...
 
#define PRINT_WARNING_COND(cond, msg)   if (cond) std::cout << WARNING_COLOR << "Warning: " << msg << DEFAULT_COLOR << std::endl
 Print msg-stream only if cond == true. More...
 
#define PRINT_WARNING_COND_NAMED(cond, msg)   PRINT_WARNING_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_WARNING_COND_ONCE(cond, msg)
 Print msg-stream only if cond == true, only once. More...
 
#define PRINT_WARNING_COND_ONCE_NAMED(cond, msg)   PRINT_WARNING_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_WARNING_NAMED(msg)   PRINT_WARNING(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define PRINT_WARNING_ONCE(msg)
 Print msg-stream only once. More...
 
#define PRINT_WARNING_ONCE_NAMED(msg)   PRINT_WARNING_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)
 
#define WARNING_COLOR   corbo::TextColorCode::FG_LIGHT_YELLOW
 

Macro Definition Documentation

◆ corbo_FUNCTION_NAME

#define corbo_FUNCTION_NAME   __FUNCTION__

Definition at line 44 of file console.h.

◆ corbo_FUNCTION_NAME_FORMATTED

#define corbo_FUNCTION_NAME_FORMATTED   "[" << corbo_FUNCTION_NAME << "] "

Definition at line 47 of file console.h.

◆ DEFAULT_COLOR

#define DEFAULT_COLOR   corbo::TextColorCode::FG_DEFAULT

Definition at line 35 of file console.h.

◆ ERROR_COLOR

#define ERROR_COLOR   corbo::TextColorCode::FG_LIGHT_RED

Definition at line 34 of file console.h.

◆ INPUT_STREAM

#define INPUT_STREAM (   variable,
  default_val 
)    std::cin >> variable

Definition at line 209 of file console.h.

◆ INPUT_STREAM_DEFAULT

#define INPUT_STREAM_DEFAULT (   variable,
  default_val 
)
Value:
{ \
std::cout << "[" << default_val << "] "; \
std::string name; \
std::getline(std::cin, name); \
if (name.empty()) \
variable = default_val; \
else \
{ \
try \
{ \
variable = static_cast<decltype(variable)>(std::stod(name)); \
} \
catch (const std::invalid_argument& ia) \
{ \
std::cerr << "Invalid argument (no number found). Using default..." << std::endl; \
variable = default_val; \
} \
} \
}

Definition at line 216 of file console.h.

◆ INPUT_STREAM_DEFAULT_MSG

#define INPUT_STREAM_DEFAULT_MSG (   msg,
  variable,
  default_val 
)
Value:
std::cout << "Interaction: " << msg << ". "; \
INPUT_STREAM_DEFAULT(variable, default_val)

Definition at line 238 of file console.h.

◆ INPUT_STREAM_MSG

#define INPUT_STREAM_MSG (   msg,
  variable,
  default_val 
)
Value:
std::cout << "Interaction: " << msg << ". "; \
std::cin >> variable

Definition at line 211 of file console.h.

◆ PRINT_DEBUG

#define PRINT_DEBUG (   msg)    std::cout << "Debug: " << msg << std::endl;

Print msg-stream only if project is compiled in Debug-mode.

Definition at line 60 of file console.h.

◆ PRINT_DEBUG_COND

#define PRINT_DEBUG_COND (   cond,
  msg 
)    if (cond) std::cout << "Debug: " << msg << std::endl;

Print msg-stream only if cond == true and only if project is compiled in Debug-mode.

Definition at line 73 of file console.h.

◆ PRINT_DEBUG_COND_NAMED

#define PRINT_DEBUG_COND_NAMED (   cond,
  msg 
)    PRINT_DEBUG_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 247 of file console.h.

◆ PRINT_DEBUG_COND_ONCE

#define PRINT_DEBUG_COND_ONCE (   cond,
  msg 
)
Value:
{ \
static const auto debugOnce = [&] { \
if (cond) std::cout << "Debug: " << msg << std::endl; \
return true; \
}(); \
(void)debugOnce; \
}

Print msg-stream only if cond == true, only once and only if project is compiled in Debug-mode.

Definition at line 77 of file console.h.

◆ PRINT_DEBUG_COND_ONCE_NAMED

#define PRINT_DEBUG_COND_ONCE_NAMED (   cond,
  msg 
)    PRINT_DEBUG_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 248 of file console.h.

◆ PRINT_DEBUG_NAMED

#define PRINT_DEBUG_NAMED (   msg)    PRINT_DEBUG(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 245 of file console.h.

◆ PRINT_DEBUG_ONCE

#define PRINT_DEBUG_ONCE (   msg)
Value:
{ \
static const auto debugOnce = [&] { \
std::cout << "Debug: " << msg << std::endl; \
return true; \
}(); \
(void)debugOnce; \
}

Print msg-stream only once and only if project is compiled in Debug-mode.

Definition at line 63 of file console.h.

◆ PRINT_DEBUG_ONCE_NAMED

#define PRINT_DEBUG_ONCE_NAMED (   msg)    PRINT_DEBUG_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 246 of file console.h.

◆ PRINT_DEBUG_WARN

#define PRINT_DEBUG_WARN (   msg)    PRINT_DEBUG(WARNING_COLOR << msg << DEFAULT_COLOR)

Print message in debug mode with warning-color-code.

Definition at line 207 of file console.h.

◆ PRINT_ERROR

#define PRINT_ERROR (   msg)    std::cerr << ERROR_COLOR << "Error: " << msg << DEFAULT_COLOR << std::endl

Print msg-stream as error msg.

Definition at line 173 of file console.h.

◆ PRINT_ERROR_COND

#define PRINT_ERROR_COND (   cond,
  msg 
)    if (cond) std::cerr << ERROR_COLOR << "Error: " << msg << DEFAULT_COLOR << std::endl

Print msg-stream only if cond == true.

Definition at line 186 of file console.h.

◆ PRINT_ERROR_COND_NAMED

#define PRINT_ERROR_COND_NAMED (   cond,
  msg 
)    PRINT_ERROR_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 262 of file console.h.

◆ PRINT_ERROR_COND_ONCE

#define PRINT_ERROR_COND_ONCE (   cond,
  msg 
)
Value:
{ \
static const auto errorOnce = [&] { \
if (cond) std::cerr << ERROR_COLOR << "Error: " << msg << DEFAULT_COLOR << std::endl; \
return true; \
}(); \
(void)errorOnce; \
}

Print msg-stream only if cond == true, only once.

Definition at line 190 of file console.h.

◆ PRINT_ERROR_COND_ONCE_NAMED

#define PRINT_ERROR_COND_ONCE_NAMED (   cond,
  msg 
)    PRINT_ERROR_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 263 of file console.h.

◆ PRINT_ERROR_NAMED

#define PRINT_ERROR_NAMED (   msg)    PRINT_ERROR(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 260 of file console.h.

◆ PRINT_ERROR_ONCE

#define PRINT_ERROR_ONCE (   msg)
Value:
{ \
static const auto infoOnce = [&] { \
std::cerr << ERROR_COLOR << "Error: " << msg << DEFAULT_COLOR << std::endl; \
return true; \
}(); \
(void)infoOnce; \
}

Print msg-stream only once.

Definition at line 176 of file console.h.

◆ PRINT_ERROR_ONCE_NAMED

#define PRINT_ERROR_ONCE_NAMED (   msg)    PRINT_ERROR_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 261 of file console.h.

◆ PRINT_FATAL

#define PRINT_FATAL (   msg)
Value:
{ \
std::cerr << ERROR_COLOR << "Fatal error: " << msg << " Stopping program execution." << DEFAULT_COLOR << std::endl; \
exit(1); \
}

Print msg-stream as fatal error msg and exit program execution.

Definition at line 200 of file console.h.

◆ PRINT_FATAL_NAMED

#define PRINT_FATAL_NAMED (   msg)    PRINT_FATAL(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 265 of file console.h.

◆ PRINT_INFO

#define PRINT_INFO (   msg)    std::cout << "Info: " << msg << std::endl

Print msg-stream.

Definition at line 117 of file console.h.

◆ PRINT_INFO_COND

#define PRINT_INFO_COND (   cond,
  msg 
)    if (cond) std::cout << "Info: " << msg << std::endl

Print msg-stream only if cond == true.

Definition at line 131 of file console.h.

◆ PRINT_INFO_COND_NAMED

#define PRINT_INFO_COND_NAMED (   cond,
  msg 
)    PRINT_INFO_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 252 of file console.h.

◆ PRINT_INFO_COND_ONCE

#define PRINT_INFO_COND_ONCE (   cond,
  msg 
)
Value:
{ \
static const auto infoOnce = [&] { \
if (cond) std::cout << "Info: " << msg << std::endl; \
return true; \
}(); \
(void)infoOnce; \
}

Print msg-stream only if cond == true, only once.

Definition at line 135 of file console.h.

◆ PRINT_INFO_COND_ONCE_NAMED

#define PRINT_INFO_COND_ONCE_NAMED (   cond,
  msg 
)    PRINT_INFO_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 253 of file console.h.

◆ PRINT_INFO_NAMED

#define PRINT_INFO_NAMED (   msg)    PRINT_INFO(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 250 of file console.h.

◆ PRINT_INFO_ONCE

#define PRINT_INFO_ONCE (   msg)
Value:
{ \
static const auto infoOnce = [&] { \
std::cout << "Info: " << msg << std::endl; \
return true; \
}(); \
(void)infoOnce; \
}

Print msg-stream only once.

Definition at line 121 of file console.h.

◆ PRINT_INFO_ONCE_NAMED

#define PRINT_INFO_ONCE_NAMED (   msg)    PRINT_INFO_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 251 of file console.h.

◆ PRINT_WARNING

#define PRINT_WARNING (   msg)    std::cout << WARNING_COLOR << "Warning: " << msg << DEFAULT_COLOR << std::endl

Print msg-stream.

Definition at line 145 of file console.h.

◆ PRINT_WARNING_COND

#define PRINT_WARNING_COND (   cond,
  msg 
)    if (cond) std::cout << WARNING_COLOR << "Warning: " << msg << DEFAULT_COLOR << std::endl

Print msg-stream only if cond == true.

Definition at line 159 of file console.h.

◆ PRINT_WARNING_COND_NAMED

#define PRINT_WARNING_COND_NAMED (   cond,
  msg 
)    PRINT_WARNING_COND(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 257 of file console.h.

◆ PRINT_WARNING_COND_ONCE

#define PRINT_WARNING_COND_ONCE (   cond,
  msg 
)
Value:
{ \
static const auto warningOnce = [&] { \
if (cond) std::cout << WARNING_COLOR << "Warning: " << msg << DEFAULT_COLOR << std::endl; \
return true; \
}(); \
(void)warningOnce; \
}

Print msg-stream only if cond == true, only once.

Definition at line 163 of file console.h.

◆ PRINT_WARNING_COND_ONCE_NAMED

#define PRINT_WARNING_COND_ONCE_NAMED (   cond,
  msg 
)    PRINT_WARNING_COND_ONCE(cond, corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 258 of file console.h.

◆ PRINT_WARNING_NAMED

#define PRINT_WARNING_NAMED (   msg)    PRINT_WARNING(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 255 of file console.h.

◆ PRINT_WARNING_ONCE

#define PRINT_WARNING_ONCE (   msg)
Value:
{ \
static const auto infoOnce = [&] { \
std::cout << WARNING_COLOR << "Warning: " << msg << DEFAULT_COLOR << std::endl; \
return true; \
}(); \
(void)infoOnce; \
}

Print msg-stream only once.

Definition at line 149 of file console.h.

◆ PRINT_WARNING_ONCE_NAMED

#define PRINT_WARNING_ONCE_NAMED (   msg)    PRINT_WARNING_ONCE(corbo_FUNCTION_NAME_FORMATTED << msg)

Definition at line 256 of file console.h.

◆ WARNING_COLOR

#define WARNING_COLOR   corbo::TextColorCode::FG_LIGHT_YELLOW

Definition at line 33 of file console.h.

ERROR_COLOR
#define ERROR_COLOR
Definition: console.h:34
DEFAULT_COLOR
#define DEFAULT_COLOR
Definition: console.h:35
WARNING_COLOR
#define WARNING_COLOR
Definition: console.h:33


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:07:16