libodsstream
tsvdirectorywriter.h
1 /*
2  libodsstream is a library to read and write ODS documents as streams
3  Copyright (C) 2013 Olivier Langella <Olivier.Langella@moulon.inra.fr>
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef TSVDIRECTORYWRITER_H
21 #define TSVDIRECTORYWRITER_H
22 
23 
24 #include <QString>
25 #include <QUrl>
26 #include <QDate>
27 #include <QDir>
28 #include <QTextStream>
29 #include <QFile>
30 #include "calcwriterinterface.h"
31 
33 {
34 public:
35  TsvDirectoryWriter(const QDir & directory);
37 
38  void close() override;
39 
40  void writeSheet(const QString & sheetName) override;
41  void writeLine() override;
42  void writeCell(const char *) override;
43  void writeCell(const QString &) override;
44  void writeEmptyCell() override;
45  void writeCell(int) override;
46  void writeCell(float) override;
47  void writeCell(double)override;
48  void writeCellPercentage(double value) override;
49  void writeCell(bool) override;
50  void writeCell(const QDate &) override;
51  void writeCell(const QDateTime &) override;
52  void writeCell(const QUrl &, const QString &) override;
53  void setCellAnnotation(const QString & annotation) override{};
54 
55 protected:
57  QString _separator = "\t";
58  QString _end_of_line = "\n";
59  QTextStream * _p_otxtstream = nullptr;
60  unsigned int numFloatPrecision = 12;
61 
62 private:
63  const QDir _directory;
64 
65  QString _file_extension = ".tsv";
66 
67  bool _tableRowStart = true;
68 
69  QFile * _p_ofile = nullptr;
70  void ensureSheet();
71 
72 
73 };
74 
75 #endif // TSVDIRECTORYWRITER_H
void setCellAnnotation(const QString &annotation) override
set annotation to write in the next cell
Definition: tsvdirectorywriter.h:53
void writeLine() override
open a new line
Definition: tsvdirectorywriter.cpp:83
void writeEmptyCell() override
write an empty cell
Definition: tsvdirectorywriter.cpp:99
Definition: tsvdirectorywriter.h:32
void writeCellPercentage(double value) override
write a double as a percentage
Definition: tsvdirectorywriter.cpp:116
void writeCell(const char *) override
write a text cell
Definition: tsvdirectorywriter.cpp:88
void writeSheet(const QString &sheetName) override
open a new sheet
Definition: tsvdirectorywriter.cpp:61
Definition: calcwriterinterface.h:29