QtSpell  0.8.0
Spell checking for Qt text widgets
Codetable.hpp
1 /* QtSpell - Spell checking for Qt text widgets.
2  * Copyright (c) 2014 Sandro Mani
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef QTSPELL_CODETABLE_HPP
20 #define QTSPELL_CODETABLE_HPP
21 
22 #include <QDir>
23 #include <QMap>
24 #include <QString>
25 
26 class QXmlStreamReader;
27 
28 namespace QtSpell {
29 
33 class Codetable
34 {
35 public:
40  static Codetable* instance();
41 
51  void lookup(const QString& language_code, QString& language_name, QString& country_name) const;
52 
53 private:
54  typedef void (*parser_t)(const QXmlStreamReader&, QMap<QString, QString>&);
55  QMap<QString, QString> m_languageTable;
56  QMap<QString, QString> m_countryTable;
57 
58  Codetable();
59  void parse(const QDir& dataDir, const QString& basename, const parser_t& parser, QMap<QString, QString>& table);
60  static void parseIso3166Elements(const QXmlStreamReader& xml, QMap<QString, QString> & table);
61  static void parseIso639Elements(const QXmlStreamReader& xml, QMap<QString, QString> & table);
62 };
63 
64 } // QtSpell
65 
66 #endif // QTSPELL_CODETABLE_HPP
static Codetable * instance()
Get codetable instance.
Definition: Codetable.cpp:31
void lookup(const QString &language_code, QString &language_name, QString &country_name) const
Looks up the language and country name for the specified language code. If no matching entries are fo...
Definition: Codetable.cpp:37
QtSpell namespace.
Definition: Checker.cpp:56
Class for translating locale identifiers into human readable strings.
Definition: Codetable.hpp:33