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

@@ -116,7 +116,7 @@ namespace hyperion
unsigned _blurRemoveCnt;
/// The border detection mode
const std::string _detectionMode;
const QString _detectionMode;
/// The blackborder detector
BlackBorderDetector _detector;

View File

@@ -1,5 +1,4 @@
#ifndef HYPERION_OPTION_H
#define HYPERION_OPTION_H
#pragma once
#include <QCommandLineOption>
#include <QCommandLineParser>
@@ -13,38 +12,30 @@ class Parser;
* regular QCommandLineOption it is _not_ idempotent! */
class Option: public QCommandLineOption
{
protected:
QString _error;
public:
Option(const QString &name,
const QString &description = QString(),
const QString &valueName = QString::null,
const QString &defaultValue = QString()
)
: QCommandLineOption(name, description, valueName, defaultValue)
{}
Option(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString::null,
const QString &defaultValue = QString()
)
: QCommandLineOption(names, description, valueName, defaultValue)
{}
Option(const QCommandLineOption &other)
: QCommandLineOption(other)
{}
Option(const QString &name,
const QString &description = QString(),
const QString &valueName = QString::null,
const QString &defaultValue = QString()
);
virtual bool validate(Parser &parser, QString &value);
QString name()
{ return this->names().last();}
QString getError()
{ return this->_error; }
Option(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString::null,
const QString &defaultValue = QString()
);
Option(const QCommandLineOption &other);
virtual bool validate(Parser &parser, QString &value);
QString name();
QString getError();
QString value(Parser &parser);
std::string getStdString(Parser &parser);
std::wstring getStdWString(Parser &parser);
const char* getCString(Parser &parser);
const char* getCString(Parser &parser);
protected:
QString _error;
};
}
#endif //HYPERION_OPTION_H

View File

@@ -20,7 +20,7 @@ public:
/// @param[in] width The width of the captured screenshot
/// @param[in] height The heigth of the captured screenshot
///
FramebufferFrameGrabber(const std::string & device, const unsigned width, const unsigned height);
FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height);
~FramebufferFrameGrabber();
///
@@ -47,7 +47,7 @@ private:
unsigned char * _fbp;
/// Framebuffer device e.g. /dev/fb0
const std::string _fbDevice;
const QString _fbDevice;
/// With of the captured snapshot [pixels]
const unsigned _width;

View File

@@ -28,7 +28,7 @@ public:
/// @param[in] grabHeight The height of the grabbed images [pixels]
/// @param[in] updateRate_Hz The image grab rate [Hz]
///
FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
///
/// Destructor of this framebuffer frame grabber. Releases any claimed resources.

View File

@@ -1,7 +1,6 @@
#pragma once
// stl includes
#include <string>
#include <vector>
#include <map>
@@ -29,7 +28,7 @@ class V4L2Grabber : public QObject
Q_OBJECT
public:
V4L2Grabber(const std::string & device,
V4L2Grabber(const QString & device,
int input,
VideoStandard videoStandard, PixelFormat pixelFormat,
int width,
@@ -103,9 +102,9 @@ private:
int xioctl(int request, void *arg);
void throw_exception(const std::string &error);
void throw_exception(const QString &error);
void throw_errno_exception(const std::string &error);
void throw_errno_exception(const QString &error);
private:
enum io_method {
@@ -120,8 +119,8 @@ private:
};
private:
std::string _deviceName;
std::map<std::string,std::string> _v4lDevices;
QString _deviceName;
std::map<QString,QString> _v4lDevices;
int _input;
VideoStandard _videoStandard;
io_method _ioMethod;

View File

@@ -13,7 +13,7 @@ class V4L2Wrapper : public GrabberWrapper
Q_OBJECT
public:
V4L2Wrapper(const std::string & device,
V4L2Wrapper(const QString & device,
int input,
VideoStandard videoStandard,
PixelFormat pixelFormat,

View File

@@ -1,8 +1,5 @@
#pragma once
#include <string>
#include <algorithm>
/**
* Enumeration of the possible video standards the grabber can be set to
*/
@@ -12,10 +9,10 @@ enum VideoStandard {
VIDEOSTANDARD_NO_CHANGE
};
inline VideoStandard parseVideoStandard(std::string videoStandard)
inline VideoStandard parseVideoStandard(QString videoStandard)
{
// convert to lower case
std::transform(videoStandard.begin(), videoStandard.end(), videoStandard.begin(), ::tolower);
videoStandard = videoStandard.toLower();
if (videoStandard == "pal")
{

View File

@@ -1,7 +1,7 @@
#pragma once
// STL includes
#include <string>
#include <QString>
// Utils includes
#include <utils/RgbChannelAdjustment.h>
@@ -12,7 +12,7 @@ class ColorAdjustment
public:
/// Unique identifier for this color transform
std::string _id;
QString _id;
/// The BLACK (RGB-Channel) adjustment
RgbChannelAdjustment _rgbBlackAdjustment;

View File

@@ -2,7 +2,6 @@
#include <QObject>
#include <QTimer>
#include <string>
#include <QString>
#include <QStringList>

View File

@@ -128,7 +128,7 @@ public:
/// get filename of configfile
/// @return the current config filename
std::string getConfigFileName() { return _configFile.toStdString(); };
QString getConfigFileName() { return _configFile; };
/// register a input source to a priority channel
/// @param name uniq name of input source
@@ -210,13 +210,13 @@ public slots:
/// Returns the list with unique adjustment identifiers
/// @return The list with adjustment identifiers
///
const std::vector<std::string> & getAdjustmentIds() const;
const QStringList & getAdjustmentIds() const;
///
/// Returns the ColorAdjustment with the given identifier
/// @return The adjustment with the given identifier (or nullptr if the identifier does not exist)
///
ColorAdjustment * getAdjustment(const std::string& id);
ColorAdjustment * getAdjustment(const QString& id);
///
/// Returns MessageForwarder Object

View File

@@ -3,7 +3,6 @@
// STL includes
#include <ctime>
#include <string>
#include <vector>
// Local includes

View File

@@ -25,8 +25,8 @@ public:
MessageForwarder();
~MessageForwarder();
void addJsonSlave(std::string slave);
void addProtoSlave(std::string slave);
void addJsonSlave(QString slave);
void addProtoSlave(QString slave);
bool protoForwardingEnabled();
bool jsonForwardingEnabled();

View File

@@ -3,7 +3,6 @@
// system includes
#include <cstdint>
#include <string>
// QT includes
#include <QTimer>

View File

@@ -8,7 +8,6 @@
// STL incldues
#include <vector>
#include <string>
#include <map>
#include <algorithm>
@@ -24,7 +23,7 @@
class LedDevice;
typedef LedDevice* ( *LedDeviceCreateFuncType ) ( const QJsonObject& );
typedef std::map<std::string,LedDeviceCreateFuncType> LedDeviceRegistry;
typedef std::map<QString,LedDeviceCreateFuncType> LedDeviceRegistry;
///
/// Interface (pure virtual base class) for LedDevices.
@@ -52,10 +51,10 @@ public:
///
virtual int open();
static int addToDeviceMap(std::string name, LedDeviceCreateFuncType funcPtr);
static int addToDeviceMap(QString name, LedDeviceCreateFuncType funcPtr);
static const LedDeviceRegistry& getDeviceMap();
static void setActiveDevice(std::string dev);
static std::string activeDevice() { return _activeDevice; }
static void setActiveDevice(QString dev);
static QString activeDevice() { return _activeDevice; }
static QJsonObject getLedDeviceSchemas();
static void setLedCount(int ledCount);
static int getLedCount() { return _ledCount; }
@@ -78,7 +77,7 @@ protected:
bool _deviceReady;
static std::string _activeDevice;
static QString _activeDevice;
static LedDeviceRegistry _ledDeviceMap;
static int _ledCount;

View File

@@ -1,9 +1,7 @@
#pragma once
// stl includes
#include <string>
// Qt includes
#include <QString>
#include <QColor>
#include <QImage>
#include <QTcpSocket>
@@ -33,7 +31,7 @@ public:
///
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
///
ProtoConnection(const std::string & address);
ProtoConnection(const QString & address);
///
/// Destructor

View File

@@ -49,7 +49,6 @@ inline std::ostream& operator<<(std::ostream& os, const ColorRgb& color)
return os;
}
/// Compare operator to check if a color is 'smaller' than another color
inline bool operator<(const ColorRgb & lhs, const ColorRgb & rhs)
{

View File

@@ -5,7 +5,6 @@
#include <QString>
// stl includes
#include <string>
#include <stdio.h>
#include <stdarg.h>
#include <map>
@@ -51,9 +50,9 @@ public:
} T_LOG_MESSAGE;
static Logger* getInstance(QString name="", LogLevel minLevel=Logger::INFO);
static void deleteInstance(std::string name="");
static void setLogLevel(LogLevel level,std::string name="");
static LogLevel getLogLevel(std::string name="");
static void deleteInstance(QString name="");
static void setLogLevel(LogLevel level, QString name="");
static LogLevel getLogLevel(QString name="");
void Message(LogLevel level, const char* sourceFile, const char* func, unsigned int line, const char* fmt, ...);
void setMinLevel(LogLevel level) { _minLevel = level; };
@@ -63,18 +62,18 @@ signals:
void newLogMessage(Logger::T_LOG_MESSAGE);
protected:
Logger( std::string name="", LogLevel minLevel=INFO);
Logger( QString name="", LogLevel minLevel=INFO);
~Logger();
private:
static std::map<std::string,Logger*> *LoggerMap;
static std::map<QString,Logger*> *LoggerMap;
static LogLevel GLOBAL_MIN_LOG_LEVEL;
std::string _name;
std::string _appname;
LogLevel _minLevel;
bool _syslogEnabled;
unsigned int _loggerId;
QString _name;
QString _appname;
LogLevel _minLevel;
bool _syslogEnabled;
unsigned _loggerId;
};

View File

@@ -1,7 +1,6 @@
#pragma once
#include <string>
#include <algorithm>
#include <QString>
/**
* Enumeration of the possible pixel formats the grabber can be set to
@@ -16,10 +15,10 @@ enum PixelFormat {
PIXELFORMAT_NO_CHANGE
};
inline PixelFormat parsePixelFormat(std::string pixelFormat)
inline PixelFormat parsePixelFormat(QString pixelFormat)
{
// convert to lower case
std::transform(pixelFormat.begin(), pixelFormat.end(), pixelFormat.begin(), ::tolower);
pixelFormat = pixelFormat.toLower();
if (pixelFormat == "yuyv")
{

View File

@@ -1,4 +1,3 @@
#include <string>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
@@ -23,16 +22,16 @@ public:
Profiler(const char* sourceFile, const char* func, unsigned int line);
~Profiler();
static void TimerStart(const std::string stopWatchName, const char* sourceFile, const char* func, unsigned int line);
static void TimerGetTime(const std::string stopWatchName, const char* sourceFile, const char* func, unsigned int line);
static void TimerStart(const QString stopWatchName, const char* sourceFile, const char* func, unsigned int line);
static void TimerGetTime(const QString stopWatchName, const char* sourceFile, const char* func, unsigned int line);
private:
static void initLogger();
static Logger* _logger;
const char* _file;
const char* _func;
unsigned int _line;
unsigned int _blockId;
clock_t _startTime;
const char* _file;
const char* _func;
unsigned int _line;
unsigned int _blockId;
clock_t _startTime;
};

View File

@@ -1,4 +1,5 @@
#pragma once
#include <QString>
#include <utils/ColorRgb.h>
#include <utils/ColorRgbw.h>
@@ -7,7 +8,7 @@ namespace RGBW {
enum WhiteAlgorithm { INVALID, SUBTRACT_MINIMUM, SUB_MIN_WARM_ADJUST, WHITE_OFF };
WhiteAlgorithm stringToWhiteAlgorithm(std::string str);
WhiteAlgorithm stringToWhiteAlgorithm(QString str);
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algorithm);
};

View File

@@ -6,8 +6,7 @@
class SysInfo : public QObject
{
// Q_OBJECT
public:
struct HyperionSysInfo
{
@@ -15,26 +14,27 @@ public:
QString kernelVersion;
QString architecture;
QString wordSize;
QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian
QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid>
QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
QString productType;
QString productVersion;
QString prettyName;
QString hostName;
};
~SysInfo();
static HyperionSysInfo get();
private:
SysInfo();
~SysInfo();
static SysInfo* _instance;
HyperionSysInfo _sysinfo;
struct QUnixOSVersion
{
// from /etc/os-release older /etc/lsb-release // redhat /etc/redhat-release // debian /etc/debian_version
QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian
QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid>
QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
QString productType;
QString productVersion;
QString prettyName;
};
QString machineHostName();

View File

@@ -1,7 +1,6 @@
#pragma once
#include <string>
#include <algorithm>
#include <QString>
/**
* Enumeration of the possible modes in which video can be playing (2D, 3D)
@@ -13,10 +12,10 @@ enum VideoMode
VIDEO_3DTAB
};
inline VideoMode parse3DMode(std::string videoMode)
inline VideoMode parse3DMode(QString videoMode)
{
// convert to lower case
std::transform(videoMode.begin(), videoMode.end(), videoMode.begin(), ::tolower);
videoMode = videoMode.toLower();
if (videoMode == "3DTAB")
{

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;
};

View File

@@ -3,7 +3,6 @@
#include <QObject>
#include <QString>
#include <string>
#include <hyperion/Hyperion.h>
class StaticFileServing;