xtandemparamsaxhandler.h 2.31 KB
Newer Older
1
2
3
4
5
6
7
8
/**
 * \file /input/xtandemparamsaxhandler.h
 * \date 19/9/2017
 * \author Olivier Langella
 * \brief XML handler for X!Tandem parameters file (presets)
 */

/*******************************************************************************
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.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@u-psud.fr> - initial API and
 *implementation
 ******************************************************************************/
30

31
#pragma once
32
33
34
35
36

#include <QXmlDefaultHandler>
#include <vector>
#include "../core/tandem_run/tandemparameters.h"

37
class XtandemParamSaxHandler : public QXmlDefaultHandler
38
{
39
40
41
  public:
  XtandemParamSaxHandler(TandemParameters *p_tandem_parameters);
  ~XtandemParamSaxHandler();
42

43
44
45
46
  bool startElement(const QString &namespaceURI,
                    const QString &localName,
                    const QString &qName,
                    const QXmlAttributes &attributes);
47

48
49
  bool endElement(const QString &namespaceURI,
                  const QString &localName,
50
                  const QString &qName);
51

52
  bool startDocument();
53

54
  bool endDocument();
55

56
  bool characters(const QString &str);
57

58
59
  bool fatalError(const QXmlParseException &exception);
  bool error(const QXmlParseException &exception);
60

61
  QString errorString() const;
62

63
  bool isTandemParameter() const;
64

65
66
67
68
69
70
71
72
73
74
75
76
  private:
  bool startElement_note(QXmlAttributes attributes);
  bool endElement_note();

  private:
  TandemParameters *_p_tandem_parameters;

  std::vector<QString> _tag_stack;
  QString _errorStr;
  QString _current_text;

  QString _current_label;
77
  bool m_isTandemParameter = false;
78
};