Commit 7302ec33 authored by Adriaan de Groot's avatar Adriaan de Groot 💬
Browse files

dot files: reduce compiler-warnings

 - be consistent(er) in using C++11-style iteration (same caveats
   as with tgf files, though)
 - processEdge() and processNode() don't have to be members, they
   don't do anything directly with the fileformat
 - use const& where possible
parent e4bb668a
...@@ -38,6 +38,9 @@ extern DotParser::DotGraphParsingHelper* phelper; ...@@ -38,6 +38,9 @@ extern DotParser::DotGraphParsingHelper* phelper;
using namespace GraphTheory; using namespace GraphTheory;
static QString processNode(const NodePtr &node);
static QString processEdge(const EdgePtr &edge);
K_PLUGIN_FACTORY_WITH_JSON( FilePluginFactory, K_PLUGIN_FACTORY_WITH_JSON( FilePluginFactory,
"dotfileformat.json", "dotfileformat.json",
registerPlugin<DotFileFormat>();) registerPlugin<DotFileFormat>();)
...@@ -95,12 +98,12 @@ void DotFileFormat::writeFile(GraphDocumentPtr document) ...@@ -95,12 +98,12 @@ void DotFileFormat::writeFile(GraphDocumentPtr document)
QHash<int, bool> processedData; QHash<int, bool> processedData;
// process all data elements // process all data elements
foreach(NodePtr node, document->nodes()) { for (const NodePtr &node : document->nodes()) {
out << processNode(node); out << processNode(node);
} }
// process all edges // process all edges
for (auto const edge : document->edges()) { for (const auto &edge : document->edges()) {
out << processEdge(edge); out << processEdge(edge);
} }
out << "}\n"; out << "}\n";
...@@ -108,7 +111,7 @@ void DotFileFormat::writeFile(GraphDocumentPtr document) ...@@ -108,7 +111,7 @@ void DotFileFormat::writeFile(GraphDocumentPtr document)
return; return;
} }
QString DotFileFormat::processEdge(EdgePtr edge) const static QString processEdge(const EdgePtr &edge)
{ {
QString edgeStr; QString edgeStr;
edgeStr.append(QString(" %1 -> %2 ") edgeStr.append(QString(" %1 -> %2 ")
...@@ -122,7 +125,7 @@ QString DotFileFormat::processEdge(EdgePtr edge) const ...@@ -122,7 +125,7 @@ QString DotFileFormat::processEdge(EdgePtr edge) const
edgeStr.append("["); edgeStr.append("[");
edgeStr.append(QString(" label = \"%2\" ").arg(edge->property("name").toString())); edgeStr.append(QString(" label = \"%2\" ").arg(edge->property("name").toString()));
} }
foreach(const QByteArray& property, edge->dynamicPropertyNames()) { for(const QByteArray &property : edge->dynamicPropertyNames()) {
if (firstProperty == true) { if (firstProperty == true) {
firstProperty = false; firstProperty = false;
edgeStr.append("["); edgeStr.append("[");
...@@ -137,7 +140,7 @@ QString DotFileFormat::processEdge(EdgePtr edge) const ...@@ -137,7 +140,7 @@ QString DotFileFormat::processEdge(EdgePtr edge) const
return edgeStr.append(";\n"); return edgeStr.append(";\n");
} }
QString DotFileFormat::processNode(NodePtr node) const static QString processNode(const NodePtr &node)
{ {
QString nodeStr; QString nodeStr;
...@@ -148,7 +151,7 @@ QString DotFileFormat::processNode(NodePtr node) const ...@@ -148,7 +151,7 @@ QString DotFileFormat::processNode(NodePtr node) const
nodeStr.append(QString("label=\"%1\" ").arg(node->dynamicProperty("name").toString())); nodeStr.append(QString("label=\"%1\" ").arg(node->dynamicProperty("name").toString()));
} }
foreach(const QByteArray& property, node->dynamicPropertyNames()) { for(const QByteArray &property : node->dynamicPropertyNames()) {
nodeStr.append(", "); nodeStr.append(", ");
nodeStr.append(QString(" %1 = \"%2\" ").arg(QString(property)).arg(node->property(property).toString())); nodeStr.append(QString(" %1 = \"%2\" ").arg(QString(property)).arg(node->property(property).toString()));
} }
......
...@@ -50,11 +50,6 @@ public: ...@@ -50,11 +50,6 @@ public:
* \param file is url of a local file * \param file is url of a local file
*/ */
void readFile() Q_DECL_OVERRIDE; void readFile() Q_DECL_OVERRIDE;
private:
QString processNode(NodePtr node) const;
QString processEdge(EdgePtr edge) const;
}; };
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment