MyGUI 3.2.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_LogLevel.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_LOG_LEVEL_H_
8 #define MYGUI_LOG_LEVEL_H_
9
10 #include "MyGUI_Prerequest.h"
11
12 namespace MyGUI
13 {
14
15 struct MYGUI_EXPORT LogLevel
16 {
17 enum Enum
18 {
19 Info, // Информационное сообщение.
20 Warning, // Несущественная проблема.
21 Error, // Устранимая ошибка.
22 Critical, // Неустранимая ошибка или сбой в работе приложения.
23 MAX
24 };
25
26 LogLevel() :
27 mValue(Info)
28 {
29 }
30
31 LogLevel(Enum _value) :
32 mValue(_value)
33 {
34 }
35
36 static LogLevel parse(const std::string& _value)
37 {
38 LogLevel type;
39 int value = 0;
40 while (true)
41 {
42 const char* name = type.getValueName(value);
43 if (strcmp(name, "") == 0 || name == _value)
44 break;
45 value++;
46 }
47 type.mValue = (Enum)value;
48 return type;
49 }
50
51 friend bool operator < (LogLevel const& a, LogLevel const& b)
52 {
53 return a.mValue < b.mValue;
54 }
55
56 friend bool operator >= (LogLevel const& a, LogLevel const& b)
57 {
58 return !(a < b);
59 }
60
61 friend bool operator > (LogLevel const& a, LogLevel const& b)
62 {
63 return (b < a);
64 }
65
66 friend bool operator <= (LogLevel const& a, LogLevel const& b)
67 {
68 return !(a > b);
69 }
70
71 friend bool operator == (LogLevel const& a, LogLevel const& b)
72 {
73 return !(a < b) && !(a > b);
74 }
75
76 friend bool operator != (LogLevel const& a, LogLevel const& b)
77 {
78 return !(a == b);
79 }
80
81 friend std::ostream& operator << (std::ostream& _stream, const LogLevel& _value)
82 {
83 _stream << _value.getValueName(_value.mValue);
84 return _stream;
85 }
86
87 friend std::istream& operator >> (std::istream& _stream, LogLevel& _value)
88 {
89 std::string value;
90 _stream >> value;
91 _value = parse(value);
92 return _stream;
93 }
94
95 std::string print() const
96 {
97 return getValueName(mValue);
98 }
99
100 int getValue() const
101 {
102 return mValue;
103 }
104
105 private:
106 const char* getValueName(int _index) const
107 {
108 static const char* values[MAX + 1] = { "Info", "Warning", "Error", "Critical", "" };
109 return values[(_index < MAX && _index >= 0) ? _index : MAX];
110 }
111
112 private:
113 Enum mValue;
114 };
115
116 } // namespace MyGUI
117
118 #endif // MYGUI_LOG_LEVEL_H_
MyGUI::FontCodeType::Enum
Enum
Definition: MyGUI_FontData.h:18
MyGUI::LogLevel::Critical
Definition: MyGUI_LogLevel.h:22
MyGUI::LogLevel::getValue
int getValue() const
Definition: MyGUI_LogLevel.h:100
MyGUI_Prerequest.h
MyGUI::LogLevel::Enum
Enum
Definition: MyGUI_LogLevel.h:17
MyGUI::LogLevel::Info
Definition: MyGUI_LogLevel.h:19
MyGUI::operator!=
bool operator!=(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1048
MyGUI::LogLevel::Warning
Definition: MyGUI_LogLevel.h:20
MyGUI::LogLevel
Definition: MyGUI_LogLevel.h:15
MyGUI::operator==
bool operator==(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1045
MyGUI::operator<=
bool operator<=(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1054
MyGUI::LogLevel::parse
static LogLevel parse(const std::string &_value)
Definition: MyGUI_LogLevel.h:36
MyGUI::LogLevel::print
std::string print() const
Definition: MyGUI_LogLevel.h:95
MyGUI::LogLevel::Error
Definition: MyGUI_LogLevel.h:21
MyGUI::operator>
bool operator>(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1057
MyGUI
Definition: MyGUI_ActionController.h:14
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::LogLevel::LogLevel
LogLevel()
Definition: MyGUI_LogLevel.h:26
MyGUI::operator>=
bool operator>=(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1060
MyGUI::LogLevel::LogLevel
LogLevel(Enum _value)
Definition: MyGUI_LogLevel.h:31
MyGUI::operator<
bool operator<(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1051