]> git.lyx.org Git - lyx.git/blob - src/Language.h
bc705b7b9533212e9ede116a84e0cbe6bb74b6db
[lyx.git] / src / Language.h
1 // -*- C++ -*-
2 /**
3  * \file Language.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author Dekel Tsur
10  * \author Jürgen Vigna
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef LANGUAGE_H
16 #define LANGUAGE_H
17
18 #include <map>
19 #include <string>
20
21
22 namespace lyx {
23
24 namespace support { class FileName; }
25
26 class Encoding;
27 class Lexer;
28
29 ///
30 class Language {
31 public:
32         ///
33         Language() : rightToLeft_(false) {}
34         ///
35         std::string const & lang() const { return lang_; }
36         ///
37         std::string const & babel() const { return babel_; }
38         ///
39         std::string const & display() const { return display_; }
40         ///
41         bool rightToLeft() const { return rightToLeft_; }
42         ///
43         Encoding const * encoding() const { return encoding_; }
44         ///
45         std::string const & encodingStr() const { return encodingStr_; }
46         ///
47         std::string const & code() const { return code_; }
48         /// set code (needed for rc.spellchecker_alt_lang)
49         void setCode(std::string const c) { code_ = c; }
50         ///
51         std::string const & variety() const { return variety_; }
52         /// set variety (needed for rc.spellchecker_alt_lang)
53         void setVariety(std::string const v) { variety_ = v; }
54         ///
55         std::string const & babel_postsettings() const { return babel_postsettings_; }
56         ///
57         bool internalFontEncoding() const { return internal_enc_; }
58         ///
59         bool read(Lexer & lex);
60         ///
61         bool readLanguage(Lexer & lex);
62         // for the use in std::map
63         friend bool operator<(Language const & p, Language const & q);
64 private:
65         ///
66         std::string lang_;
67         ///
68         std::string babel_;
69         ///
70         std::string display_;
71         ///
72         bool rightToLeft_;
73         ///
74         std::string encodingStr_;
75         ///
76         Encoding const * encoding_;
77         ///
78         std::string code_;
79         ///
80         std::string variety_;
81         ///
82         std::string babel_postsettings_;
83         ///
84         bool internal_enc_;
85 };
86
87
88 inline bool operator<(Language const & p, Language const & q)
89 {
90         return q.lang() > p.lang();
91 }
92
93
94 class Languages
95 {
96 public:
97         ///
98         typedef std::map<std::string, Language> LanguageList;
99         ///
100         typedef LanguageList::const_iterator const_iterator;
101         ///
102         typedef LanguageList::size_type size_type;
103         ///
104         void read(support::FileName const & filename);
105         ///
106         Language const * getLanguage(std::string const & language) const;
107         ///
108         size_type size() const { return languagelist.size(); }
109         ///
110         const_iterator begin() const { return languagelist.begin(); }
111         ///
112         const_iterator end() const { return languagelist.end(); }
113         ///
114
115 private:
116         ///
117         LanguageList languagelist;
118 };
119
120 /// Global singleton instance.
121 extern Languages languages;
122 /// Default language defined in LyXRC
123 extern Language const * default_language;
124 /// Used to indicate that the language should be left unchanged when
125 /// applying a font change.
126 extern Language const * ignore_language;
127 /// Default language defined in LyXRC
128 extern Language const * latex_language;
129 /// Used to indicate that the language should be reset to the Buffer
130 // language when applying a font change.
131 extern Language const * reset_language;
132
133
134 } // namespace lyx
135
136 #endif