• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kaddressbook

  • sources
  • kde-4.12
  • kdepim
  • kaddressbook
  • xxport
  • csv
qcsvreader.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  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 the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef QCSVREADER_H
21 #define QCSVREADER_H
22 
23 #include <QtCore/QObject>
24 
25 class QIODevice;
26 
36 class QCsvBuilderInterface
37 {
38  public:
42  virtual ~QCsvBuilderInterface();
43 
47  virtual void begin() = 0;
48 
52  virtual void beginLine() = 0;
53 
61  virtual void field( const QString &data, uint row, uint column ) = 0;
62 
66  virtual void endLine() = 0;
67 
71  virtual void end() = 0;
72 
78  virtual void error( const QString &errorMsg ) = 0;
79 };
80 
91 class QCsvReader : public QObject
92 {
93  Q_OBJECT
94 
95  Q_PROPERTY( QChar textQuote READ textQuote WRITE setTextQuote )
96  Q_PROPERTY( QChar delimiter READ delimiter WRITE setDelimiter )
97  Q_PROPERTY( uint startRow READ startRow WRITE setStartRow )
98 
99  public:
105  explicit QCsvReader( QCsvBuilderInterface *builder );
106 
110  ~QCsvReader();
111 
117  bool read( QIODevice *device );
118 
122  void setTextQuote( const QChar &textQuote );
123 
127  QChar textQuote() const;
128 
133  void setDelimiter( const QChar &delimiter );
134 
138  QChar delimiter() const;
139 
149  void setStartRow( uint startRow );
150 
154  uint startRow() const;
155 
161  void setTextCodec( QTextCodec *textCodec );
162 
166  QTextCodec *textCodec() const;
167 
171  void terminate();
172 
173  private:
174  class Private;
175  Private *const d;
176 };
177 
186 class QCsvStandardBuilder : public QCsvBuilderInterface
187 {
188  public:
192  QCsvStandardBuilder();
193 
197  ~QCsvStandardBuilder();
198 
202  QString lastErrorString() const;
203 
207  uint rowCount() const;
208 
212  uint columnCount() const;
213 
218  QString data( uint row, uint column ) const;
219 
223  void begin();
224  void beginLine();
225  void field( const QString &data, uint row, uint column );
226  void endLine();
227  void end();
228  void error( const QString &errorMsg );
229 
230  private:
231  class Private;
232  Private *const d;
233 
234  Q_DISABLE_COPY( QCsvStandardBuilder )
235 };
236 
237 #endif
QCsvReader::setTextCodec
void setTextCodec(QTextCodec *textCodec)
Sets the text codec that shall be used for parsing the csv list.
Definition: qcsvreader.cpp:297
QCsvBuilderInterface::error
virtual void error(const QString &errorMsg)=0
This method is called whenever an error occurs during parsing.
QCsvBuilderInterface::end
virtual void end()=0
This method is called at the end of parsing.
QCsvBuilderInterface::beginLine
virtual void beginLine()=0
This method is called whenever a new line starts.
QCsvReader
A parser for comma separated value data.
Definition: qcsvreader.h:91
QObject
QCsvBuilderInterface::begin
virtual void begin()=0
This method is called on start of the parsing.
QCsvBuilderInterface::field
virtual void field(const QString &data, uint row, uint column)=0
This method is called for every parsed field.
QCsvBuilderInterface::~QCsvBuilderInterface
virtual ~QCsvBuilderInterface()
This method is called on the destruction of the interface.
Definition: qcsvreader.cpp:28
QCsvReader::setDelimiter
void setDelimiter(const QChar &delimiter)
Sets the character that is used as delimiter for fields.
Definition: qcsvreader.cpp:277
QCsvReader::setTextQuote
void setTextQuote(const QChar &textQuote)
Sets the character that is used for quoting.
Definition: qcsvreader.cpp:267
QCsvReader::setStartRow
void setStartRow(uint startRow)
Sets the row from where the parsing shall be started.
Definition: qcsvreader.cpp:287
QCsvReader::terminate
void terminate()
Terminates the parsing of the csv data.
Definition: qcsvreader.cpp:307
QCsvReader::textQuote
QChar textQuote() const
Returns the character that is used for quoting.
QCsvReader::read
bool read(QIODevice *device)
Parses the csv data from device.
Definition: qcsvreader.cpp:89
QCsvReader::delimiter
QChar delimiter() const
Returns the delimiter that is used as delimiter for fields.
QCsvStandardBuilder
A convenience class that implements QCsvBuilderInterface.
Definition: qcsvreader.h:186
QCsvReader::startRow
uint startRow() const
Returns the start row.
QCsvBuilderInterface
An interface to build data structures from a CSV file.
Definition: qcsvreader.h:36
QCsvReader::textCodec
QTextCodec * textCodec() const
Returns the text codec that is used for parsing the csv list.
Definition: qcsvreader.cpp:302
QCsvBuilderInterface::endLine
virtual void endLine()=0
This method is called whenever a line ends.
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal