elementparser.h 2.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/***************************************************************************
    copyright            : (C) 2005 by Carsten Niehaus
    email                : cniehaus@kde.org
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

14 15 16
#ifndef ELEMENTPARSER_H
#define ELEMENTPARSER_H

Yuri Chornoivan's avatar
Yuri Chornoivan committed
17 18 19
#include <QList>
#include <QXmlAttributes>
#include <QXmlDefaultHandler>
Carsten Niehaus's avatar
Carsten Niehaus committed
20

Yuri Chornoivan's avatar
Yuri Chornoivan committed
21 22
#include "libkdeedu_science_export.h"

23 24
class Element;

25 26 27
/**
 * @author Carsten Niehaus <cniehaus@kde.org>
 */
Laurent Montel's avatar
Laurent Montel committed
28
class SCIENCE_EXPORT ElementSaxParser : public QXmlDefaultHandler
Carsten Niehaus's avatar
Carsten Niehaus committed
29
{
30 31 32 33 34 35
public:
    /**
     * Constructor
     */
    ElementSaxParser();
    ~ElementSaxParser();
36
    bool startElement(const QString&, const QString &localName, const QString&,
Yuri Chornoivan's avatar
Yuri Chornoivan committed
37
                      const QXmlAttributes &attrs) override;
38

Yuri Chornoivan's avatar
Yuri Chornoivan committed
39
    bool endElement(const QString& namespaceURI, const QString &localName, const QString& qName) override;
40

Yuri Chornoivan's avatar
Yuri Chornoivan committed
41
    bool characters(const QString &ch) override;
Carsten Niehaus's avatar
Carsten Niehaus committed
42

43
    QList<Element*> getElements();
44

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
private:
    /**
    * Looks up a name @p unitname. The valid names are
    * hard-coded in the C++ code, currently
    *   - bo:kelvin
    *   - bo:ev
    *   - bo:nm
    *   - bo:pm
    *   - bo:y
    *   - bo:s
    *   - bo:noUnit
    *
    * @return the BlueObeliskUnit of a ChemicalDataObject
    *   corresponding to @p unitname, or noUnit if the name
    *   doesn't match any of the known values.
    * @param unitname the attribute-text of the XML parsed
    */
62
    int unit(const QString& unitname) const;
63 64 65

    class Private;
    Private *const d;
Carsten Niehaus's avatar
Carsten Niehaus committed
66
};
67

Carsten Niehaus's avatar
Carsten Niehaus committed
68
#endif // ELEMENTPARSER_H