-
Notifications
You must be signed in to change notification settings - Fork 146
/
writer.h
55 lines (48 loc) · 1.71 KB
/
writer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef QTCSVWRITER_H
#define QTCSVWRITER_H
#include "qtcsv/qtcsv_global.h"
#include "abstractdata.h"
#include <QIODevice>
#include <QList>
#include <QString>
#include <QStringConverter>
namespace QtCSV {
class ContentIterator;
// Writer is a data-writer class that works with csv-files and IO Devices.
// As a source of information it requires AbstractData-based container
// class object.
//
// It supports different write methods:
// - WriteMode::REWRITE - if file exist, it will be rewritten
// - WriteMode::APPEND - if file exist, new information will be appended
// to the end of the file.
//
// Also you can specify header and footer for your data.
class QTCSVSHARED_EXPORT Writer {
public:
enum class WriteMode {
REWRITE = 0,
APPEND
};
// Write data to csv-file
static bool write(
const QString& filePath,
const AbstractData& data,
const QString& separator = QString(","),
const QString& textDelimiter = QString("\""),
WriteMode mode = WriteMode::REWRITE,
const QList<QString>& header = {},
const QList<QString>& footer = {},
QStringConverter::Encoding codec = QStringConverter::Utf8);
// Write data to IO Device
static bool write(
QIODevice& ioDevice,
const AbstractData& data,
const QString& separator = QString(","),
const QString& textDelimiter = QString("\""),
const QList<QString>& header = {},
const QList<QString>& footer = {},
QStringConverter::Encoding codec = QStringConverter::Utf8);
};
}
#endif // QTCSVWRITER_H