00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef LOG4QT_LEVEL_H
00026 #define LOG4QT_LEVEL_H
00027
00028
00029
00030
00031
00032
00033 #include <QtCore/QString>
00034 #include <QtCore/QMetaType>
00035 #include "log4qt/log4qt.h"
00036
00037
00038
00039
00040
00041
00042 namespace Log4Qt
00043 {
00044
00050 class Level
00051 {
00052 public:
00053
00054
00055
00056
00060 enum Value
00061 {
00063 NULL_INT = 0,
00064 ALL_INT = 32,
00065 TRACE_INT = 64,
00066 DEBUG_INT = 96,
00067 INFO_INT = 128,
00068 WARN_INT = 150,
00069 ERROR_INT = 182,
00070 FATAL_INT = 214,
00071 OFF_INT = 255
00072 };
00073
00074 public:
00075 Level(Value value = NULL_INT);
00076
00077
00078
00079
00080 int syslogEquivalent() const;
00081 int toInt() const;
00082
00083 bool operator==(const Level &rOther) const;
00084 bool operator!=(const Level &rOther) const;
00085 bool operator<(const Level &rOther) const;
00086 bool operator<=(const Level &rOther) const;
00087 bool operator>(const Level &rOther) const;
00088 bool operator>=(const Level &rOther) const;
00089 QString toString() const;
00090
00091 static Level fromString(const QString &rName, bool *pOk = 0);
00092
00093 private:
00094
00095 volatile Value mValue;
00096
00097 #ifndef QT_NO_DATASTREAM
00098
00099 friend QDataStream &operator<<(QDataStream &rStream,
00100 const Level &rLevel);
00101 friend QDataStream &operator>>(QDataStream &rStream,
00102 Level &rLevel);
00103 #endif // QT_NO_DATASTREAM
00104 };
00105
00106
00107
00108
00109
00110
00111 #ifndef QT_NO_DATASTREAM
00112
00118 QDataStream &operator<<(QDataStream &rStream,
00119 const Level &rLevel);
00120
00127 QDataStream &operator>>(QDataStream &rStream,
00128 Level &rLevel);
00129 #endif // QT_NO_DATASTREAM
00130
00131 #ifndef QT_NO_DEBUG_STREAM
00132
00143 QDebug operator<<(QDebug debug,
00144 const Level &rLevel);
00145 #endif // QT_NO_DEBUG_STREAM
00146
00147
00148
00149
00150
00151
00152
00153 inline Level::Level(Value value) :
00154 mValue(value)
00155 {}
00156
00157 inline int Level::toInt() const
00158 {
00159 return mValue; }
00160
00161 inline bool Level::operator==(const Level &rOther) const
00162 {
00163 return mValue == rOther.mValue; }
00164
00165 inline bool Level::operator!=(const Level &rOther) const
00166 {
00167 return mValue != rOther.mValue; }
00168
00169 inline bool Level::operator<(const Level &rOther) const
00170 {
00171 return mValue < rOther.mValue; }
00172
00173 inline bool Level::operator<=(const Level &rOther) const
00174 {
00175 return mValue <= rOther.mValue; }
00176
00177 inline bool Level::operator>(const Level &rOther) const
00178 {
00179 return mValue > rOther.mValue; }
00180
00181 inline bool Level::operator>=(const Level &rOther) const
00182 {
00183 return mValue >= rOther.mValue; }
00184
00185
00186 }
00187
00188
00189 Q_DECLARE_METATYPE(Log4Qt::Level)
00190 Q_DECLARE_TYPEINFO(Log4Qt::Level, Q_MOVABLE_TYPE);
00191
00192
00193 #endif // LOG4QT_LEVEL_H