xref: /aosp_15_r20/external/gmmlib/Source/GmmLib/Utility/GmmLog/spdlog/formatter.h (revision 35ffd701415c9e32e53136d61a677a8d0a8fc4a5)
1 //
2 // Copyright(c) 2015 Gabi Melman.
3 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
4 //
5 
6 #pragma once
7 
8 #include <spdlog/details/log_msg.h>
9 
10 #include <vector>
11 #include <string>
12 #include <memory>
13 
14 namespace spdlog
15 {
16 namespace details
17 {
18 class flag_formatter;
19 }
20 
21 class formatter
22 {
23 public:
~formatter()24     virtual ~formatter() {}
25     virtual void format(details::log_msg& msg) = 0;
26 };
27 
28 class pattern_formatter : public formatter
29 {
30 
31 public:
32     explicit pattern_formatter(const std::string& pattern);
33     pattern_formatter(const pattern_formatter&) = delete;
34     pattern_formatter& operator=(const pattern_formatter&) = delete;
35     void format(details::log_msg& msg) override;
36 private:
37     const std::string _pattern;
38     std::vector<std::unique_ptr<details::flag_formatter>> _formatters;
39     void handle_flag(char flag);
40     void compile_pattern(const std::string& pattern);
41 };
42 }
43 
44 #include <spdlog/details/pattern_formatter_impl.h>
45 
46