1.读不匹配但需要忽略的信息。
2.暂时不用单例。 Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
parent
51eed6e99e
commit
29b219fbe9
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "loadmatchexception.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString,char > *LoadMatchException::ht=NULL;
|
||||||
|
LoadMatchException::LoadMatchException()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadMatchException::~LoadMatchException()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadMatchException::contains(const QString& key)
|
||||||
|
{
|
||||||
|
return LoadMatchException::ht->contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadMatchException::init(const QString& exceptionFilePath)
|
||||||
|
{
|
||||||
|
LoadMatchException::ht=new QHash<QString,char >;
|
||||||
|
QFile file(exceptionFilePath);
|
||||||
|
QString line;
|
||||||
|
if(file.open(QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream reader(&file);
|
||||||
|
while(!reader.atEnd())
|
||||||
|
{
|
||||||
|
line=reader.readLine().trimmed();
|
||||||
|
if(line.length()==0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(*LoadMatchException::ht)[line]=0;
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef LOADMATCHEXCEPTION_H
|
||||||
|
#define LOADMATCHEXCEPTION_H
|
||||||
|
|
||||||
|
//有些负荷文件就不匹配了
|
||||||
|
#include <QString>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
class LoadMatchException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LoadMatchException();
|
||||||
|
~LoadMatchException();
|
||||||
|
bool contains(const QString& key);
|
||||||
|
bool init(const QString& exceptionFilePath);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~CG()
|
||||||
|
{
|
||||||
|
if (LoadMatchException::ht)
|
||||||
|
delete LoadMatchException::ht;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
||||||
|
static QHash<QString,char > *ht;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOADMATCHEXCEPTION_H
|
||||||
|
|
@ -3,12 +3,14 @@
|
||||||
|
|
||||||
//做一个单例
|
//做一个单例
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
|
|
||||||
template<typename KeyType,typename ValueType>
|
template<typename KeyType,typename ValueType>
|
||||||
class SingletonBase
|
class SingletonBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SingletonBase();
|
// SingletonBase();
|
||||||
~SingletonBase();
|
// ~SingletonBase();
|
||||||
void add(const KeyType& key,const ValueType& val)
|
void add(const KeyType& key,const ValueType& val)
|
||||||
{
|
{
|
||||||
this->ht[key]=val;
|
this->ht[key]=val;
|
||||||
|
|
@ -22,6 +24,10 @@ public:
|
||||||
return this->ht[key];
|
return this->ht[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initInstance()
|
||||||
|
{
|
||||||
|
if()
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
|
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
|
||||||
|
|
@ -34,7 +40,7 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
||||||
static QHash<KeyType,ValueType> *ht; *ht;
|
static QHash<KeyType,ValueType> *ht;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SINGLETONBASE_H
|
#endif // SINGLETONBASE_H
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ SOURCES += main.cpp \
|
||||||
task.cpp \
|
task.cpp \
|
||||||
loadmapping.cpp \
|
loadmapping.cpp \
|
||||||
recursedir.cpp \
|
recursedir.cpp \
|
||||||
loadinfo.cpp
|
loadinfo.cpp \
|
||||||
|
loadmatchexception.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
elementhashtable.h \
|
elementhashtable.h \
|
||||||
|
|
@ -67,7 +68,8 @@ HEADERS += \
|
||||||
loadmapping.h \
|
loadmapping.h \
|
||||||
recursedir.h \
|
recursedir.h \
|
||||||
loadinfo.h \
|
loadinfo.h \
|
||||||
singletonbase.h
|
singletonbase.h \
|
||||||
|
loadmatchexception.h
|
||||||
|
|
||||||
#release{
|
#release{
|
||||||
DEFINES += QT_NO_DEBUG_OUTPUT
|
DEFINES += QT_NO_DEBUG_OUTPUT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue