]> git.lyx.org Git - features.git/blob - src/mathed/MathClass.cpp
Introduce the notion of math class
[features.git] / src / mathed / MathClass.cpp
1 /**
2  * \file MathClass.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jean-Marc Lasgouttes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "MathClass.h"
14
15 #include "support/docstring.h"
16 #include "support/lassert.h"
17
18 using namespace std;
19
20 namespace lyx {
21
22
23 docstring const class_to_string(MathClass const mc)
24 {
25         string s;
26         switch (mc) {
27         case MC_ORD:
28                 s = "mathord";
29                 break;
30         case MC_OP:
31                 s = "mathop";
32                 break;
33         case MC_BIN:
34                 s = "mathbin";
35                 break;
36         case MC_REL:
37                 s = "mathrel";
38                 break;
39         case MC_OPEN:
40                 s = "mathopen";
41                 break;
42         case MC_CLOSE:
43                 s = "mathclose";
44                 break;
45         case MC_PUNCT:
46                 s = "mathpunct";
47                 break;
48         case MC_INNER:
49                 s = "mathinner";
50                 break;
51         case MC_UNKNOWN:
52                 LATTEST(false);
53                 s = "mathord";
54         }
55         return from_ascii(s);
56 }
57
58
59 MathClass string_to_class(docstring const &s)
60 {
61         if (s  == "mathop")
62                 return MC_OP;
63         else if (s  == "mathbin")
64                 return MC_BIN;
65         else if (s  == "mathrel")
66                 return MC_REL;
67         else if (s  == "mathopen")
68                 return MC_OPEN;
69         else if (s  == "mathclose")
70                 return MC_CLOSE;
71         else if (s  == "mathpunct")
72                 return MC_PUNCT;
73         else if (s  == "mathinner")
74                 return MC_INNER;
75         else  if (s  == "mathord")
76                 return MC_ORD;
77         else
78                 return MC_UNKNOWN;
79 }
80
81
82 } // namespace lyx