10#ifndef COMMON_COMPLEX_PRINTER_HPP
11#define COMMON_COMPLEX_PRINTER_HPP
34 std::string param_name_output_color;
35 std::string param_name_output_color_cache;
37 std::vector<std::string> param_names;
38 int current_param_index;
46 template <
typename...
ARGS>
52 std::string GetPrintPrefix(
bool is_last_arg)
override;
103 for (
size_t i = 0;
i <
len; ++
i)
112 size_t first =
token.find_first_not_of(
" \t\n\r");
113 size_t last =
token.find_last_not_of(
" \t\n\r");
115 if (
first == std::string::npos)
116 param_names.emplace_back(
"<" +
token +
">");
121 current_param_index = 0;
155template <
typename...
ARGS>
175 this->param_name_output_color = param_name_output_color;
193inline std::string ComplexPrinter::GetPrintPrefix(
bool is_last_arg) {
194 Cm_Assert(current_param_index >= 0 && param_names.size() > current_param_index,
"Parameter name list string data error!!!");
198 param_name_output_color_cache = param_name_output_color;
199 param_name_output_color =
"";
205 prefix += param_name_output_color;
206 prefix += param_names[current_param_index++];
212 current_param_index = -1;
216 param_name_output_color = param_name_output_color_cache;
219 return std::move(prefix);
static std::string RESET
结束符,重置所有颜色设置
static std::string BLUE
蓝色
static std::string FONT_BOLD
加粗
static std::string GREEN
绿色
~ComplexPrinter()
复杂打印器类的析构函数
std::ostream & operator()(const std::string ¶m_names_str, ARGS... args)
复杂打印器参数打印
ComplexPrinter & SetParamNameOutputColor(const std::string ¶m_name_output_color)
设置默认输出内容的颜色
ComplexPrinter & ParseParamNames(std::string param_names_str)
复杂打印器参数名列表解析
ComplexPrinter(const std::string &default_split_string="\n", const std::string &output_color=Color::BLUE, const std::string ¶m_name_output_color=Color::GREEN+Color::FONT_BOLD)
复杂打印器类的带参构造函数
Printer & Print(T arg)
实现单个参数的打印
#define Cm_Assert(expr, message)
断言宏