]> git.lyx.org Git - lyx.git/blob - src/Language.h
Make the fake sequence for braces highly unlikely (addressing #6478).
[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         ///
49         std::string const & variety() const { return variety_; }
50         ///
51         std::string const & latex_options() const { return latex_options_; }
52         ///
53         bool internalFontEncoding() const;
54         ///
55         bool read(Lexer & lex);
56         // for the use in std::map
57         friend bool operator<(Language const & p, Language const & q);
58 private:
59         ///
60         std::string lang_;
61         ///
62         std::string babel_;
63         ///
64         std::string display_;
65         ///
66         bool rightToLeft_;
67         ///
68         std::string encodingStr_;
69         ///
70         Encoding const * encoding_;
71         ///
72         std::string codeStr_;
73         ///
74         std::string code_;
75         ///
76         std::string variety_;
77         ///
78         std::string latex_options_;
79 };
80
81
82 inline bool operator<(Language const & p, Language const & q)
83 {
84         return q.lang() > p.lang();
85 }
86
87
88 class Languages
89 {
90 public:
91         ///
92         typedef std::map<std::string, Language> LanguageList;
93         ///
94         typedef LanguageList::const_iterator const_iterator;
95         ///
96         typedef LanguageList::size_type size_type;
97         ///
98         void read(support::FileName const & filename);
99         ///
100         Language const * getLanguage(std::string const & language) const;
101         ///
102         size_type size() const { return languagelist.size(); }
103         ///
104         const_iterator begin() const { return languagelist.begin(); }
105         ///
106         const_iterator end() const { return languagelist.end(); }
107         ///
108
109 private:
110         ///
111         LanguageList languagelist;
112 };
113
114 /// Global singleton instance.
115 extern Languages languages;
116 /// Default language defined in LyXRC
117 extern Language const * default_language;
118 /// Used to indicate that the language should be left unchanged when
119 /// applying a font change.
120 extern Language const * ignore_language;
121 /// Default language defined in LyXRC
122 extern Language const * latex_language;
123 /// Used to indicate that the language should be reset to the Buffer
124 // language when applying a font change.
125 extern Language const * reset_language;
126
127
128 } // namespace lyx
129
130 #endif