128 template <comppare::
internal::concepts::Streamable T>
152 std::ios saved(
nullptr);
156 std::ostringstream tmp;
159 std::string body = std::move(tmp).str();
241#define ANSI_DEFINE(NAME, ON, OFF) \
243 inline constexpr const char *NAME##_ON_CODE = "\033[" ON "m"; \
244 inline constexpr const char *NAME##_OFF_CODE = "\033[" OFF "m"; \
250 friend std::ostream &operator<<(std::ostream &os, NAME##_ON_t) \
253 std::ios saved(nullptr); \
256 os << NAME##_ON_CODE; \
262 template <comppare::internal::concepts::Streamable T> \
263 auto operator()(T &&v) const \
265 return ScopedAnsiWrapper<std::decay_t<T>>(NAME##_ON_CODE, NAME##_OFF_CODE, std::forward<T>(v)); \
269 inline constexpr NAME##_ON_t NAME{}; \
274 friend std::ostream &operator<<(std::ostream &os, NAME##_OFF_t) \
277 std::ios saved(nullptr); \
280 os << NAME##_OFF_CODE; \
286 inline constexpr NAME##_OFF_t NAME##_OFF{};
#define ANSI_DEFINE(NAME, ON, OFF)
Macro to define ANSI escape codes for text styling and colors.
Definition ansi.hpp:241
Applying ANSI styles/colors to a value in a scope.
Definition ansi.hpp:130
const char * on_
ANSI "on" code.
Definition ansi.hpp:132
ScopedAnsiWrapper(const char *on, const char *off, T v)
Definition ansi.hpp:139
T val_
The value to be wrapped.
Definition ansi.hpp:136
const char * off_
ANSI "off" code.
Definition ansi.hpp:134
friend std::ostream & operator<<(std::ostream &os, ScopedAnsiWrapper const &w)
Overloaded operator<< to stream the value with ANSI codes.
Definition ansi.hpp:149
This file contains commonly used concepts internally within the ComPPare library.
Utilities for applying ANSI styles and colors to console output.