]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macrotable.h
Make Helge happy: no more crash on arrow up/down in math macro
[lyx.git] / src / mathed / math_macrotable.h
1 // -*- C++ -*-
2 /**
3  * \file math_macrotable.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_MACROTABLE_H
13 #define MATH_MACROTABLE_H
14
15 #include <map>
16 #include <string>
17 #include <vector>
18
19 class MathArray;
20
21
22 ///
23 class MacroData {
24 public:
25         ///
26         MacroData();
27         ///
28         MacroData(std::string const & def, int nargs, std::string const & disp);
29         ///
30         std::string def() const { return def_; }
31         ///
32         std::string disp() const { return disp_; }
33         ///
34         int numargs() const { return numargs_; }
35         /// replace #1,#2,... by given MathAtom 0,1,..
36         void expand(std::vector<MathArray> const & from, MathArray & to) const;
37
38 private:
39         ///
40         std::string def_;
41         ///
42         int numargs_;
43         ///
44         std::string disp_;
45 };
46
47
48 // This contains a table of "global" macros that are always accessible,
49 // either because they implement a feature of standard LaTeX or some
50 // hack to display certain contents nicely.
51
52 class MacroTable : public std::map<std::string, MacroData>
53 {
54 public:
55         /// Parse full "\def..." or "\newcommand..." or ...
56         void insert(std::string const & definition);
57         /// Insert pre-digested macro definition
58         void insert(std::string const & name, MacroData const & data);
59         /// Do we have a macro by that name?
60         bool has(std::string const & name) const;
61         ///
62         MacroData const & get(std::string const & name) const;
63         ///
64         void dump();
65
66         /// the global list
67         static MacroTable & globalMacros();
68         /// the local list hack
69         //static MacroTable & localMacros();
70 };
71
72 #endif