~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to MyGUIEngine/include/MyGUI_LogLevel.h

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
        @file
3
 
        @author         Albert Semenov
4
 
        @date           04/2010
5
 
*/
6
 
/*
7
 
        This file is part of MyGUI.
8
 
 
9
 
        MyGUI is free software: you can redistribute it and/or modify
10
 
        it under the terms of the GNU Lesser General Public License as published by
11
 
        the Free Software Foundation, either version 3 of the License, or
12
 
        (at your option) any later version.
13
 
 
14
 
        MyGUI is distributed in the hope that it will be useful,
15
 
        but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
        GNU Lesser General Public License for more details.
18
 
 
19
 
        You should have received a copy of the GNU Lesser General Public License
20
 
        along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
21
 
*/
22
 
#ifndef __MYGUI_LOG_LEVEL_H__
23
 
#define __MYGUI_LOG_LEVEL_H__
24
 
 
25
 
#include "MyGUI_Prerequest.h"
26
 
 
27
 
namespace MyGUI
28
 
{
29
 
 
30
 
        struct MYGUI_EXPORT LogLevel
31
 
        {
32
 
                enum Enum
33
 
                {
34
 
                        Info, // Информационное сообщение.
35
 
                        Warning, // Несущественная проблема.
36
 
                        Error, // Устранимая ошибка.
37
 
                        Critical, // Неустранимая ошибка или сбой в работе приложения.
38
 
                        MAX
39
 
                };
40
 
 
41
 
                LogLevel() :
42
 
                        value(Info)
43
 
                {
44
 
                }
45
 
 
46
 
                LogLevel(Enum _value) :
47
 
                        value(_value)
48
 
                {
49
 
                }
50
 
 
51
 
                static LogLevel parse(const std::string& _value)
52
 
                {
53
 
                        LogLevel type;
54
 
                        int value = 0;
55
 
                        while (true)
56
 
                        {
57
 
                                const char* name = type.getValueName(value);
58
 
                                if (strcmp(name, "") == 0 || name == _value)
59
 
                                        break;
60
 
                                value++;
61
 
                        }
62
 
                        type.value = (Enum)value;
63
 
                        return type;
64
 
                }
65
 
 
66
 
                friend bool operator < (LogLevel const& a, LogLevel const& b)
67
 
                {
68
 
                        return a.value < b.value;
69
 
                }
70
 
 
71
 
                friend bool operator >= (LogLevel const& a, LogLevel const& b)
72
 
                {
73
 
                        return !(a < b);
74
 
                }
75
 
 
76
 
                friend bool operator > (LogLevel const& a, LogLevel const& b)
77
 
                {
78
 
                        return (b < a);
79
 
                }
80
 
 
81
 
                friend bool operator <= (LogLevel const& a, LogLevel const& b)
82
 
                {
83
 
                        return !(a > b);
84
 
                }
85
 
 
86
 
                friend bool operator == (LogLevel const& a, LogLevel const& b)
87
 
                {
88
 
                        return !(a < b) && !(a > b);
89
 
                }
90
 
 
91
 
                friend bool operator != (LogLevel const& a, LogLevel const& b)
92
 
                {
93
 
                        return !(a == b);
94
 
                }
95
 
 
96
 
                friend std::ostream& operator << (std::ostream& _stream, const LogLevel&  _value)
97
 
                {
98
 
                        _stream << _value.getValueName(_value.value);
99
 
                        return _stream;
100
 
                }
101
 
 
102
 
                friend std::istream& operator >> (std::istream& _stream, LogLevel&  _value)
103
 
                {
104
 
                        std::string value;
105
 
                        _stream >> value;
106
 
                        _value = parse(value);
107
 
                        return _stream;
108
 
                }
109
 
 
110
 
                std::string print() const
111
 
                {
112
 
                        return getValueName(value);
113
 
                }
114
 
 
115
 
        private:
116
 
                const char* getValueName(int _index) const
117
 
                {
118
 
                        static const char* values[MAX + 1] = { "Info", "Warning", "Error", "Critical", "" };
119
 
                        return values[(_index < MAX && _index >= 0) ? _index : MAX];
120
 
                }
121
 
 
122
 
        private:
123
 
                Enum value;
124
 
        };
125
 
 
126
 
} // namespace MyGUI
127
 
 
128
 
#endif // __MYGUI_LOG_LEVEL_H__
 
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__