parent
9faa1cce49
commit
491f5e2276
|
|
@ -18,22 +18,40 @@ LoadMapping::~LoadMapping()
|
|||
|
||||
bool LoadMapping::load(const QString &loadDir,const QString &matchdDir,const QString &exceptionFile)
|
||||
{
|
||||
|
||||
if(LoadMapping::ht->keys().length()>0)
|
||||
{
|
||||
return true;//只执行一次
|
||||
}
|
||||
if(!QFileInfo::exists(loadDir)|!QFileInfo::exists(matchdDir)|!QFileInfo::exists(exceptionFile))
|
||||
if(!QFileInfo::exists(loadDir))
|
||||
{
|
||||
std::cout<<"load file not exists."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!QFileInfo::exists(matchdDir))
|
||||
{
|
||||
std::cout<<"match file not exists."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!QFileInfo::exists(exceptionFile))
|
||||
{
|
||||
std::cout<<"match file not exists."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!this->readMatch(matchdDir))
|
||||
{
|
||||
std::cout<<"read match failed"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
this->loadMatchException.init(exceptionFile);
|
||||
|
||||
if(!this->readLoads(loadDir))
|
||||
{
|
||||
std::cout<<"read load failed"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
@ -57,6 +75,12 @@ bool LoadMapping::readLoads(const QString &dir)
|
|||
continue;
|
||||
}
|
||||
QString fileName=fileInfo.baseName();
|
||||
|
||||
if(this->loadMatchException.contains(fileName))
|
||||
{
|
||||
std::cout<<"ignore "<<fileName.toLocal8Bit().data()<<std::endl;
|
||||
continue;
|
||||
}
|
||||
if(!this->loadsToLoadInfo.contains(fileName))
|
||||
{
|
||||
std::cout<<filePath.toLocal8Bit().data()<<" no match."<<std::endl;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "recursedir.h"
|
||||
#include "loadinfo.h"
|
||||
#include "loadmatchexception.h"
|
||||
//这是一个单例
|
||||
class LoadMapping
|
||||
{
|
||||
|
|
@ -37,6 +38,7 @@ private:
|
|||
static QHash<QString,QVector<double> > *ht;
|
||||
QHash<QString,QVector<QSharedPointer<LoadInfo> > > loads;
|
||||
QHash<QString,QSharedPointer<LoadInfo> > loadsToLoadInfo;
|
||||
LoadMatchException loadMatchException;
|
||||
};
|
||||
|
||||
#endif // LOADMAPPING_H
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "loadmatchexception.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
QHash<QString,char > *LoadMatchException::ht=NULL;
|
||||
LoadMatchException::LoadMatchException()
|
||||
{
|
||||
|
|
@ -14,6 +14,7 @@ LoadMatchException::~LoadMatchException()
|
|||
|
||||
bool LoadMatchException::contains(const QString& key)
|
||||
{
|
||||
|
||||
return LoadMatchException::ht->contains(key);
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +37,10 @@ bool LoadMatchException::init(const QString& exceptionFilePath)
|
|||
}
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"cannot open exception file "<<exceptionFilePath.toStdString()<<std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QHash>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
class LoadMatchException
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
LoadMapping lm;
|
||||
lm.load("D:/Project/佛山项目/数据/搭网架参数文件/泰安/泰安负荷","D:/Project/佛山项目/数据/匹配的数据","");
|
||||
lm.load("D:/Project/佛山项目/数据/搭网架参数文件/泰安/泰安负荷","D:/Project/佛山项目/数据/匹配的数据","D:/Project/佛山项目/数据/exception.txt");
|
||||
|
||||
// ReadWrite aa;
|
||||
// RegexExtract re;
|
||||
|
|
|
|||
Loading…
Reference in New Issue