]> git.lyx.org Git - lyx.git/blob - src/chset.h
Replace LString.h with support/std_string.h,
[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
19 #include "support/std_string.h"
20
21 /// a class for mapping char strings such as "\^{A}" to the integer value
22 class CharacterSet {
23 public:
24         /**
25          * initialise this charset from the given .cdef file
26          * param charset the charset to look for
27          *
28          * Finds a .cdef file corresponding to the named charset
29          * and parses it. This function is only intended to be
30          * called once.
31          */
32         bool loadFile(string const & charset);
33         /// return the name of the current charset
34         string const & getName() const;
35         /**
36          * Return the encoded charset value of the given string.
37          *
38          * The bool value is false if an encoding could not be found
39          * in this charset, and true otherwise.
40          */
41         std::pair<bool, int> const encodeString(string const &) const;
42 private:
43         /// charset name
44         string name_;
45         ///
46         typedef std::map<string, unsigned char> Cdef;
47         /// mapping from string representation to encoded value
48         Cdef map_;
49 };
50 #endif