ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/CommonLibs/plog/Record.h
(Generate patch)

Comparing s10k/CommonLibs/plog/Record.h (file contents):
Revision 1073 by s10k, Thu Oct 5 17:48:32 2017 UTC vs.
Revision 1096 by s10k, Sat Dec 30 14:40:33 2017 UTC

# Line 1 | Line 1
1 < #pragma once
2 < #include <plog/Severity.h>
3 < #include <plog/Util.h>
4 <
5 < namespace plog
6 < {
7 <    namespace detail
8 <    {
9 <        //////////////////////////////////////////////////////////////////////////
10 <        // Stream output operators as free functions
11 <
12 <        inline void operator<<(util::nstringstream& stream, const char* data)
13 <        {
14 <            data = data ? data : "(null)";
15 <
16 < #if defined(_WIN32) && defined(__BORLANDC__)
17 <            stream << util::toWide(data);
18 < #elif defined(_WIN32)
19 <            std::operator<<(stream, util::toWide(data));
20 < #else
21 <            std::operator<<(stream, data);
22 < #endif
23 <        }
24 <
25 <        inline void operator<<(util::nstringstream& stream, const std::string& data)
26 <        {
27 <            plog::detail::operator<<(stream, data.c_str());
28 <        }
29 <
30 < #if PLOG_ENABLE_WCHAR_INPUT
31 <        inline void operator<<(util::nstringstream& stream, const wchar_t* data)
32 <        {
33 <            data = data ? data : L"(null)";
34 <
35 < #ifdef _WIN32
36 <            std::operator<<(stream, data);
37 < #else
38 <            std::operator<<(stream, util::toNarrow(data));
39 < #endif
40 <        }
41 <
42 <        inline void operator<<(util::nstringstream& stream, const std::wstring& data)
43 <        {
44 <            plog::detail::operator<<(stream, data.c_str());
45 <        }
46 < #endif
47 <    }
48 <
49 <    class Record
50 <    {
51 <    public:
52 <        Record(Severity severity, const char* func, size_t line, const char* file, const void* object)
53 <            : m_severity(severity), m_tid(util::gettid()), m_object(object), m_line(line), m_func(func), m_file(file)
54 <        {
55 <            util::ftime(&m_time);
56 <        }
57 <
58 <        //////////////////////////////////////////////////////////////////////////
59 <        // Stream output operators
60 <
61 <        Record& operator<<(char data)
62 <        {
63 <            char str[] = { data, 0 };
64 <            return *this << str;
65 <        }
66 <
67 < #if PLOG_ENABLE_WCHAR_INPUT
68 <        Record& operator<<(wchar_t data)
69 <        {
70 <            wchar_t str[] = { data, 0 };
71 <            return *this << str;
72 <        }
73 < #endif
74 <
75 < #ifdef _WIN32
76 <        Record& operator<<(std::wostream& (*data)(std::wostream&))
77 < #else
78 <        Record& operator<<(std::ostream& (*data)(std::ostream&))
79 < #endif
80 <        {
81 <            m_message << data;
82 <            return *this;
83 <        }
84 <
85 < #ifdef QT_VERSION
86 <        Record& operator<<(const QString& data)
87 <        {
88 < #ifdef _WIN32
89 <            return *this << data.toStdWString();
90 < #else
91 <            return *this << data.toStdString();
92 < #endif
93 <        }
94 < #endif
95 <
96 <        template<typename T>
97 <        Record& operator<<(const T& data)
98 <        {
99 <            using namespace plog::detail;
100 <
101 <            m_message << data;
102 <            return *this;
103 <        }
104 <
105 <        //////////////////////////////////////////////////////////////////////////
106 <        // Getters
107 <
108 <        virtual const util::Time& getTime() const
109 <        {
110 <            return m_time;
111 <        }
112 <
113 <        virtual Severity getSeverity() const
114 <        {
115 <            return m_severity;
116 <        }
117 <
118 <        virtual unsigned int getTid() const
119 <        {
120 <            return m_tid;
121 <        }
122 <
123 <        virtual const void* getObject() const
124 <        {
125 <            return m_object;
126 <        }
127 <
128 <        virtual size_t getLine() const
129 <        {
130 <            return m_line;
131 <        }
132 <
133 <        virtual const util::nchar* getMessage() const
134 <        {
135 <            m_messageStr = m_message.str();
136 <            return m_messageStr.c_str();
137 <        }
138 <
139 <        virtual const char* getFunc() const
140 <        {
141 <            m_funcStr = util::processFuncName(m_func);
142 <            return m_funcStr.c_str();
143 <        }
144 <
145 <        virtual const char* getFile() const
146 <        {
147 <            return m_file;
148 <        }
149 <
150 <    private:
151 <        util::Time              m_time;
152 <        const Severity          m_severity;
153 <        const unsigned int      m_tid;
154 <        const void* const       m_object;
155 <        const size_t            m_line;
156 <        util::nstringstream     m_message;
157 <        const char* const       m_func;
158 <        const char* const       m_file;
159 <        mutable std::string     m_funcStr;
160 <        mutable util::nstring   m_messageStr;
161 <    };
162 < }
1 > #pragma once
2 > #include <plog/Severity.h>
3 > #include <plog/Util.h>
4 >
5 > namespace plog
6 > {
7 >    namespace detail
8 >    {
9 >        //////////////////////////////////////////////////////////////////////////
10 >        // Stream output operators as free functions
11 >
12 >        inline void operator<<(util::nstringstream& stream, const char* data)
13 >        {
14 >            data = data ? data : "(null)";
15 >
16 > #if defined(_WIN32) && defined(__BORLANDC__)
17 >            stream << util::toWide(data);
18 > #elif defined(_WIN32)
19 >            std::operator<<(stream, util::toWide(data));
20 > #else
21 >            std::operator<<(stream, data);
22 > #endif
23 >        }
24 >
25 >        inline void operator<<(util::nstringstream& stream, const std::string& data)
26 >        {
27 >            plog::detail::operator<<(stream, data.c_str());
28 >        }
29 >
30 > #if PLOG_ENABLE_WCHAR_INPUT
31 >        inline void operator<<(util::nstringstream& stream, const wchar_t* data)
32 >        {
33 >            data = data ? data : L"(null)";
34 >
35 > #ifdef _WIN32
36 >            std::operator<<(stream, data);
37 > #else
38 >            std::operator<<(stream, util::toNarrow(data));
39 > #endif
40 >        }
41 >
42 >        inline void operator<<(util::nstringstream& stream, const std::wstring& data)
43 >        {
44 >            plog::detail::operator<<(stream, data.c_str());
45 >        }
46 > #endif
47 >    }
48 >
49 >    class Record
50 >    {
51 >    public:
52 >        Record(Severity severity, const char* func, size_t line, const char* file, const void* object)
53 >            : m_severity(severity), m_tid(util::gettid()), m_object(object), m_line(line), m_func(func), m_file(file)
54 >        {
55 >            util::ftime(&m_time);
56 >        }
57 >
58 >        //////////////////////////////////////////////////////////////////////////
59 >        // Stream output operators
60 >
61 >        Record& operator<<(char data)
62 >        {
63 >            char str[] = { data, 0 };
64 >            return *this << str;
65 >        }
66 >
67 > #if PLOG_ENABLE_WCHAR_INPUT
68 >        Record& operator<<(wchar_t data)
69 >        {
70 >            wchar_t str[] = { data, 0 };
71 >            return *this << str;
72 >        }
73 > #endif
74 >
75 > #ifdef _WIN32
76 >        Record& operator<<(std::wostream& (*data)(std::wostream&))
77 > #else
78 >        Record& operator<<(std::ostream& (*data)(std::ostream&))
79 > #endif
80 >        {
81 >            m_message << data;
82 >            return *this;
83 >        }
84 >
85 > #ifdef QT_VERSION
86 >        Record& operator<<(const QString& data)
87 >        {
88 > #ifdef _WIN32
89 >            return *this << data.toStdWString();
90 > #else
91 >            return *this << data.toStdString();
92 > #endif
93 >        }
94 > #endif
95 >
96 >        template<typename T>
97 >        Record& operator<<(const T& data)
98 >        {
99 >            using namespace plog::detail;
100 >
101 >            m_message << data;
102 >            return *this;
103 >        }
104 >
105 >        //////////////////////////////////////////////////////////////////////////
106 >        // Getters
107 >
108 >        virtual const util::Time& getTime() const
109 >        {
110 >            return m_time;
111 >        }
112 >
113 >        virtual Severity getSeverity() const
114 >        {
115 >            return m_severity;
116 >        }
117 >
118 >        virtual unsigned int getTid() const
119 >        {
120 >            return m_tid;
121 >        }
122 >
123 >        virtual const void* getObject() const
124 >        {
125 >            return m_object;
126 >        }
127 >
128 >        virtual size_t getLine() const
129 >        {
130 >            return m_line;
131 >        }
132 >
133 >        virtual const util::nchar* getMessage() const
134 >        {
135 >            m_messageStr = m_message.str();
136 >            return m_messageStr.c_str();
137 >        }
138 >
139 >        virtual const char* getFunc() const
140 >        {
141 >            m_funcStr = util::processFuncName(m_func);
142 >            return m_funcStr.c_str();
143 >        }
144 >
145 >        virtual const char* getFile() const
146 >        {
147 >            return m_file;
148 >        }
149 >
150 >    private:
151 >        util::Time              m_time;
152 >        const Severity          m_severity;
153 >        const unsigned int      m_tid;
154 >        const void* const       m_object;
155 >        const size_t            m_line;
156 >        util::nstringstream     m_message;
157 >        const char* const       m_func;
158 >        const char* const       m_file;
159 >        mutable std::string     m_funcStr;
160 >        mutable util::nstring   m_messageStr;
161 >    };
162 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)