]> git.lyx.org Git - lyx.git/blob - src/chset.h
Real fix from Bernhard Roider
[lyx.git] / src / chset.h
1 // -*- C++ -*-
2 /**
3  * \file chset.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  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef CHSET_H
14 #define CHSET_H
15
16 #include <map>
17 #include <utility>
18 #include <string>
19
20
21 namespace lyx {
22
23 /// a class for mapping char strings such as "\^{A}" to the integer value
24 class CharacterSet {
25 public:
26         /**
27          * initialise this charset from the given .cdef file
28          * param charset the charset to look for
29          *
30          * Finds a .cdef file corresponding to the named charset
31          * and parses it. This function is only intended to be
32          * called once.
33          */
34         bool loadFile(std::string const & charset);
35         /// return the name of the current charset
36         std::string const & getName() const;
37         /**
38          * Return the encoded charset value of the given string.
39          *
40          * The bool value is false if an encoding could not be found
41          * in this charset, and true otherwise.
42          */
43         std::pair<bool, int> const encodeString(std::string const &) const;
44 private:
45         /// charset name
46         std::string name_;
47         ///
48         typedef std::map<std::string, unsigned char> Cdef;
49         /// mapping from string representation to encoded value
50         Cdef map_;
51 };
52
53 } // namespace lyx
54
55 #endif