diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-05 15:49:59 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-05 15:49:59 +0100 |
commit | a47b981c2254e1d49f58ebd4244c1be4624ba998 (patch) | |
tree | d5ca1f37f0e2d93f241721b13abacc5123bfe92a /src/crepe/util/LogColor.h | |
parent | 5f75bdbf3d38c94baeae52f4c4889f147ec6885e (diff) |
remove util and api namespaces
Diffstat (limited to 'src/crepe/util/LogColor.h')
-rw-r--r-- | src/crepe/util/LogColor.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/crepe/util/LogColor.h b/src/crepe/util/LogColor.h new file mode 100644 index 0000000..7e60ba2 --- /dev/null +++ b/src/crepe/util/LogColor.h @@ -0,0 +1,51 @@ +#pragma once + +#include <string> + +namespace crepe { + +class LogColor { +public: + LogColor() = default; + +public: + //! get color code as c-style string (or color content string) + const char * c_str(const char * content = NULL); + //! color printf-style format string + const char * fmt(const char * fmt, ...); + //! get color code as stl string (or color content string) + const std::string str(const std::string & content = ""); + +public: + //! reset color to default foreground and background color + LogColor & reset(); + +public: + LogColor & fg_black(bool bright = false); + LogColor & fg_red(bool bright = false); + LogColor & fg_green(bool bright = false); + LogColor & fg_yellow(bool bright = false); + LogColor & fg_blue(bool bright = false); + LogColor & fg_magenta(bool bright = false); + LogColor & fg_cyan(bool bright = false); + LogColor & fg_white(bool bright = false); + +public: + LogColor & bg_black(bool bright = false); + LogColor & bg_red(bool bright = false); + LogColor & bg_green(bool bright = false); + LogColor & bg_yellow(bool bright = false); + LogColor & bg_blue(bool bright = false); + LogColor & bg_magenta(bool bright = false); + LogColor & bg_cyan(bool bright = false); + LogColor & bg_white(bool bright = false); + +private: + LogColor & add_code(unsigned int code); + +private: + std::string code = ""; + std::string final = ""; +}; + +} // namespace crepe::util |