cimforreduceloss/testHasttable/dgmapping.cpp

68 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "dgmapping.h"
#include <iostream>
DGMapping::DGMapping()
{
}
DGMapping::~DGMapping()
{
}
bool DGMapping::load(const QString &filePath)
{
//格式
//序号名称容量所属Substation的ID
QFile file(filePath);
QString line;
QStringList sep;
if(file.open(QFile::ReadOnly))
{
QTextStream reader(&file);
while(!reader.atEnd())
{
line=reader.readLine().trimmed();
if(line.length()==0)
{
continue;
}
if(line.startsWith("#"))
{
continue;
}
sep=line.split(',');
if(sep.length()<4)
{
continue;
}
QString name=sep.at(1);
double capacity=sep.at(2).toDouble();
QString attachedSubID=sep.at(3);
QSharedPointer<DGInfo> t(new DGInfo);
t->setName(name);
t->setCapacity(capacity);
t->setAttchedSubstaitonID(attachedSubID);
QVector<QSharedPointer<DGInfo> >& vec=this->ht.get(attachedSubID);
vec.push_back(t);
}
file.close();
}
else
{
return false;
}
// QStringList keys;
// keys=this->ht.keys();
// foreach(QString k,keys)
// {
// std::cout<<this->ht.get(k).at(0)->getAttchedSubstaitonID().toStdString()<<std::endl;
// }
return true;
}