QtSpell  0.8.2
Spell checking for Qt text widgets
/usr/src/RPM/BUILD/qtspell-0.8.2/src/Codetable.hpp
00001 /* QtSpell - Spell checking for Qt text widgets.
00002  * Copyright (c) 2014 Sandro Mani
00003  *
00004  *    This program is free software; you can redistribute it and/or modify
00005  *    it under the terms of the GNU General Public License as published by
00006  *    the Free Software Foundation; either version 2 of the License, or
00007  *    (at your option) any later version.
00008  *
00009  *    This program is distributed in the hope that it will be useful,
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *    GNU General Public License for more details.
00013  *
00014  *    You should have received a copy of the GNU General Public License along
00015  *    with this program; if not, write to the Free Software Foundation, Inc.,
00016  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef QTSPELL_CODETABLE_HPP
00020 #define QTSPELL_CODETABLE_HPP
00021 
00022 #include <QDir>
00023 #include <QMap>
00024 #include <QString>
00025 
00026 class QXmlStreamReader;
00027 
00028 namespace QtSpell {
00029 
00033 class Codetable
00034 {
00035 public:
00040         static Codetable* instance();
00041 
00051         void lookup(const QString& language_code, QString& language_name, QString& country_name) const;
00052 
00053 private:
00054         typedef void (*parser_t)(const QXmlStreamReader&, QMap<QString, QString>&);
00055         QMap<QString, QString> m_languageTable;
00056         QMap<QString, QString> m_countryTable;
00057 
00058         Codetable();
00059         void parse(const QDir& dataDir, const QString& basename, const parser_t& parser, QMap<QString, QString>& table);
00060         static void parseIso3166Elements(const QXmlStreamReader& xml, QMap<QString, QString> & table);
00061         static void parseIso639Elements(const QXmlStreamReader& xml, QMap<QString, QString> & table);
00062 };
00063 
00064 } // QtSpell
00065 
00066 #endif // QTSPELL_CODETABLE_HPP