#include <QtCore/QLocale>
#include <QtWidgets/QMessageBox>
-const OutputFormat DataFileExporter::SUPPORTED_FORMATS[] = { OutputFormat("Comma separated values", "csv") };
+
+const std::vector<DataFileExporter::OutputFormat> DataFileExporter::SUPPORTED_FORMATS({DataFileExporter::OutputFormat("Comma separated values", "csv")});
/* Static methods */
QStringList DataFileExporter::supportedFormats()
QStringList list;
for (const OutputFormat& of : SUPPORTED_FORMATS) {
- list << of.first;
+ list << of.description;
}
return list;
DataFileExporter::ReturnCode ret;
DataWriterBackend* backend;
- if (formatIdx < 0 || formatIdx >= sizeof(SUPPORTED_FORMATS)) {
+ if (formatIdx < 0 || formatIdx >= SUPPORTED_FORMATS.size()) {
return ReturnCode::E_INVAL_FORMAT;
}
if (suffix.length() == 0)
return;
- for (size_t i = 0; i < sizeof(SUPPORTED_FORMATS); i++) {
- const OutputFormat& of = SUPPORTED_FORMATS[i];
- if (suffix.compare(of.second) == 0) {
- emit formatChanged(i);
+ for (int idx = 0; idx < SUPPORTED_FORMATS.size(); idx++) {
+ if (suffix.compare(SUPPORTED_FORMATS[idx].suffix) == 0) {
+ emit formatChanged(idx);
return;
}
}
#include <QtCore/QFile>
#include <QtCore/QObject>
-typedef std::pair<const QString, const QString> OutputFormat;
-
class DataFileExporter : public QObject
{
Q_OBJECT
CSV,
INVALID
};
+ struct OutputFormat {
+ OutputFormat(const QString& description, const QString& suffix) :
+ description(description), suffix(suffix) {}
+
+ const QString description;
+ const QString suffix;
+ };
OutputFormats formatIdxToFormat(const int idx);
QString toCSVLine(double time, double value);
ReturnCode writeToFile(QFile& file, const DataWriterBackend* writer, const std::pair<QVariantList, std::vector<QVariantList>>& data);
- static const OutputFormat SUPPORTED_FORMATS[];
+ static const std::vector<OutputFormat> SUPPORTED_FORMATS;
signals:
void formatChanged(const int idx);