summaryrefslogtreecommitdiffstats
path: root/kttsd/filters/xhtml2ssml/xhtml2ssml.h
blob: 7271dc0c2e103a18ce4a6f311c01e59bd62a0ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

/****************************************************************************
  XHTMLToSSMLParser class

  Parses a piece of XHTML markup and converts into SSML.
  -------------------
  Copyright:
  (C) 2004 by Paul Giannaros <ceruleanblaze@gmail.com>
  -------------------
  Original author: Paul Giannaros <ceruleanblaze@gmail.com>
******************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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; version 2 of the License.               *
 *                                                                         *
 ***************************************************************************/


#ifndef _XHTML2SSML_H_
#define _XHTML2SSML_H_

#include <qxml.h>
#include <qmap.h>

typedef QMap<QString, QString> QStringMap;
class QString;

class XHTMLToSSMLParser : public QXmlDefaultHandler {

public:
    /// No need to reimplement constructor..
    /// The document parsing starts
    bool startDocument();
    /// start of an element encountered (<element foo="bar">)
    bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts);
    /// end of an element encountered (</element>)
    bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
    /// text encountered (blah bah blah)
    bool characters(const QString &);
    
    /// Get the output text that was generated during the parsing.
    /// @returns                    The converted text.
    QString convertedText();
    
    /// Parse a line from the configuration file which maps xhtml : ssml equivalent.
    /// It makes entries in the m_xhtml2ssml map accordingly.
    /// @param line               A line from a file to parse
    /// @returns                     true if the syntax of the line was okay and the parsing succeeded - false otherwise.
    bool readFileConfigEntry(const QString &line);

private:
    /// Dict of xhtml tags -> ssml tags
    QStringMap m_xhtml2ssml;
    /// The output of the conversion
    QString m_output;
};

#endif