~michael-sheldon/ubuntu-keyboard/fix-oxide-dismiss-test

« back to all changes in this revision

Viewing changes to src/lib/parser/layoutparser.h

  • Committer: Thomas Moenicke
  • Date: 2013-07-19 12:05:07 UTC
  • Revision ID: thomas.moenicke@canonical.com-20130719120507-lzw5oq50xm567x0j
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; c-file-offsets: ((innamespace . 0)); -*-
 
2
/*
 
3
 * This file is part of Maliit Plugins
 
4
 *
 
5
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
 
6
 *
 
7
 * Contact: Mohammad Anwari <Mohammad.Anwari@nokia.com>
 
8
 *
 
9
 * Redistribution and use in source and binary forms, with or without modification,
 
10
 * are permitted provided that the following conditions are met:
 
11
 *
 
12
 * Redistributions of source code must retain the above copyright notice, this list
 
13
 * of conditions and the following disclaimer.
 
14
 * Redistributions in binary form must reproduce the above copyright notice, this list
 
15
 * of conditions and the following disclaimer in the documentation and/or other materials
 
16
 * provided with the distribution.
 
17
 * Neither the name of Nokia Corporation nor the names of its contributors may be
 
18
 * used to endorse or promote products derived from this software without specific
 
19
 * prior written permission.
 
20
 *
 
21
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 
22
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
23
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 
24
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
25
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
27
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
28
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
30
 *
 
31
 */
 
32
 
 
33
#ifndef MALIIT_KEYBOARD_LAYOUTPARSER_H
 
34
#define MALIIT_KEYBOARD_LAYOUTPARSER_H
 
35
 
 
36
#include <QXmlStreamReader>
 
37
#include <QStringList>
 
38
 
 
39
#include "alltagtypes.h"
 
40
 
 
41
#include "tagbindingcontainer.h"
 
42
#include "tagbinding.h"
 
43
#include "tagextended.h"
 
44
#include "tagkeyboard.h"
 
45
#include "tagkey.h"
 
46
#include "taglayout.h"
 
47
#include "tagmodifiers.h"
 
48
#include "tagrowcontainer.h"
 
49
#include "tagrowelement.h"
 
50
#include "tagrow.h"
 
51
#include "tagsection.h"
 
52
#include "tagspacer.h"
 
53
 
 
54
namespace MaliitKeyboard {
 
55
 
 
56
class LayoutParser
 
57
{
 
58
public:
 
59
    explicit LayoutParser(QIODevice *device);
 
60
 
 
61
    bool parse();
 
62
    bool isLanguageFile();
 
63
 
 
64
    const QString errorString() const;
 
65
 
 
66
    const TagKeyboardPtr keyboard() const;
 
67
    const QStringList imports() const;
 
68
    const QStringList symviews() const;
 
69
    const QStringList numbers() const;
 
70
    const QStringList phonenumbers() const;
 
71
 
 
72
private:
 
73
    QXmlStreamReader m_xml;
 
74
    TagKeyboardPtr m_keyboard;
 
75
    QStringList m_imports;
 
76
    QStringList m_symviews;
 
77
    QStringList m_numbers;
 
78
    QStringList m_phonenumbers;
 
79
 
 
80
    void parseKeyboard();
 
81
    void parseImport();
 
82
    void parseNewStyleImport();
 
83
    void parseImportChild(QStringList *target_list);
 
84
    bool validateOldStyleImport();
 
85
    void parseLayout();
 
86
    void parseSection(const TagLayoutPtr &layout);
 
87
    void parseRow(const TagRowContainerPtr &row_container);
 
88
    void parseKey(const TagRowPtr &row);
 
89
    void parseBinding(const TagBindingContainerPtr &binding_container);
 
90
    void parseModifiers(const TagBindingPtr &binding);
 
91
    void parseExtended(const TagKeyPtr &key);
 
92
    void parseSpacer(const TagRowPtr &row);
 
93
    void goToRootElement();
 
94
    void readToEnd();
 
95
 
 
96
    void error(const QString &message);
 
97
 
 
98
    bool boolValue(const QStringRef &value, bool defaultValue);
 
99
 
 
100
    template <class E>
 
101
    E enumValue(const char * const attribute, const QStringList &values, E defaultValue);
 
102
};
 
103
 
 
104
} // namespace MaliitKeyboard
 
105
 
 
106
#endif // MALIIT_KEYBOARD_LAYOUTPARSER_H