/******************************************************************************
*
* package: Log4Qt
* file: patternformatter.cpp
* created: September 2007
* author: Martin Heinrich
*
*
* changes Feb 2009, Martin Heinrich
* - Fixed VS 2008 unreferenced formal parameter warning by using
* Q_UNUSED in LiteralPatternConverter::convert.
*
*
* Copyright 2007 - 2009 Martin Heinrich
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/******************************************************************************
* Dependencies
******************************************************************************/
#include "log4qt/helpers/patternformatter.h"
#include <QtCore/QString>
#include <QtCore/QDebug>
#include <limits.h>
#include "log4qt/helpers/datetime.h"
#include "log4qt/helpers/logerror.h"
#include "log4qt/layout.h"
#include "log4qt/logger.h"
#include "log4qt/loggingevent.h"
namespace Log4Qt
{
/**************************************************************************
*Declarations
**************************************************************************/
/*!
* \brief The class FormattingInfo stores the formatting modifier for a
* pattern converter.
*
* \sa PatternConverter
*/
class FormattingInfo
{
public:
FormattingInfo()
{ clear(); }
// FormattingInfo(const FormattingInfo &rOther); // Use compiler default
// virtual ~FormattingInfo(); // Use compiler default
// FormattingInfo &operator=(const FormattingInfo &rOther); // Use compiler default
void clear();
static QString intToString(int i);
public:
int mMinLength;
int mMaxLength;
bool mLeftAligned;
};
/*!
* \brief The class PatternConverter is the abstract base class for all
* pattern converters.
*
* PatternConverter handles the minimum and maximum modifier for a
* conversion character. The actual conversion is by calling the
* convert() member function of the derived class.
*
* \sa PatternLayout::format()
*/
class PatternConverter
{
public:
PatternConverter(const FormattingInfo &rFormattingInfo = FormattingInfo()) :
mFormattingInfo(rFormattingInfo)
{};
virtual ~PatternConverter()
{};
private:
PatternConverter(const PatternConverter &rOther); // Not implemented
PatternConverter &operator=(const PatternConverter &rOther); // Not implemented
public:
void format(QString &rFormat, const LoggingEvent &rLoggingEvent) const;
protected:
virtual QString convert(const LoggingEvent &rLoggingEvent) const = 0;
#ifndef QT_NO_DEBUG_STREAM
virtual QDebug debug(QDebug &rDebug) const = 0;
friend QDebug operator<<(QDebug, const PatternConverter &rPatternConverter);
#endif
protected:
FormattingInfo mFormattingInfo;
};
/*!
* \brief The class BasicPatternConverter converts several members of a
* LoggingEvent to a string.
*
* BasicPatternConverter is used by PatternLayout to convert members that
* do not reuquire additional formatting to a string as part of formatting
* the LoggingEvent. It handles the following conversion characters:
* 'm', 'p', 't', 'x'
*
* \sa PatternLayout::format()
* \sa PatternConverter::format()
*/
class BasicPatternConverter : public PatternConverter
{
public:
enum Type {
MESSAGE_CONVERTER,
NDC_CONVERTER,
LEVEL_CONVERTER,
THREAD_CONVERTER,
};
public:
BasicPatternConverter(const FormattingInfo &rFormattingInfo,
Type type) :
PatternConverter(rFormattingInfo),
mType(type)
{};
// virtual ~BasicPatternConverter(); // Use compiler default
private:
BasicPatternConverter(const BasicPatternConverter &rOther); // Not implemented
BasicPatternConverter &operator=(const BasicPatternConverter &rOther); // Not implemented
protected:
virtual QString convert(const LoggingEvent &rLoggingEvent) const;
#ifndef QT_NO_DEBUG_STREAM
virtual QDebug debug(QDebug &rDebug) const;
#endif
private:
Type mType;
};
/*!
* \brief The class DatePatternConverter converts the time stamp of a
* LoggingEvent to a string.
*
* DatePatternConverter is used by PatternLayout to convert the time stamp
* of a LoggingEvent to a string as part of formatting the LoggingEvent.
* It handles the 'd' and 'r' conversion character.
*
* \sa PatternLayout::format()
* \sa PatternConverter::format()
*/
class DatePatternConverter : public PatternConverter
{
public:
DatePatternConverter(const FormattingInfo &rFormattingInfo,
const QString &rFormat) :
PatternConverter(rFormattingInfo),
mFormat(rFormat)
{};
// virtual ~DatePatternConverter(); // Use compiler default
private:
DatePatternConverter(const DatePatternConverter &rOther); // Not implemented
DatePatternConverter &operator=(const DatePatternConverter &rOther); // Not implemented
protected:
virtual QString convert(const LoggingEvent &rLoggingEvent) const;
#ifndef QT_NO_DEBUG_STREAM
virtual QDebug debug(QDebug &rDebug) const;
#endif
private:
QString mFormat;
};
/*!
* \brief The class LiteralPatternConverter provides string literals.
*
* LiteralPatternConverter is used by PatternLayout to embed string
* literals as part of formatting the LoggingEvent. It handles string
* literals and the 'n' conversion character.
*
* \sa PatternLayout::format()
* \sa PatternConverter::format()
*/
class LiteralPatternConverter : public PatternConverter
{
public:
LiteralPatternConverter(const QString &rLiteral) :
PatternConverter(),
mLiteral(rLiteral)
{};
// virtual ~LiteralPatternConverter(); // Use compiler default
private:
LiteralPatternConverter(const LiteralPatternConverter &rOther); // Not implemented
LiteralPatternConverter &operator=(const LiteralPatternConverter &rOther); // Not implemented
protected:
virtual QString convert(const LoggingEvent &rLoggingEvent) const;
#ifndef QT_NO_DEBUG_STREAM
virtual QDebug debug(QDebug &rDebug) const;
#endif
private:
QString mLiteral;
};
/*!
* \brief The class LoggerPatternConverter converts the Logger name of a
* LoggingEvent to a string.
*
* LoggerPatternConverter is used by PatternLayout to convert the Logger
* name of a LoggingEvent to a string as part of formatting the
* LoggingEvent. It handles the 'c' conversion character.
*
* \sa PatternLayout::format()
* \sa PatternConverter::format()
*/
class LoggerPatternConverter : public PatternConverter
{
public:
LoggerPatternConverter(const FormattingInfo &rFormattingInfo,
int precision) :
PatternConverter(rFormattingInfo),
mPrecision(precision)
{};
// virtual ~LoggerPatternConverter(); // Use compiler default
private:
LoggerPatternConverter(const LoggerPatternConverter &rOther); // Not implemented
LoggerPatternConverter &operator=(const LoggerPatternConverter &rOther); // Not implemented
protected:
virtual QString convert(const LoggingEvent &rLoggingEvent) const;
#ifndef QT_NO_DE
没有合适的资源?快使用搜索试试~ 我知道了~
IO 模拟和测试工具,两个程序,相互测试,Qt-5-15-2
共118个文件
h:51个
cpp:48个
png:8个
需积分: 5 0 下载量 43 浏览量
2023-05-30
14:25:12
上传
评论
收藏 798KB RAR 举报
温馨提示
IO 模拟和测试工具,两个程序,相互测试,有界面,很直观。Qt_5_15_2, 模拟IO输入输出。
资源推荐
资源详情
资源评论
收起资源包目录
IO 模拟和测试工具,两个程序,相互测试,Qt-5-15-2 (118个子文件)
patternformatter.cpp 26KB
lanecfg.cpp 25KB
MockIOCard.cpp 24KB
propertyconfigurator.cpp 22KB
logmanager.cpp 17KB
factory.cpp 16KB
laneutils.cpp 13KB
dailyrollingfileappender.cpp 12KB
properties.cpp 10KB
optionconverter.cpp 10KB
logerror.cpp 10KB
datetime.cpp 10KB
logger.cpp 9KB
fileappender.cpp 9KB
loggingevent.cpp 8KB
appenderskeleton.cpp 7KB
writerappender.cpp 7KB
level.cpp 6KB
rollingfileappender.cpp 6KB
mainwindow.cpp 6KB
hierarchy.cpp 6KB
initialisationhelper.cpp 6KB
consoleappender.cpp 5KB
ttcclayout.cpp 5KB
ndc.cpp 4KB
patternlayout.cpp 4KB
listappender.cpp 4KB
configuratorhelper.cpp 4KB
debugappender.cpp 4KB
logrecord.cpp 4KB
basicconfigurator.cpp 3KB
mdc.cpp 3KB
classlogger.cpp 3KB
levelrangefilter.cpp 3KB
stringmatchfilter.cpp 3KB
levelmatchfilter.cpp 3KB
nullappender.cpp 3KB
simplelayout.cpp 2KB
layout.cpp 2KB
load.cpp 2KB
denyallfilter.cpp 2KB
loggerrepository.cpp 2KB
logobject.cpp 2KB
filter.cpp 2KB
logobjectptr.cpp 2KB
log4qt.cpp 2KB
CMockThread.cpp 2KB
main.cpp 385B
MockIOCard.dll 762KB
logger.h 65KB
log4qt.h 26KB
initialisationhelper.h 18KB
factory.h 17KB
logerror.h 17KB
logmanager.h 12KB
fileappender.h 8KB
ttcclayout.h 7KB
appenderskeleton.h 7KB
loggingevent.h 7KB
configuratorhelper.h 7KB
lanecfg.h 7KB
patternformatter.h 7KB
datetime.h 7KB
propertyconfigurator.h 7KB
dailyrollingfileappender.h 7KB
writerappender.h 7KB
logobject.h 6KB
level.h 6KB
laneutils.h 6KB
rollingfileappender.h 6KB
listappender.h 5KB
optionconverter.h 5KB
properties.h 5KB
logobjectptr.h 5KB
consoleappender.h 5KB
hierarchy.h 5KB
patternlayout.h 5KB
levelrangefilter.h 5KB
loggerrepository.h 4KB
layout.h 4KB
stringmatchfilter.h 4KB
levelmatchfilter.h 4KB
debugappender.h 4KB
appender.h 4KB
classlogger.h 4KB
mdc.h 3KB
ndc.h 3KB
filter.h 3KB
denyallfilter.h 3KB
simplelayout.h 3KB
nullappender.h 3KB
basicconfigurator.h 3KB
MockIOCard.h 2KB
logrecord.h 1KB
load.h 1KB
transcode.h 1KB
mainwindow.h 1KB
MockIOCard_global.h 974B
MockIOCard_global.h 974B
CMockThread.h 876B
共 118 条
- 1
- 2
资源评论
hymaliang1120
- 粉丝: 1
- 资源: 68
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功