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_PATTERNFORMATTER_H
00026 #define LOG4QT_PATTERNFORMATTER_H
00027 
00028 
00029 
00030 
00031 
00032 
00033 #include <QtCore/QList>
00034 #include <QtCore/QString>
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 namespace Log4Qt
00043 {
00044     
00045     class FormattingInfo;
00046     class PatternConverter;
00047     class LoggingEvent;
00048     
00064     class PatternFormatter
00065     {
00066     public:
00070         PatternFormatter(const QString &rPattern);
00071         
00075         virtual ~PatternFormatter();
00076     
00077     private:
00078         PatternFormatter(const PatternFormatter &rOther); 
00079         PatternFormatter &operator=(const PatternFormatter &rOther); 
00080     
00081     public:
00087         QString format(const LoggingEvent &rLoggingEvent) const;
00088         
00089     private:
00100         bool addDigit(const QChar &rDigit, 
00101                       int &rValue);
00102         
00111         void createConverter(const QChar &rChar, 
00112                              const FormattingInfo &rFormattingInfo,  
00113                              const QString &rOption = QString());
00114         
00122         void createLiteralConverter(const QString &rLiteral);
00123         
00128         void parse();   
00129     
00136         int parseIntegerOption(const QString &rOption);
00137         
00138     private:
00139         const QString mIgnoreCharacters;
00140         const QString mConversionCharacters;
00141         const QString mOptionCharacters;
00142         QString mPattern;
00143         QList<PatternConverter *> mPatternConverters;
00144         
00145         
00146         friend QDebug operator<<(QDebug, const PatternFormatter &rPatternFormatter);
00147     };
00148     
00149     
00150     
00151 
00152 
00153     
00154 #ifndef QT_NO_DEBUG_STREAM
00155 
00179     QDebug operator<<(QDebug debug, 
00180                       const PatternFormatter &rPatternFormatter);
00181 #endif // QT_NO_DEBUG_STREAM
00182     
00183     
00184     
00185 
00186 
00187     
00188     
00189 } 
00190 
00191 
00192 Q_DECLARE_TYPEINFO(Log4Qt::PatternFormatter, Q_MOVABLE_TYPE);
00193 
00194 
00195 #endif // LOG4QT_PATTERNFORMATTER_H