]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroTable.h
cursor is no more damaging the background. L-shaped cursor is broken right now....
[lyx.git] / src / mathed / MathMacroTable.h
1 // -*- C++ -*-
2 /**
3  * \file MathMacroTable.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 #include "support/docstring.h"
20
21 namespace lyx {
22
23 class MathArray;
24
25 ///
26 class MacroData {
27 public:
28         ///
29         MacroData();
30         ///
31         MacroData(docstring const & def, int nargs, docstring const & disp);
32         ///
33         docstring def() const { return def_; }
34         ///
35         docstring disp() const { return disp_; }
36         ///
37         int numargs() const { return numargs_; }
38         /// replace #1,#2,... by given MathAtom 0,1,..
39         void expand(std::vector<MathArray> const & from, MathArray & to) const;
40
41 private:
42         ///
43         docstring def_;
44         ///
45         int numargs_;
46         ///
47         docstring disp_;
48 };
49
50
51 // This contains a table of "global" macros that are always accessible,
52 // either because they implement a feature of standard LaTeX or some
53 // hack to display certain contents nicely.
54
55 class MacroTable : public std::map<docstring, MacroData>
56 {
57 public:
58         /// Parse full "\def..." or "\newcommand..." or ...
59         void insert(docstring const & definition);
60         /// Insert pre-digested macro definition
61         void insert(docstring const & name, MacroData const & data);
62         /// Do we have a macro by that name?
63         bool has(docstring const & name) const;
64         ///
65         MacroData const & get(docstring const & name) const;
66         ///
67         void dump();
68
69         /// the global list
70         static MacroTable & globalMacros();
71         /// the local list hack
72         //static MacroTable & localMacros();
73 };
74
75
76 } // namespace lyx
77
78 #endif