1 /* This file is part of the KDE project 2 Copyright (C) 2010 Marijn Kruisselbrink <mkruisselbrink@kde.org> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef XLSRECORDOUTPUTSTREAM_H 21 #define XLSRECORDOUTPUTSTREAM_H 22 23 #include <QDataStream> 24 25 class QBuffer; 26 class QIODevice; 27 28 namespace Swinder { 29 30 class Record; 31 32 class XlsRecordOutputStream 33 { 34 public: 35 explicit XlsRecordOutputStream(QIODevice *device); 36 37 /** 38 * Writes a record, updates the records position to the position it is saved to in the file. 39 */ 40 void writeRecord(Record& record); 41 void writeRecord(const Record& record); 42 /** 43 * Rewrites the given record at its recordPosition by first seeking there, and then going back to where the output device was first. 44 */ 45 void rewriteRecord(const Record& record); 46 47 void startRecord(unsigned recordType); 48 void endRecord(); 49 50 void writeUnsigned(unsigned bits, unsigned value); 51 void writeSigned(unsigned bits, signed value); 52 void writeFloat(unsigned bits, double value); 53 void writeUnicodeString(const QString& value); 54 void writeUnicodeStringWithFlags(const QString& value); 55 void writeUnicodeStringWithFlagsAndLength(const QString& value); 56 void writeByteString(const QString& value); 57 void writeBlob(const QByteArray& value); 58 59 qint64 pos() const; 60 qint64 recordPos() const; 61 private: 62 QDataStream m_dataStream; 63 unsigned m_currentRecord; 64 QBuffer* m_buffer; 65 unsigned char m_curByte; 66 unsigned m_curBitOffset; 67 }; 68 69 } // namespace Swinder 70 71 #endif // XLSRECORDOUTPUTSTREAM_H 72