00001 /****************************************************************************** 00002 * 00003 * package: Log4Qt 00004 * file: stringmatchfilter.h 00005 * created: September 2007 00006 * author: Martin Heinrich 00007 * 00008 * 00009 * Copyright 2007 Martin Heinrich 00010 * 00011 * Licensed under the Apache License, Version 2.0 (the "License"); 00012 * you may not use this file except in compliance with the License. 00013 * You may obtain a copy of the License at 00014 * 00015 * http://www.apache.org/licenses/LICENSE-2.0 00016 * 00017 * Unless required by applicable law or agreed to in writing, software 00018 * distributed under the License is distributed on an "AS IS" BASIS, 00019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 * See the License for the specific language governing permissions and 00021 * limitations under the License. 00022 * 00023 ******************************************************************************/ 00024 00025 #ifndef LOG4QT_STRINGMATCHFILTER_H 00026 #define LOG4QT_STRINGMATCHFILTER_H 00027 00028 00029 /****************************************************************************** 00030 * Dependencies 00031 ******************************************************************************/ 00032 00033 #include "log4qt/spi/filter.h" 00034 00035 00036 /****************************************************************************** 00037 * Declarations 00038 ******************************************************************************/ 00039 00040 namespace Log4Qt 00041 { 00042 00050 class StringMatchFilter : public Filter 00051 { 00052 Q_OBJECT 00053 00061 Q_PROPERTY(bool acceptOnMatch READ acceptOnMatch WRITE setAcceptOnMatch) 00062 00063 00068 Q_PROPERTY(QString stringToMatch READ stringToMatch WRITE setStringToMatch) 00069 00070 public: 00071 StringMatchFilter(QObject *pParent = 0); 00072 // StringMatchFilter(const StringMatchFilter &rOther); // Use compiler default 00073 // virtual ~StringMatchFilter(); // Use compiler default 00074 // StringMatchFilter &operator=(const StringMatchFilter &rOther); // Use compiler default 00075 00076 bool acceptOnMatch() const; 00077 QString stringToMatch() const; 00078 void setAcceptOnMatch(bool accept); 00079 void setStringToMatch(const QString &rString); 00080 00081 virtual Decision decide(const LoggingEvent &rEvent) const; 00082 00083 protected: 00084 #ifndef QT_NO_DEBUG_STREAM 00085 00096 virtual QDebug debug(QDebug &rDebug) const; 00097 #endif // QT_NO_DEBUG_STREAM 00098 00099 private: 00100 bool mAcceptOnMatch; 00101 QString mStringToMatch; 00102 }; 00103 00104 00105 /************************************************************************** 00106 * Operators, Helper 00107 **************************************************************************/ 00108 00109 00110 /************************************************************************** 00111 * Inline 00112 **************************************************************************/ 00113 00114 inline bool StringMatchFilter::acceptOnMatch() const 00115 { return mAcceptOnMatch; } 00116 00117 inline QString StringMatchFilter::stringToMatch() const 00118 { return mStringToMatch; } 00119 00120 inline void StringMatchFilter::setAcceptOnMatch(bool accept) 00121 { mAcceptOnMatch = accept; } 00122 00123 inline void StringMatchFilter::setStringToMatch(const QString &rString) 00124 { mStringToMatch = rString; } 00125 00126 00127 } // namespace Log4Qt 00128 00129 00130 // Q_DECLARE_TYPEINFO(Log4Qt::StringMatchFilter, Q_MOVABLE_TYPE); // Use default 00131 00132 00133 #endif // LOG4QT_STRINGMATCHFILTER_H