mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
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:
@@ -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();
|
||||
|
@@ -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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user