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