migrate std::string to qstring + add sysinfo via json (#412)

* std::string -> qstring part 1

* more string migration

* more string migration ...

* ...

* more qstring mogrations
add sysinfo via json

* remove unneccessary includes

* integrate sysinfo into webui
This commit is contained in:
redPanther
2017-03-04 22:17:42 +01:00
committed by GitHub
parent 19f8928869
commit bfb9a08c80
90 changed files with 539 additions and 529 deletions

View File

@@ -1,9 +1,7 @@
#pragma once
#include <iostream>
#include <string>
#include <stdexcept>
#include <sstream>
// JSON-Schema includes
#include <utils/jsonschema/QJsonSchemaChecker.h>
@@ -30,9 +28,10 @@ public:
bool valid = schemaChecker.validate(configTree);
for (std::list<std::string>::const_iterator i = schemaChecker.getMessages().begin(); i != schemaChecker.getMessages().end(); ++i)
QStringList messages = schemaChecker.getMessages();
for (int i = 0; i < messages.size(); ++i)
{
std::cout << *i << std::endl;
std::cout << messages[i].toStdString() << std::endl;
}
if (!valid)
@@ -52,9 +51,7 @@ public:
if (!file.open(QIODevice::ReadOnly))
{
std::stringstream sstream;
sstream << "Configuration file not found: '" << path.toStdString() << "' (" << file.errorString().toStdString() << ")";
throw std::runtime_error(sstream.str());
throw std::runtime_error(QString("Configuration file not found: '" + path + "' (" + file.errorString() + ")").toStdString());
}
QString config = QString(file.readAll());
@@ -78,9 +75,9 @@ public:
}
}
std::stringstream sstream;
sstream << "Failed to parse configuration: " << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
throw std::runtime_error(sstream.str());
throw std::runtime_error (
QString("Failed to parse configuration: " + error.errorString() + " at Line: " + QString::number(errorLine) + ", Column: " + QString::number(errorColumn)).toStdString()
);
}
return doc.object();
@@ -93,9 +90,7 @@ public:
if (!schemaData.open(QIODevice::ReadOnly))
{
std::stringstream sstream;
sstream << "Schema not found: '" << path.toStdString() << "' (" << schemaData.errorString().toStdString() << ")";
throw std::runtime_error(sstream.str());
throw std::runtime_error(QString("Schema not found: '" + path + "' (" + schemaData.errorString() + ")").toStdString());
}
QByteArray schema = schemaData.readAll();
@@ -117,9 +112,9 @@ public:
}
}
std::stringstream sstream;
sstream << "ERROR: Json schema wrong: " << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
throw std::runtime_error(sstream.str());
throw std::runtime_error(QString("ERROR: Json schema wrong: " + error.errorString() + " at Line: " + QString::number(errorLine)
+ ", Column: " + QString::number(errorColumn)).toStdString()
);
}
return doc.object();

View File

@@ -1,9 +1,5 @@
#pragma once
// stl includes
#include <string>
#include <list>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
@@ -48,7 +44,7 @@ public:
///
/// @return A list of error messages
///
const std::list<std::string> & getMessages() const;
const QStringList & getMessages() const;
private:
///
@@ -65,7 +61,7 @@ private:
///
/// @param[in] message The message to add to the queue
///
void setMessage(const std::string & message);
void setMessage(const QString & message);
private:
// attribute check functions
@@ -166,9 +162,9 @@ private:
/// ignore the required value in json schema
bool _ignoreRequired;
/// The current location into a json-configuration structure being checked
std::list<std::string> _currentPath;
QStringList _currentPath;
/// The result messages collected during the schema verification
std::list<std::string> _messages;
QStringList _messages;
/// Flag indicating an error occured during validation
bool _error;
};