return line + "\n";
}
-QString CSVDataWriterBackend::filename(const QString& name, const QString& extra) const
-{
-
- QString newname;
- int dotIdx;
-
- dotIdx = name.lastIndexOf('.');
- if (dotIdx > 0) {
- QString suffix = name.mid(dotIdx+1).toLower();
- if (suffix.compare(FILE_EXTENSION) == 0)
- newname = name.mid(0, dotIdx-1); /* Cut the suffix */
- else
- newname = name;
- } else
- newname = name;
-
- if (extra.compare("") != 0)
- return newname + "_" + extra + "." + FILE_EXTENSION;
- else
- return newname + "." + FILE_EXTENSION;
-}
-
QString CSVDataWriterBackend::line(const QVariantList& data) const
{
QString line;
public:
CSVDataWriterBackend(QObject* parent = nullptr);
QString header(const QVariantList& data) const;
- QString filename(const QString& name, const QString& extra) const;
QString line(const QVariantList& data) const;
private:
FILE_EXTENSION(extension)
{
}
+
+QString DataWriterBackend::filename(const QString& name, const QString& extra) const
+{
+ QString newname;
+ int dotIdx;
+
+ dotIdx = name.lastIndexOf('.');
+ if (dotIdx > 0) {
+ QString suffix = name.mid(dotIdx+1).toLower();
+ if (suffix.compare(FILE_EXTENSION) == 0)
+ newname = name.mid(0, dotIdx); /* Cut the suffix */
+ else
+ newname = name;
+ } else
+ newname = name;
+
+ if (extra.compare("") != 0)
+ return newname + "_" + extra + "." + FILE_EXTENSION;
+ else
+ return newname + "." + FILE_EXTENSION;
+}
public:
explicit DataWriterBackend(const QString& extension, QObject* parent = nullptr);
virtual QString header(const QVariantList& data) const = 0;
- virtual QString filename(const QString& name, const QString& extra = QString()) const = 0;
+ virtual QString filename(const QString& name, const QString& extra = QString()) const;
virtual QString line(const QVariantList& data) const = 0;
const QString FILE_EXTENSION;