]> git.lyx.org Git - lyx.git/blob - src/chset.h
namespace grfx -> lyx::graphics
[lyx.git] / src / chset.h
1 // -*- C++ -*-
2 /**
3  * \file chset.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  */
7
8 #ifndef CHSET_H
9 #define CHSET_H
10
11 #include <map>
12 #include <utility>
13
14 #include "LString.h"
15
16 /// a class for mapping char strings such as "\^{A}" to the integer value
17 class CharacterSet {
18 public:
19         /**
20          * initialise this charset from the given .cdef file
21          * param charset the charset to look for
22          *
23          * Finds a .cdef file corresponding to the named charset
24          * and parses it. This function is only intended to be
25          * called once.
26          */
27         bool loadFile(string const & charset);
28         /// return the name of the current charset
29         string const & getName() const;
30         /**
31          * Return the encoded charset value of the given string.
32          *
33          * The bool value is false if an encoding could not be found
34          * in this charset, and true otherwise.
35          */
36         std::pair<bool, int> const encodeString(string const &) const;
37 private:
38         /// charset name
39         string name_;
40         ///
41         typedef std::map<string, unsigned char> Cdef;
42         /// mapping from string representation to encoded value
43         Cdef map_;
44 };
45 #endif