Skip to content
Snippets Groups Projects
xpipsaxhandler.h 2.22 KiB
/*******************************************************************************
* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of XTPcpp.
*
*     XTPcpp 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 3 of the License, or
*     (at your option) any later version.
*
*     XTPcpp is distributed in the hope that it will be useful,
*     but WITHOUT ANY WARRANTY; without even the implied warranty of
*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*     GNU General Public License for more details.
*
*     You should have received a copy of the GNU General Public License
*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
*     Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/

#ifndef XPIPSAXHANDLER_H
#define XPIPSAXHANDLER_H

#include <QXmlDefaultHandler>
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/protein/protein.h>
#include "../core/project.h"

using namespace pappso;

class XpipSaxHandler: public QXmlDefaultHandler
{
public:
    XpipSaxHandler(Project * p_project);
    ~XpipSaxHandler();

    bool startElement(const QString & namespaceURI, const QString & localName,
                      const QString & qName, const QXmlAttributes & attributes);

    bool endElement(const QString & namespaceURI, const QString & localName,
                    const QString & qName);

    bool startDocument();

    bool endDocument();

    bool characters(const QString &str);

    bool fatalError(const QXmlParseException &exception);
    bool error(const QXmlParseException &exception);

    QString errorString() const;

    
private:
  bool startElement_protein(QXmlAttributes attributes);
  bool startElement_sample(QXmlAttributes attributes);
  bool endElement_sequence();
  bool endElement_protein();

private:
    std::vector<QString> _tag_stack;
    QString _errorStr;
    QString _current_text;
    
    Project * _p_project;
    Protein _current_protein;
};

#endif // XTANDEMRESULTSHANDLER_H