File indexing completed on 2024-04-28 07:28:52

0001 /*
0002     SPDX-FileCopyrightText: 2005 Carsten Niehaus <cniehaus@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef ELEMENTPARSER_H
0007 #define ELEMENTPARSER_H
0008 
0009 #include <QList>
0010 #include <QXmlAttributes>
0011 #include <QXmlDefaultHandler>
0012 
0013 #include "science_export.h"
0014 
0015 class Element;
0016 
0017 /**
0018  * @author Carsten Niehaus <cniehaus@kde.org>
0019  */
0020 class SCIENCE_EXPORT ElementSaxParser : public QXmlDefaultHandler
0021 {
0022 public:
0023     /**
0024      * Constructor
0025      */
0026     ElementSaxParser();
0027     ~ElementSaxParser() override;
0028     bool startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs) override;
0029 
0030     bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) override;
0031 
0032     bool characters(const QString &ch) override;
0033 
0034     QList<Element *> getElements() const;
0035 
0036 private:
0037     /**
0038      * Looks up a name @p unitname. The valid names are
0039      * hard-coded in the C++ code, currently
0040      *   - bo:kelvin
0041      *   - bo:ev
0042      *   - bo:nm
0043      *   - bo:pm
0044      *   - bo:y
0045      *   - bo:s
0046      *   - bo:noUnit
0047      *
0048      * @return the BlueObeliskUnit of a ChemicalDataObject
0049      *   corresponding to @p unitname, or noUnit if the name
0050      *   doesn't match any of the known values.
0051      * @param unitname the attribute-text of the XML parsed
0052      */
0053     int unit(const QString &unitname) const;
0054 
0055     class Private;
0056     Private *const d;
0057 };
0058 
0059 #endif // ELEMENTPARSER_H